Skip to content

Support struct type in Scribe#146

Merged
xd1313113 merged 10 commits intomainfrom
dixiao/struct
Apr 20, 2026
Merged

Support struct type in Scribe#146
xd1313113 merged 10 commits intomainfrom
dixiao/struct

Conversation

@xd1313113
Copy link
Copy Markdown
Contributor

@xd1313113 xd1313113 commented Mar 30, 2026

Issue #, if available:
None
Description of changes:
Adds support for transpiling PartiQL struct types into multiple SQL dialects, including struct field navigation and struct construction, and expands golden test coverage for these cases.

Changes:

Add new struct.sql input fixture plus expected outputs for PartiQL, Trino, Spark, and Redshift.
Update Spark struct construction to use NAMED_STRUCT, and adjust Spark EXCLUDE golden outputs accordingly.
Extend Trino/Redshift rewrites to handle constructed structs (and, for Redshift, to hard-fail unsupported constructed-struct field access).

Each Tests are manually tested on each sql engine.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for transpiling PartiQL struct types into multiple SQL dialects, including struct field navigation and struct construction, and expands golden test coverage for these cases.

Changes:

  • Add new struct.sql input fixture plus expected outputs for PartiQL, Trino, Spark, and Redshift.
  • Update Spark struct construction to use NAMED_STRUCT, and adjust Spark EXCLUDE golden outputs accordingly.
  • Extend Trino/Redshift rewrites to handle constructed structs (and, for Redshift, to hard-fail unsupported constructed-struct field access).

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/test/resources/outputs/trino/basics/struct.sql New Trino golden outputs covering struct selection, navigation, wildcard expansion, and construction.
src/test/resources/outputs/spark/basics/struct.sql New Spark golden outputs using NAMED_STRUCT for struct construction and field access.
src/test/resources/outputs/spark/basics/exclude.sql Updates Spark EXCLUDE golden outputs to use NAMED_STRUCT instead of STRUCT(... AS ...).
src/test/resources/outputs/redshift/basics/struct.sql New Redshift golden outputs using OBJECT(...) and documenting unsupported constructed-struct field access.
src/test/resources/outputs/partiql/basics/struct.sql New PartiQL golden outputs for struct behaviors (baseline dialect).
src/test/resources/inputs/basics/struct.sql New input fixture covering struct cases (navigation, dot-star, construction, filtering, join, subquery).
src/test/resources/catalogs/default/T_ALL_TYPES.ion Updates catalog schema to include col_struct_simple and col_struct_nested with nested struct fields.
src/main/kotlin/org/partiql/scribe/targets/trino/utils/TrinoExcludeUtils.kt Extends Trino ROW reconstruction to also handle RexStruct operands; adjusts UNKNOWN type handling.
src/main/kotlin/org/partiql/scribe/targets/trino/TrinoRewriter.kt Wraps constructed structs in CAST-to-ROW when used in path navigation; rewrites nested RexStruct fields.
src/main/kotlin/org/partiql/scribe/targets/trino/TrinoAstToSql.kt Adds a defensive error path for ExprStruct reaching AST-to-SQL conversion.
src/main/kotlin/org/partiql/scribe/targets/spark/SparkAstToSql.kt Switches struct construction emission to NAMED_STRUCT and adds struct-field emission visitor.
src/main/kotlin/org/partiql/scribe/targets/redshift/RedshiftRewriter.kt Throws a targeted error when accessing fields on constructed structs (unsupported in Redshift).
api/Scribe.api Captures new public API surface from added visitor overrides.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/kotlin/org/partiql/scribe/targets/trino/utils/TrinoExcludeUtils.kt Outdated
Comment thread src/test/resources/outputs/trino/basics/struct.sql Outdated
Comment thread src/test/resources/outputs/redshift/basics/struct.sql
Comment thread src/main/kotlin/org/partiql/scribe/targets/trino/TrinoAstToSql.kt Outdated
Comment thread src/test/resources/outputs/redshift/basics/struct.sql
Copy link
Copy Markdown
Member

@johnedquinn johnedquinn left a comment

Choose a reason for hiding this comment

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

Overall looks good. Minor comments.

Copy link
Copy Markdown

@XuechunHHH XuechunHHH left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@xd1313113 xd1313113 merged commit 1a1f1e6 into main Apr 20, 2026
4 checks passed
@xd1313113 xd1313113 deleted the dixiao/struct branch April 20, 2026 17:00
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.

4 participants