Skip to content

[DRAFT] fix: Constant-fold inline struct literal path access in TrinoRewriter#147

Closed
am357 wants to merge 1 commit intomainfrom
chore-union-all-trino
Closed

[DRAFT] fix: Constant-fold inline struct literal path access in TrinoRewriter#147
am357 wants to merge 1 commit intomainfrom
chore-union-all-trino

Conversation

@am357
Copy link
Copy Markdown

@am357 am357 commented Apr 3, 2026

When a UNION ALL query contains inline struct literal path access like {'x': t1.b, 'y': t1.c}."x", the TrinoRewriter now resolves it at rewrite time to the matching field value (e.g., t1.b). This is necessary because none of Scribe's transpilation targets (Trino, Spark, Redshift) support PartiQL's {key: value, ...} struct literal syntax.

The issue was specifically triggered for UNION ALL queries where SQL Select columns get transcribed to a literal struct.

Added a Trino sandbox test suite to reproduce and verify the fix.

Issue #, if available:

Description of changes:

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

When a UNION ALL query contains inline struct literal path access like
`{'x': t1.b, 'y': t1.c}."x"`, the TrinoRewriter now resolves it at
rewrite time to the matching field value (e.g., `t1.b`). This is
necessary because none of Scribe's transpilation targets (Trino, Spark,
Redshift) support PartiQL's `{key: value, ...}` struct literal syntax.

The issue was specifically triggered for UNION ALL queries where SQL
Select columns get transcribed to a literal struct.

Added a Trino sandbox test suite to reproduce and verify the fix.
@am357 am357 force-pushed the chore-union-all-trino branch from 054095c to d786102 Compare April 6, 2026 16:51
@am357 am357 marked this pull request as ready for review April 6, 2026 16:53
@am357 am357 requested a review from xd1313113 April 6, 2026 16:54
@xd1313113
Copy link
Copy Markdown
Contributor

xd1313113 commented Apr 6, 2026

This looks a partial duplication of the PR which supports struct transpilation, however it does not solve the issue. I might mislead the investigation. We might need to provide a template for customer to ask for origin query, transcribed SQL dialect, schema info and version info.

@am357
Copy link
Copy Markdown
Author

am357 commented Apr 8, 2026

This looks a partial duplication of the PR which supports struct transpilation, however it does not solve the issue. I might mislead the investigation. We might need to provide a template for customer to ask for origin query, transcribed SQL dialect, schema info and version info.

* [Support struct type in Scribe #146](https://github.com/partiql/partiql-scribe/pull/146)

That seems right. I will close this PR for now.

@am357 am357 closed this Apr 8, 2026
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