You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is the library used in the plugin v0.8.1 out of date, or is this another issue like #128?
Example:
from invoices # A PRQL query begins with a table
# Subsequent lines "transform" (modify) it
derive { # "derive" adds columns to the result
transaction_fee = 0.8, # "=" sets a column name
income = total - transaction_fee # Calculations can use other column names
}
# starts a comment; commenting out a line leaves a valid query
filter income > 5 # "filter" replaces both of SQL's WHERE & HAVING
filter invoice_date >= @2010-01-16 # Clear date syntax
group customer_id ( # "group" performs the pipeline in (...) on each group
aggregate { # "aggregate" reduces each group to a single row
sum_income = sum income, # ... using SQL SUM(), COUNT(), etc. functions
ct = count customer_id, #
}
)
join c=customers (==customer_id) # join on "customer_id" from both tables
derive name = f"{c.last_name}, {c.first_name}" # F-strings like Python
derive db_version = s"version()" # S-string offers escape hatch to SQL
select { # "select" passes along only the named columns
c.customer_id, name, sum_income, ct, db_version,
} # trailing commas always ignored
sort {-sum_income} # "sort" sorts the result; "-" is decreasing order
take 1..10 # Limit to a range - could also be "take 10"
#
# The "output.sql" tab at right shows the SQL generated from this PRQL query
# The "output.arrow" tab shows the result of the query
Preview SQL output:
Waiting for a PRQL file...
Error:
╭─[:3:8]
│
3 │ derive { # "derive" adds columns to the result
│ ┬
│ ╰── unexpected {
───╯
Expected SQL output:
WITH table_1 AS (
SELECT
customer_id,
total -0.8AS _expr_0,
invoice_date
FROM
invoices
),
table_0 AS (
SELECT
COALESCE(SUM(_expr_0), 0) AS sum_income,
COUNT(*) AS ct,
customer_id
FROM
table_1
WHERE
_expr_0 >5AND invoice_date >=DATE'2010-01-16'GROUP BY
customer_id
)
SELECTc.customer_id,
CONCAT(c.last_name, ', ', c.first_name) AS name,
table_0.sum_income,
table_0.ct,
version() AS db_version
FROM
table_0
JOIN customers AS c ONtable_0.customer_id=c.customer_idORDER BYtable_0.sum_incomeDESCLIMIT10-- Generated by PRQL compiler version:0.9.1 (https://prql-lang.org)
The text was updated successfully, but these errors were encountered:
Is the library used in the plugin
v0.8.1
out of date, or is this another issue like #128?Example:
Preview SQL output:
Expected SQL output:
The text was updated successfully, but these errors were encountered: