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

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

SQL

SELECT
  LOWER(last_name) LIKE CONCAT('a', '%'),
  REPLACE(title, 'manager', 'chief')
FROM
  employees