mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-19 14:43:05 -03:00
Reorganize tests into a real spec suite
This commit is contained in:
188
spec/tests/prql/filename.txt
Normal file
188
spec/tests/prql/filename.txt
Normal file
@ -0,0 +1,188 @@
|
||||
---input---
|
||||
from invoices
|
||||
filter invoice_date >= @1970-01-16
|
||||
derive {
|
||||
transaction_fees = 0.8,
|
||||
income = total - transaction_fees
|
||||
}
|
||||
filter income > 1
|
||||
group customer_id (
|
||||
aggregate {
|
||||
average total,
|
||||
sum_income = sum income,
|
||||
ct = count total,
|
||||
}
|
||||
)
|
||||
sort {-sum_income}
|
||||
take 10
|
||||
join c=customers (==customer_id)
|
||||
derive name = f"{c.last_name}, {c.first_name}"
|
||||
select {
|
||||
c.customer_id, name, sum_income
|
||||
}
|
||||
derive db_version = s"version()"
|
||||
|
||||
---tokens---
|
||||
'from' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'invoices' Name.Variable
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'filter' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'invoice_date' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'>=' Operator
|
||||
' ' Text.Whitespace
|
||||
'@1970-01-16' Literal.Date
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'derive' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'{' Punctuation
|
||||
'\n ' Text.Whitespace
|
||||
'transaction_fees' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'=' Operator
|
||||
' ' Text.Whitespace
|
||||
'0.8' Literal.Number.Float
|
||||
',' Punctuation
|
||||
'\n ' Text.Whitespace
|
||||
'income' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'=' Operator
|
||||
' ' Text.Whitespace
|
||||
'total' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'-' Operator
|
||||
' ' Text.Whitespace
|
||||
'transaction_fees' Name.Variable
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'}' Punctuation
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'filter' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'income' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'>' Operator
|
||||
' ' Text.Whitespace
|
||||
'1' Literal.Number.Integer
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'group' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'customer_id' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'(' Punctuation
|
||||
'\n ' Text.Whitespace
|
||||
'aggregate' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'{' Punctuation
|
||||
'\n ' Text.Whitespace
|
||||
'average' Name.Function
|
||||
' ' Text.Whitespace
|
||||
'total' Name.Variable
|
||||
',' Punctuation
|
||||
'\n ' Text.Whitespace
|
||||
'sum_income' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'=' Operator
|
||||
' ' Text.Whitespace
|
||||
'sum' Name.Function
|
||||
' ' Text.Whitespace
|
||||
'income' Name.Variable
|
||||
',' Punctuation
|
||||
'\n ' Text.Whitespace
|
||||
'ct' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'=' Operator
|
||||
' ' Text.Whitespace
|
||||
'count' Name.Function
|
||||
' ' Text.Whitespace
|
||||
'total' Name.Variable
|
||||
',' Punctuation
|
||||
'\n ' Text.Whitespace
|
||||
'}' Punctuation
|
||||
'\n' Text.Whitespace
|
||||
|
||||
')' Punctuation
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'sort' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'{' Punctuation
|
||||
'-' Operator
|
||||
'sum_income' Name.Variable
|
||||
'}' Punctuation
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'take' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'10' Literal.Number.Integer
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'join' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'c' Name.Variable
|
||||
'=' Operator
|
||||
'customers' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'(' Punctuation
|
||||
'==' Operator
|
||||
'customer_id' Name.Variable
|
||||
')' Punctuation
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'derive' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'name' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'=' Operator
|
||||
' ' Text.Whitespace
|
||||
'f' Literal.String.Affix
|
||||
'"' Literal.String.Double
|
||||
'{' Literal.String.Interpol
|
||||
'c' Name.Variable
|
||||
'.' Operator
|
||||
'last_name' Name.Variable
|
||||
'}' Literal.String.Interpol
|
||||
', ' Literal.String.Double
|
||||
'{' Literal.String.Interpol
|
||||
'c' Name.Variable
|
||||
'.' Operator
|
||||
'first_name' Name.Variable
|
||||
'}' Literal.String.Interpol
|
||||
'"' Literal.String.Double
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'select' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'{' Punctuation
|
||||
'\n ' Text.Whitespace
|
||||
'c' Name.Variable
|
||||
'.' Operator
|
||||
'customer_id' Name.Variable
|
||||
',' Punctuation
|
||||
' ' Text.Whitespace
|
||||
'name' Name.Variable
|
||||
',' Punctuation
|
||||
' ' Text.Whitespace
|
||||
'sum_income' Name.Variable
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'}' Punctuation
|
||||
'\n' Text.Whitespace
|
||||
|
||||
'derive' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'db_version' Name.Variable
|
||||
' ' Text.Whitespace
|
||||
'=' Operator
|
||||
' ' Text.Whitespace
|
||||
's' Literal.String.Affix
|
||||
'"' Literal.String.Double
|
||||
'version()' Literal.String.Double
|
||||
'"' Literal.String.Double
|
||||
'\n' Text.Whitespace
|
13
spec/tests/prql/fstring.txt
Normal file
13
spec/tests/prql/fstring.txt
Normal file
@ -0,0 +1,13 @@
|
||||
---input---
|
||||
f"Hello {name}!"
|
||||
|
||||
---tokens---
|
||||
'f' Literal.String.Affix
|
||||
'"' Literal.String.Double
|
||||
'Hello ' Literal.String.Double
|
||||
'{' Literal.String.Interpol
|
||||
'name' Name.Variable
|
||||
'}' Literal.String.Interpol
|
||||
'!' Literal.String.Double
|
||||
'"' Literal.String.Double
|
||||
'\n' Text.Whitespace
|
11
spec/tests/prql/rstring.txt
Normal file
11
spec/tests/prql/rstring.txt
Normal file
@ -0,0 +1,11 @@
|
||||
---input---
|
||||
r"Not \n escaped"
|
||||
|
||||
---tokens---
|
||||
'r' Literal.String.Affix
|
||||
'"' Literal.String.Double
|
||||
'Not ' Literal.String.Double
|
||||
'\\' Literal.String.Double
|
||||
'n escaped' Literal.String.Double
|
||||
'"' Literal.String.Double
|
||||
'\n' Text.Whitespace
|
9
spec/tests/prql/sstring.txt
Normal file
9
spec/tests/prql/sstring.txt
Normal file
@ -0,0 +1,9 @@
|
||||
---input---
|
||||
s"version()"
|
||||
|
||||
---tokens---
|
||||
's' Literal.String.Affix
|
||||
'"' Literal.String.Double
|
||||
'version()' Literal.String.Double
|
||||
'"' Literal.String.Double
|
||||
'\n' Text.Whitespace
|
Reference in New Issue
Block a user