from_text

    • format:csv parses CSV (default),
    • format:json parses either:
      • an array of objects each of which represents a row, or
      • an object with fields columns & data, where columns take an array of column names and data takes an array of arrays.

    PRQL

    SQL

    1. WITH table_0 AS (
    2. SELECT
    3. '1' AS a,
    4. '2' AS b,
    5. '3' AS c
    6. UNION
    7. ALL
    8. SELECT
    9. '4' AS a,
    10. '5' AS b,
    11. '6' AS c
    12. )
    13. SELECT
    14. a,
    15. b,
    16. c,
    17. b + c AS d,
    18. 42 AS answer
    19. FROM
    20. table_0 AS table_1

    PRQL

    SQL

    1. WITH table_0 AS (
    2. SELECT
    3. 'uk' AS country_code,
    4. 'C' AS format
    5. UNION
    6. ALL
    7. 'us' AS country_code,
    8. UNION
    9. ALL
    10. SELECT
    11. 'lr' AS country_code,
    12. 'F' AS format
    13. UNION
    14. ALL
    15. SELECT
    16. 'de' AS country_code,
    17. 'C' AS format
    18. ),
    19. temp_format_lookup AS (
    20. SELECT
    21. country_code,
    22. format
    23. FROM
    24. table_0 AS table_1
    25. )
    26. SELECT
    27. temperatures.*,
    28. temp_format_lookup.country_code,
    29. temp_format_lookup.format
    30. FROM
    31. temperatures
    32. JOIN temp_format_lookup ON temperatures.country_code = temp_format_lookup.country_code

    PRQL

    SQL

    1. WITH table_0 AS (
    2. SELECT
    3. 1 AS a,
    4. 'x' AS b,
    5. false AS c
    6. UNION
    7. ALL
    8. SELECT
    9. 4 AS a,
    10. NULL AS c
    11. ),
    12. x AS (
    13. SELECT
    14. a,
    15. b,
    16. c
    17. FROM
    18. table_0 AS table_1
    19. ),
    20. table_2 AS (
    21. SELECT
    22. 1 AS a,
    23. '5' AS m
    24. UNION
    25. ALL
    26. SELECT
    27. 4 AS a,
    28. NULL AS m
    29. ),
    30. y AS (
    31. SELECT
    32. a,
    33. m
    34. FROM
    35. table_2 AS table_3
    36. )
    37. SELECT
    38. x.a,
    39. x.b,
    40. x.c,
    41. y.a,
    42. y.m
    43. FROM
    44. JOIN y ON x.a = y.a