diff --git a/crates/sqlquack-semantics/src/lineage/_helpers/checks/coercion.rs b/crates/sqlquack-semantics/src/lineage/_helpers/checks/coercion.rs index 520e5d86d..28be18ebb 100644 --- a/crates/sqlquack-semantics/src/lineage/_helpers/checks/coercion.rs +++ b/crates/sqlquack-semantics/src/lineage/_helpers/checks/coercion.rs @@ -88,12 +88,17 @@ pub(crate) fn predicate(engine: Engine, family: Family) -> bool { || engine.predicates().contains(&family) } -/// Whether `expression` is a string literal, past aliases and parentheses. +/// Whether `expression` is a string literal, past aliases, parentheses and comments. pub(crate) fn string_literal(expression: &Expression) -> bool { match expression { Expression::Literal(literal) => matches!(literal.as_ref(), Literal::String(_)), Expression::Alias(alias) => string_literal(&alias.this), Expression::Paren(paren) => string_literal(&paren.this), + Expression::Annotated(annotated) + if annotated.type_assertion.is_none() && annotated.type_like.is_none() => + { + string_literal(&annotated.this) + } _ => false, } } diff --git a/crates/sqlquack-semantics/src/lineage/tests/test_checks.rs b/crates/sqlquack-semantics/src/lineage/tests/test_checks.rs index f4b04106e..e1be90b71 100644 --- a/crates/sqlquack-semantics/src/lineage/tests/test_checks.rs +++ b/crates/sqlquack-semantics/src/lineage/tests/test_checks.rs @@ -214,6 +214,12 @@ fn given_a_snowflake_query_when_checking_built_in_calls_and_types_then_definite_ sql: "SELECT id, status FROM orders UNION ALL BY NAME SELECT status, id FROM orders", expected_findings: &[], }, + QueryFindingsTestCase { + description: "a timestamp against a date string with a comment after it converts", + sql: "SELECT cutoff FROM shipments WHERE shipped_at >= '2026-10-03' /* c */ \ + AND shipped_at < '2026-10-04' -- c\n", + expected_findings: &[], + }, QueryFindingsTestCase { description: "a number plus text, which Snowflake converts", sql: "SELECT id + status AS d FROM orders",