Skip to content

[SQL] Allow ROW field access without qualifying table#6388

Queued
mihaibudiu wants to merge 1 commit into
feldera:mainfrom
mihaibudiu:issue3636
Queued

[SQL] Allow ROW field access without qualifying table#6388
mihaibudiu wants to merge 1 commit into
feldera:mainfrom
mihaibudiu:issue3636

Conversation

@mihaibudiu
Copy link
Copy Markdown
Contributor

Fixes #3636

for TABLE T(ROW R(x INT) r) you could not write r.x, you had to write T.r.x.

I thought this was a Calcite bug, but it actually was a configurable behavior; the behavior we had was SQL standard, but we want a more lenient one, which is supported by multiple dialects.

Describe Manual Test Plan

Ran manually the Java tests.

Checklist

  • Unit tests added/updated

@mihaibudiu mihaibudiu requested a review from lalithsuresh June 4, 2026 00:55
@mihaibudiu mihaibudiu enabled auto-merge June 4, 2026 00:55
@mihaibudiu mihaibudiu disabled auto-merge June 4, 2026 00:56
Copy link
Copy Markdown

@mythical-fred mythical-fred left a comment

Choose a reason for hiding this comment

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

APPROVE.

Minimal, targeted fix: override createStructType on the type factory to tag every struct with StructKind.PEEK_FIELDS_NO_EXPAND, matching the lenient dialect behavior #3636 asked for. Regression test covers both qualified (t.r.b) and unqualified (r.b) field access on a ROW column.

One sanity-check question (non-blocking): the override applies to all struct types the factory creates, not just user-declared ROW(...) columns — relation row types built during planning go through the same path. PEEK_FIELDS_NO_EXPAND is one level (no recursive peek) so I don't see how this can introduce a new ambiguity that the regular FROM-clause column namespace doesn't already handle, but if you've already convinced yourself of that via the wider Java test run feel free to ignore.

@mihaibudiu mihaibudiu added this pull request to the merge queue Jun 4, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 4, 2026
@mihaibudiu mihaibudiu added this pull request to the merge queue Jun 4, 2026
@mythical-fred
Copy link
Copy Markdown

Two small things I noticed in the latest push (b6d1c4c08e) — not blockers, fine to land as-is and clean up in a follow-up:

  1. SqlToRelCompiler.java picks up import javax.xml.datatype.DatatypeFactory; that nothing in the file uses. Looks like an IDE auto-import; the lint will flag it.

  2. QATests.java line ~30 has a stray Expand commentComment on line R30Resolved glued to the end of the 'connectors' = '[]' example comment — that's the GitHub review-UI "expand thread" text accidentally pasted into the source. Should just be deleted from the comment block.

The StructKind.PEEK_FIELDS_NO_EXPAND override and the new Regression3Tests.issue3636 coverage still look right.

@mihaibudiu mihaibudiu removed this pull request from the merge queue due to a manual request Jun 4, 2026
@mihaibudiu mihaibudiu force-pushed the issue3636 branch 2 times, most recently from a03f514 to 4c19a3b Compare June 4, 2026 04:26
@mihaibudiu mihaibudiu enabled auto-merge June 4, 2026 04:26
@mihaibudiu mihaibudiu added this pull request to the merge queue Jun 4, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 4, 2026
@mihaibudiu mihaibudiu added this pull request to the merge queue Jun 4, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 4, 2026
Copy link
Copy Markdown

@mythical-fred mythical-fred left a comment

Choose a reason for hiding this comment

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

Re-APPROVE on 4c19a3b055.

Force-push rebases the prior b6d1c4c08e onto the v0.306.0 prep commit and addresses both follow-up nits from issue comment 4618836591:

  • The stray import javax.xml.datatype.DatatypeFactory; is gone from SqlToRelCompiler.java (only the intentional StructKind import remains in this PR's diff).
  • The "Expand commentComment on line R30Resolved" GitHub-UI paste is gone from the QATests.java comment block.

Substantive code is unchanged from the prior approve: StructKind.PEEK_FIELDS_NO_EXPAND override on createStructType/builder(), the two new Regression3Tests.issue3636 cases covering col.field2 and mixed t.r.b / r.b access, the replaceConnectors helper + reshaped getQATests (now scans new/workloads and .), and the types.md removal of the obsolete "must qualify with table name" caveat. Ship it.

@mihaibudiu mihaibudiu added this pull request to the merge queue Jun 4, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 4, 2026
@mihaibudiu
Copy link
Copy Markdown
Contributor Author

This blocked waiting for apache/calcite#4993 to merge

@mihaibudiu mihaibudiu added the Calcite Fix required in Calcite label Jun 4, 2026
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
@mihaibudiu mihaibudiu added this pull request to the merge queue Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Calcite Fix required in Calcite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SQL] Can only project ROW fields when fully qualified

3 participants