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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
6 changes: 6 additions & 0 deletions crates/sqlquack-semantics/src/lineage/tests/test_checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading