Skip to content

sqlglot started doing unnecessary casts to DATE when transpiling to duckdb #6770

@baruchoxman

Description

@baruchoxman

Appeared when upgrading from 28.5.0 to 28.6.0

>>> import sqlglot
>>> sqlglot.parse_one("DATE_TRUNC('WEEK', CURRENT_DATE)", "snowflake")
TimestampTrunc(
  this=CurrentDate(),
  unit=Var(this=WEEK),
  input_type_preserved=True)
>>> sqlglot.parse_one("DATE_TRUNC('WEEK', CURRENT_DATE)", "snowflake").sql("duckdb")
"CAST(DATE_TRUNC('WEEK', CURRENT_DATE) AS DATE)"
>>>

It's not a major issue, but the cast to DATE is redundant in this case.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions