Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions coverage/syntax/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"catalogue/utility.toml": "55b30dcf06bf8182232a0da6b1da75462ae171e015cc8c9b8b95b36a722b44c5",
"sources.toml": "a180c722616dfefc1568edf41938a0abf491f5a89f9609a1f666a50aa5aead94"
},
"parser_tree": "2de58a44aca56391ee1dbe36a091556e469b7a9d",
"parser_tree": "cc21b65e16782fc53d833e5ec10a9bc3ba9fdc04",
"forms": {
"sf.classes.anomaly-detection.commands.create-anomaly-detection": "unverified",
"sf.classes.anomaly-detection.commands.drop-anomaly-detection": "unverified",
Expand Down Expand Up @@ -2637,7 +2637,7 @@
"sf.functions.trim": "verified",
"sf.functions.trunc.trunc": "verified",
"sf.functions.trunc.truncate": "verified",
"sf.functions.trunc2": "verified",
"sf.functions.trunc2": "unverified",
"sf.functions.try-base64-decode-binary": "verified",
"sf.functions.try-base64-decode-string": "verified",
"sf.functions.try-cast": "verified",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1860,14 +1860,6 @@ impl Parser {
"DATE_TRUNC" | "DATETRUNC" if !args.is_empty() => Some(0),
"DATEDIFF" | "TIMEDIFF" | "TIMESTAMPDIFF" if args.len() == TERNARY_ARITY => Some(0),
"EXTRACT" if args.len() == BINARY_ARITY => Some(0),
"TRUNC" | "TRUNCATE"
if args.len() == BINARY_ARITY
&& matches!(&args[1], Expression::Column(c)
if c.table.is_none() && !c.name.quoted)
&& self.try_parse_date_part_unit_expr(&args[1]).is_some() =>
{
Some(1)
}
_ => None,
},
_ => None,
Expand Down
14 changes: 8 additions & 6 deletions crates/sqlquack-syntax/tests/parser/test_fixes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,18 @@ fn given_auditor_tree_findings_when_parsing_faithfully_then_the_tree_records_wha
expected_value: json!("DAY"),
},
ProjectionTestCase {
description: "TRUNC's date part is a date part",
sql: "SELECT TRUNC(1, DAY)",
pointer: "/function/args/1/var/this",
description:
"TRUNC's bare second argument stays a column, a date part only by the first's type",
sql: "SELECT TRUNC(x, DAY)",
pointer: "/function/args/1/column/name/name",
expected_value: json!("DAY"),
},
ProjectionTestCase {
description: "TRUNC's numeric scale column stays a column",
sql: "SELECT TRUNC(1, c1)",
description:
"TRUNCATE's scale column named like a date part abbreviation stays a column",
sql: "SELECT TRUNCATE(x, s)",
pointer: "/function/args/1/column/name/name",
expected_value: json!("c1"),
expected_value: json!("s"),
},
ProjectionTestCase {
description: "unary plus keeps its operator",
Expand Down
Loading