Skip to content

Fix(athena): Properly extend Athena dialect#5077

Merged
erindru merged 4 commits intomainfrom
erin/fix-athena
Jul 31, 2025
Merged

Fix(athena): Properly extend Athena dialect#5077
erindru merged 4 commits intomainfrom
erin/fix-athena

Conversation

@erindru
Copy link
Collaborator

@erindru erindru commented Jul 31, 2025

Closes #5065

I think Athena has been broken since SQLMesh v0.198.0 were we upgraded SQLGlot to v26.32.0.

With that upgrade:

  • Athena stopped extending Trino and became its own top-level Dialect
  • It also defined some extra top-level Parser/Tokenizer/Generator classes that could not be reached directly from <dialect>.Parser, <dialect>.Tokenizer etc

This PR includes the extra set of top-level classes when extending the Athena dialect and adds a test that checks MODEL (...) can be roundtripped across every dialect

- redshift
- bigquery
- clickhouse-cloud
#- snowflake
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: revert prior to merge

@georgesittas
Copy link
Contributor

Thanks for taking this on. I'm surprised this wasn't caught by any tests.

@erindru
Copy link
Collaborator Author

erindru commented Jul 31, 2025

I'm surprised this wasn't caught by any tests.

Me too. I think it was partially working for the parser because Hive.Parser is not instantiated by the Athena dialect until runtime and it had already been patched.

It was the Generator path that was getting missed because:

  • the class is created at import time before the parent class Trino.Generator gets monkeypatched
  • it redefines TRANSFORMS, so the runtime changes to inject the SQLMesh transforms into the base class don't flow through

We also have a tendency to assume in the test suite that if it works for duckdb, it works for everything

@erindru erindru enabled auto-merge (squash) July 31, 2025 18:32
@erindru erindru merged commit 7b88251 into main Jul 31, 2025
27 checks passed
@erindru erindru deleted the erin/fix-athena branch July 31, 2025 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: Unsupported expression type Model when altering table using Athena

2 participants