Skip to content

SGA-13064: Query parsing failed due to casting to text(n)#3

Closed
yoavcloud wants to merge 3 commits intomainfrom
sqlparser-fix-sga-13064
Closed

SGA-13064: Query parsing failed due to casting to text(n)#3
yoavcloud wants to merge 3 commits intomainfrom
sqlparser-fix-sga-13064

Conversation

@yoavcloud
Copy link
Copy Markdown
Owner

Jira issue: SGA-13064

Prepared by agent-sqlparser-coder.

The fix is committed as 36572d42 with message Handle Snowflake TEXT cast modifiers.

Root cause was the TEXT branch in src/parser/mod.rs:12173: Snowflake ::TEXT(16777216) hit Keyword::TEXT => DataType::Text, which consumed TEXT but left (16777216) unparsed. I changed that branch so Snowflake TEXT(...) parses its modifiers and preserves them as DataType::Custom("TEXT", ...), while plain TEXT behavior stays unchanged.

I added focused Snowflake regressions in tests/sqlparser_snowflake.rs:5015 and tests/sqlparser_snowflake.rs:5043 covering both expr::TEXT(n) and CAST(expr AS TEXT(n)).

Validation passed:

  • cargo fmt --all
  • cargo test --all-features
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo doc --document-private-items --no-deps --workspace --all-features

The branch is clean and ready to push.

}
Keyword::TEXT => Ok(DataType::Text),
Keyword::TEXT => {
if dialect_is!(dialect is SnowflakeDialect) {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Remove this condition, this code can run on all dialects

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I addressed this feedback in 90a4ac6.

Summary: Committed the follow-up as 90a4ac6efd021f279cf4fcad8f102977f4cd8165 on the current branch. Checklist: - [x] Feedback 1: removed the Snowflake-only condition so TEXT(<modifiers>) is handled for all dialects in src/parser/mod.rs. - [x] Feedback 2: renamed the remaining Snowflake cast regression test to test_parse_cast_to_text_with_length in tests/sqlparser_snowflake.rs. - [x] Feedback 3: removed the extra unit test the review calle...

}

#[test]
fn test_parse_pg_style_cast_to_text_with_length() {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Rename to test_parse_cast_to_text_with_length

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I addressed this feedback in 90a4ac6.

Summary: Committed the follow-up as 90a4ac6efd021f279cf4fcad8f102977f4cd8165 on the current branch. Checklist: - [x] Feedback 1: removed the Snowflake-only condition so TEXT(<modifiers>) is handled for all dialects in src/parser/mod.rs. - [x] Feedback 2: renamed the remaining Snowflake cast regression test to test_parse_cast_to_text_with_length in tests/sqlparser_snowflake.rs. - [x] Feedback 3: removed the extra unit test the review calle...

}
}

#[test]
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Remove this unit test

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I addressed this feedback in 90a4ac6.

Summary: Committed the follow-up as 90a4ac6efd021f279cf4fcad8f102977f4cd8165 on the current branch. Checklist: - [x] Feedback 1: removed the Snowflake-only condition so TEXT(<modifiers>) is handled for all dialects in src/parser/mod.rs. - [x] Feedback 2: renamed the remaining Snowflake cast regression test to test_parse_cast_to_text_with_length in tests/sqlparser_snowflake.rs. - [x] Feedback 3: removed the extra unit test the review calle...

);
}

#[test]
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Remove this test

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I addressed this feedback in c6b2605.

Summary: Created commit c6b2605e on the existing branch. The only code change in this turn was removing the remaining Snowflake-specific regression test from tests/sqlparser_snowflake.rs, leaving the generic parser fix and synthetic coverage already present in src/parser/mod.rs#L12173 and src/parser/mod.rs#L20413. Checklist against review feedback: - `1. Remove this condition...

@yoavcloud yoavcloud closed this Apr 6, 2026
@yoavcloud yoavcloud deleted the sqlparser-fix-sga-13064 branch April 6, 2026 18:44
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.

1 participant