Skip to content

[SQL] Improved unused field analysis: proper dataflow analysis, and less conservative handling of nullable tuples#5826

Merged
mihaibudiu merged 1 commit intomainfrom
unused
Mar 19, 2026
Merged

[SQL] Improved unused field analysis: proper dataflow analysis, and less conservative handling of nullable tuples#5826
mihaibudiu merged 1 commit intomainfrom
unused

Conversation

@mihaibudiu
Copy link
Contributor

Fixes #5823

Describe Manual Test Plan

I have tested with a new program that I am adding to the qa repository that this analysis is more precise.

Copy link

@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.

LGTM. Tracking used fields (positive) is cleaner than tracking unused (negative), and the FieldSet union correctly handles t.1.is_null() on nullable tuples without touching any inner fields.

FieldUseMap fieldMap1 = fum.getUse();
Assert.assertEquals("Ref([X, _, _, [_, _]])", fieldMap1.toString());

FieldUseMap reduced = fieldMap0.reduce(fieldMap1);

Choose a reason for hiding this comment

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

Non-blocking: the fix for #5823 (t.1.is_null() on a nullable tuple should not mark inner fields as used) would be worth a small unit test here. The regression currently lives only in the external QA repo. Not blocking.

@mihaibudiu mihaibudiu enabled auto-merge March 18, 2026 19:11
@mihaibudiu mihaibudiu added this pull request to the merge queue Mar 18, 2026
@gz gz removed this pull request from the merge queue due to a manual request Mar 19, 2026
@mihaibudiu mihaibudiu added this pull request to the merge queue Mar 19, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 19, 2026
@mihaibudiu
Copy link
Contributor Author

The CI failure is an interesting one: there is a test which checks that when adding a new view, the existing program does not change. Well, in this case a table had unused fields, but the newly added view uses these fields, so the new view DOES modify the existing program. So I will have to come up with a different test...

…ess conservative handling of nullable tuples

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
@mihaibudiu mihaibudiu enabled auto-merge March 19, 2026 07:10
@mihaibudiu mihaibudiu added this pull request to the merge queue Mar 19, 2026
Merged via the queue into main with commit b59158d Mar 19, 2026
1 check passed
@mihaibudiu mihaibudiu deleted the unused branch March 19, 2026 09:08
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.

[SQL] Unused fields analysis is too conservative for nullable tuples

3 participants