fix(mysql): Fix AttributeError crash when transpiling IGNORE/RESPECT NULLS#7361
Merged
geooo109 merged 3 commits intotobymao:mainfrom Mar 24, 2026
Merged
Conversation
Collaborator
|
Hello @ShubhamKapoor992 , thanks for the PR. |
geooo109
reviewed
Mar 24, 2026
Repository owner
deleted a comment from
ShubhamKapoor992
Mar 24, 2026
geooo109
reviewed
Mar 24, 2026
Collaborator
geooo109
left a comment
There was a problem hiding this comment.
@ShubhamKapoor992 deleted the previous comments to make more clear what we should do at once, thanks.
geooo109
reviewed
Mar 24, 2026
Contributor
Author
@geooo109 Thank you. Any idea why the PR test fails home/runner/work/sqlglot/sqlglot/sqlglot/generators/bigquery.py: error: Duplicate module named "sqlglot.generators.bigquery" (also at "/home/runner/work/sqlglot/sqlglot/sqlglot/generators/bigquery.py") |
Collaborator
|
@ShubhamKapoor992 nothing to worry about, I'm waiting for this #7381 and after I will merge. |
Contributor
Author
Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7359
Description
Fixes a critical bug where MySQL dialect crashes with
AttributeErrorwhen transpiling SQL containingIGNORE NULLSorRESPECT NULLSclauses in window functions.Problem
When transpiling window functions with
IGNORE NULLSorRESPECT NULLSfrom other dialects (e.g., Snowflake, DuckDB) to MySQL, the generator crashes with:AttributeError: 'IgnoreNulls' object has no attribute 'sql_name'
AttributeError: 'RespectNulls' object has no attribute 'sql_name'
Root Cause
NULL_ORDERING_SUPPORTED = False, which triggers NULL ordering simulation logicgenerator.py:ordered_sql()retrieveswindow.thisto check window function propertieswindow.thiscan be anIgnoreNullsorRespectNullswrapper object (not the actual window function).sql_name()on these wrapper objects, which don't have that methodExample
Solution
Added logic to unwrap IgnoreNulls and RespectNulls wrapper objects before accessing window function properties.
Changes
File: sqlglot/generator.py (lines 2857-2862)
Testing
✅ All 1,059 existing tests pass (17,694 subtests)
✅ Tested across 9 database vendors (MySQL, Oracle, PostgreSQL, Snowflake, BigQuery, Redshift, Spark, Hive, DuckDB)
✅ No regressions introduced
✅ MySQL now successfully transpiles IGNORE/RESPECT NULLS without crashing