Skip to content

Snowflake: Parse structured OBJECT types - #2489

Open
osipovartem wants to merge 5 commits into
apache:mainfrom
Embucket:upstream-snowflake-structured-object-independent
Open

osipovartem wants to merge 5 commits into
apache:mainfrom
Embucket:upstream-snowflake-structured-object-independent

Conversation

@osipovartem

Copy link
Copy Markdown
Contributor

Snowflake structured OBJECT types can contain named, nullable or NOT NULL fields and recursively nested OBJECT types. The generic Custom(Vec<String>) representation loses these boundaries.

This adds DataType::Object(Vec<ColumnDef>), a Snowflake dialect capability, recursive parsing and formatting, and leaves unstructured OBJECT unchanged.

Validated against:
https://docs.snowflake.com/en/sql-reference/data-types-structured#structured-object-types

Tests cover nested types, NOT NULL AST preservation, unstructured OBJECT, and malformed definitions.

AI assistance: Codex was used to prepare the implementation and tests.

Comment thread src/dialect/snowflake.rs Outdated
@osipovartem
osipovartem requested a review from iffyio September 10, 2026 10:12
Comment thread src/dialect/mod.rs Outdated
Comment thread tests/sqlparser_snowflake.rs Outdated
@osipovartem
osipovartem requested a review from iffyio September 11, 2026 13:47
// With table function args, without alias
snowflake().verified_stmt("SELECT $1, $2 FROM @mystage1(file_format => 'myformat')");
}
#[test]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
#[test]
#[test]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added the missing blank line before the test in 0d58c18.

snowflake().verified_stmt("SELECT $1, $2 FROM @mystage1(file_format => 'myformat')");
}
#[test]
fn test_structured_object_type() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we're missing a test case for how the PR handles plain OBJECT as a type (as mentioned in my previous review comment)

@osipovartem osipovartem Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added an explicit test_plain_object_type in 0d58c18. It verifies both Snowflake and Generic dialect parsing and asserts that plain OBJECT remains DataType::Custom("OBJECT", []), while OBJECT(...) uses the new structured representation. cargo test --all-targets and cargo clippy --all-targets --all-features -- -D warnings pass locally.

@osipovartem
osipovartem requested a review from iffyio September 14, 2026 09:41
Comment thread tests/sqlparser_snowflake.rs Outdated
Comment on lines +4946 to +4948

#[test]
fn test_plain_object_type() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's merge this with the existing test case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. I folded the plain OBJECT assertion into test_structured_object_type and removed the separate test case. The targeted Snowflake parser test passes locally.

@osipovartem
osipovartem requested a review from iffyio September 14, 2026 11:43
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.

2 participants