Skip to content

Conversation

@lustefaniak
Copy link
Collaborator

@lustefaniak lustefaniak commented Oct 23, 2025

Problem:
The lineage parser failed to parse CREATE TABLE statements with schema-qualified or fully-qualified tag names in the WITH TAG clause. For example: WITH TAG (STAGE.TAG_SCHEMA.DOMAIN_MAPPING='marketing')

Root Cause:
The SqlOption struct used WithSpan for the tag name, which only supports simple identifiers. Snowflake allows multi-part tag names like:

  • Simple: TAG_NAME='value'
  • Schema-qualified: SCHEMA.TAG_NAME='value'
  • Fully-qualified: DB.SCHEMA.TAG_NAME='value'

Solution:

  1. Changed SqlOption.name from WithSpan to ObjectName
  2. Updated parse_sql_option to use parse_object_name() instead of parse_identifier()
  3. Added comprehensive tests for all tag qualification levels
  4. Updated existing test assertions to use ObjectName format

Impact:

  • Lineage parser can now extract lineage from tables with dotted tag names
  • All tag qualification levels are supported
  • Backward compatible with simple tag names

Files Changed:

  • src/ast/mod.rs: Updated SqlOption struct
  • src/parser/mod.rs: Updated parse_sql_option function
  • tests/sqlparser_snowflake.rs: Added comprehensive tag name tests
  • tests/sqlparser_common.rs: Updated test assertions
  • tests/sqlparser_postgres.rs: Updated test assertions

Allow multi-part tag names in WITH TAG clause:
- Simple: TAG_NAME='value'
- Schema-qualified: SCHEMA.TAG_NAME='value'
- Fully-qualified: DB.SCHEMA.TAG_NAME='value'

Changed SqlOption.name from WithSpan<Ident> to ObjectName
to support qualified tag identifiers.
@lustefaniak lustefaniak force-pushed the claude/fix-lineage-parser-tag-011CUQTtYrecpXvus5HBRFE6 branch from 39ead46 to 4623358 Compare October 24, 2025 09:07
@lustefaniak lustefaniak changed the title Fix Snowflake WITH TAG parsing to support dotted tag names sqlparser-rs: Snowflake WITH TAG dotted names Oct 24, 2025
@lustefaniak lustefaniak changed the title sqlparser-rs: Snowflake WITH TAG dotted names snowflake: WITH TAG dotted names Oct 24, 2025
@lustefaniak lustefaniak merged commit f33a533 into main Oct 24, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants