-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix FORK with union-types #134033
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 FORK with union-types #134033
Conversation
Hi @craigtaverner, I've created a changelog YAML for you. |
Pinging @elastic/es-analytical-engine (Team:Analytics) |
FROM apps, apps_short | ||
| EVAL x = id::integer | ||
| FORK (WHERE true) (WHERE true) | ||
| DROP _fork |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do something with x
after FORK? for example adding EVAL x = x + 1
or something similar?
just to validate that the value can be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also remove these lines here:
Lines 58 to 61 in c243306
assumeFalse( | |
"Tests using implicit_casting_date_and_date_nanos are not supported for now", | |
testCase.requiredCapabilities.contains(IMPLICIT_CASTING_DATE_AND_DATE_NANOS.capabilityName()) | |
); |
I tested your fix and it seems that it also solves the problem we had with the implicit casting for date and date nanos (which I just found out we took out of snapshot 🎉 ).
At the time we released FORK this was still under development and so it wasn't a priority to fix.
With GenerativeForkRestTest
we test almost all csv specs, by adding at the end "FORK (WHERE true) (WHERE true) | WHERE _fork == "fork1" | DROP _fork". This new query using FORK should render the same results.
So I'd say that if we want to add more tests using FORK, it's less important to follow the same pattern with FORK (WHERE true) (WHERE true)
and it's more important to see if the columns can be used after FORK, if there is any weirdness when the FORK columns have different outputs etc. I am happy to add more tests for it in a separate PR if we simply want to get this merged sooner.
Regarding the tests with @ioanatia did a amazing job by adding If we could have a combination of this test with what |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
8268153 | sample_data_ts_long | 2023-10-23T13:52:55.015Z | 1698069175015 | 1698069175015 | 172.21.3.15 | 172.21.3.15 | ||
8268153 | sample_data_ts_nanos | 2023-10-23T13:52:55.015Z | 2023-10-23T13:52:55.015123456Z | 1698069175015123456 | 172.21.3.15 | 172.21.3.15 | ||
; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to look at inlinestats.csv-spec file and search for https://github.com/elastic/elasticsearch/issues/133973
. There are some ignored tests in there that need a check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We checked these tests cannot be unignored because there seems to be a bug with INLINESTATS
in queries where we use a union type, which seems unrelated to what we've done for FORK
:
FROM employees, employees_incompatible
| KEEP emp_no, hire_date
| EVAL yr = DATE_TRUNC(1 year, hire_date)
| INLINESTATS c = count(emp_no::long) BY yr
| SORT yr DESC
| LIMIT 5
;
To be investigated as a separate piece of work
That's a good idea. |
FORK
createsReferenceAttributes
that represent the combination of the underlyingFieldAttributes
inside each forked sub-plan. However, union-types uses syntheticFieldAttributes
to represent the underlying originalFieldAttributes
converted to a single type. These synthetic attributes are removed in the last phase of semantic analysis usingDROP
commands (Project
), but the code to do that does not handle theReferenceAttributes
provided byFORK
. The simplest approach to fixing this is not restrict the check toFieldAttributes
, but only check forattr.synthetic()
.It would seem the only special case we need to deal with is the
NO_FIELDS
special field which is bothsynthetic
and aReferenceAttribute
, and should not be touched by the union-types cleanup code.Fixes #133973