Text functions

These are all the functions defined in the text module:

functionparametersdescription
containssub colReturns true if col contains sub
ends_withsub colReturns true if col ends with sub
extractidx len colExtracts a substring at the index idx (starting at 1) with the length len
lengthcolReturns the number of characters in col
lowercolConverts col to lower case
ltrimcolRemoves all the whitespaces from the left side of col
replacebefore after colReplaces any occurrences of before with after in col
rtrimcolRemoves all the whitespaces from the right side of col
starts_withsub colReturns true if col starts with sub
trimcolRemoves all the whitespaces from both sides of col
uppercolConverts col to upper case

Example

PRQL

  1. from employees
  2. select {
  3. last_name | text.lower | text.starts_with("a"),
  4. title | text.replace "manager" "chief"
  5. }

SQL

  1. SELECT
  2. LOWER(last_name) LIKE CONCAT('a', '%'),
  3. REPLACE(title, 'manager', 'chief')
  4. FROM
  5. employees