-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix field resolution for FORK #128193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix field resolution for FORK #128193
Changes from 1 commit
5a64c9b
c4a25d3
af3b955
4d23bc0
34c883e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1796,7 +1796,7 @@ public void testDropWildcardFields_WithLookupJoin() { | |
| ); | ||
| } | ||
|
|
||
| public void testForkFieldsWithKeep() { | ||
| public void testForkFieldsWithKeepAfterFork() { | ||
| assumeTrue("FORK available as snapshot only", EsqlCapabilities.Cap.FORK.isEnabled()); | ||
|
|
||
| assertFieldNames(""" | ||
|
|
@@ -1810,6 +1810,20 @@ public void testForkFieldsWithKeep() { | |
| """, Set.of("a", "a.*", "c", "c.*", "d", "d.*", "e", "e.*", "x", "x.*", "y", "y.*")); | ||
| } | ||
|
|
||
| public void testForkFieldsWithKeepBeforeFork() { | ||
| assumeTrue("FORK available as snapshot only", EsqlCapabilities.Cap.FORK.isEnabled()); | ||
|
|
||
| assertFieldNames(""" | ||
| FROM test | ||
| | KEEP a, b, c, d, x | ||
| | WHERE a > 2000 | ||
| | EVAL b = a + 100 | ||
| | FORK (WHERE c > 1 AND a < 10000 | EVAL d = a + 500) | ||
| (WHERE d > 1000 AND e == "aaa" | EVAL c = a + 200) | ||
| | WHERE x > y | ||
| """, Set.of("a", "a.*", "b", "b.*", "c", "c.*", "d", "d.*", "e", "e.*", "x", "x.*", "y", "y.*")); | ||
| } | ||
|
|
||
| public void testForkFieldsWithNoProjection() { | ||
| assumeTrue("FORK available as snapshot only", EsqlCapabilities.Cap.FORK.isEnabled()); | ||
|
|
||
|
|
@@ -1833,23 +1847,62 @@ public void testForkFieldsWithStatsInOneBranch() { | |
| | FORK (WHERE c > 1 AND a < 10000 | EVAL d = a + 500) | ||
| (STATS x = count(*), y=min(z)) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm - now that I am looking at this more - I think we should return all fields, because one branch is not bounded by any command like
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is one more query where I am confused, in part because of probably not knowing what is the expectation for
This shows these columns:
Should these be a "union" kind of set of columns and
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The FORK output should be a union of the outputs of the fork branches. If we detect that the same field exists in multiple fork branches outputs, but the field has different type, we fail with a validation error. FORK will pad with null columns the output of FORK branches that are missing fields. Will produce: I think fixed the field resolution for this case. |
||
| | WHERE x > y | ||
| """, Set.of("a", "a.*", "c", "c.*", "z", "z.*")); | ||
| """, ALL_FIELDS); | ||
| } | ||
|
|
||
| public void testForkFieldsWithEnrichAndLookupJoins() { | ||
| assumeTrue("FORK available as snapshot only", EsqlCapabilities.Cap.FORK.isEnabled()); | ||
| assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()); | ||
|
|
||
| assertFieldNames( | ||
| """ | ||
| FROM test | ||
| | KEEP a, b, abc, def, z, xyz | ||
| | ENRICH enrich_policy ON abc | ||
| | EVAL b = a + 100 | ||
| | LOOKUP JOIN my_lookup_index ON def | ||
| | FORK (WHERE c > 1 AND a < 10000 | EVAL d = a + 500) | ||
| (STATS x = count(*), y=min(z)) | ||
| | LOOKUP JOIN my_lookup_index ON xyz | ||
| | WHERE x > y OR _fork == "fork1" | ||
| """, | ||
| Set.of( | ||
| "x", | ||
| "y", | ||
| "_fork", | ||
| "a", | ||
| "c", | ||
| "abc", | ||
| "b", | ||
| "def", | ||
| "z", | ||
| "xyz", | ||
| "def.*", | ||
| "_fork.*", | ||
| "y.*", | ||
| "x.*", | ||
| "xyz.*", | ||
| "z.*", | ||
| "abc.*", | ||
| "a.*", | ||
| "c.*", | ||
| "b.*" | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| public void testForkWithStatsInAllBranches() { | ||
| assumeTrue("FORK available as snapshot only", EsqlCapabilities.Cap.FORK.isEnabled()); | ||
|
|
||
| assertFieldNames(""" | ||
| FROM test | ||
| | ENRICH enrich_policy ON abc | ||
| | WHERE a > 2000 | ||
| | EVAL b = a + 100 | ||
| | LOOKUP JOIN my_lookup_index ON def | ||
| | FORK (WHERE c > 1 AND a < 10000 | EVAL d = a + 500) | ||
| | FORK (WHERE c > 1 AND a < 10000 | STATS m = count(*)) | ||
| (EVAL z = a * b | STATS m = max(z)) | ||
| (STATS x = count(*), y=min(z)) | ||
| | LOOKUP JOIN my_lookup_index ON xyz | ||
| | WHERE x > y | ||
| """, Set.of("a", "a.*", "abc", "abc.*", "c", "c.*", "def", "def.*", "x", "x.*", "xyz", "xyz.*", "y", "y.*", "z", "z.*")); | ||
| """, Set.of("a", "a.*", "b", "b.*", "c", "c.*", "z", "z.*")); | ||
| } | ||
|
|
||
| private Set<String> fieldNames(String query, Set<String> enrichPolicyMatchFields) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.