Strings

Strings in PRQL can use either single or double quotes:

PRQL

  1. from my_table
  2. select x = "hello world"

SQL

  1. SELECT
  2. 'hello world' AS x
  3. FROM
  4. my_table

PRQL

  1. from my_table
  2. select x = 'hello world'

SQL

  1. SELECT
  2. 'hello world' AS x
  3. FROM
  4. my_table

To quote a string containing quotes, either use the “other” type of quote, or use 3, 4, 5 or 6 quotes, and close with the same number.

PRQL

  1. from my_table
  2. select x = '"hello world"'

SQL

  1. SELECT
  2. '"hello world"' AS x
  3. FROM
  4. my_table

PRQL

  1. from my_table
  2. select x = """I said "hello world"!"""

SQL

  1. SELECT
  2. 'I said "hello world"!' AS x
  3. FROM
  4. my_table

PRQL

  1. from my_table
  2. select x = """""I said """hello world"""!"""""

SQL

  1. SELECT
  2. 'I said """hello world"""!' AS x
  3. FROM
  4. my_table

Strings can also contain any escape defined by JSON standard.

PRQL

  1. from my_table
  2. select x = "\t\tline ends here\n \\ "

SQL

  1. SELECT
  2. ' line ends here
  3. \ ' AS x
  4. FROM
  5. my_table

F-Strings and S-Strings

These special case strings can be used to:

F-strings - Build up a new string from a set of columns or values

S-strings - Insert SQL statements directly into the query. Use when PRQL doesn’t have an equivalent facility.

Warning

Currently PRQL allows multiline strings with either a single character or multiple character quotes. This may change for strings using a single character quote in future versions.