-
Notifications
You must be signed in to change notification settings - Fork 582
Return name of function as output name #17858
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
Conversation
d52afc0
to
a8eee1b
Compare
@matriv @kneth rebased and pushed a fixup to the state that was on Unclear to me is if we should also change the HTTP output (otherwise we have to deal with jdbc 0/1 diffs in the tests that assert column names and use functions) Probably also needs a changes entry. Happy to hand this back to you for finalization. |
server/src/main/java/io/crate/analyze/relations/select/SelectAnalysis.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/crate/analyze/relations/select/SelectAnalyzer.java
Show resolved
Hide resolved
a8eee1b
to
dd66b7b
Compare
I've pushed a wrapup version, but now we have the problem that functions (e.g. aggregates), which don't collapse to a literal but need to be calculated based on the query and cols, are also returned with only the function name (e.g.: This conforms with postgres:
But I'm thinking of 2 variations:
What do you think? |
dd66b7b
to
594cd71
Compare
where as postgres returns:
The same situation holds for other expressions like
and postgres returns the target data type:
What should we do for 2 and 3? For 3? I'm not sure, maybe do what postgres does? |
Another issue with the current approach is that if a
Another option (regarding point 2.) would be to return |
That's okay for now.
Should also be fine.
We can do that if we encounter a concrete compatibility issue. Until then I'd keep this limited to handling the |
server/src/test/java/io/crate/integrationtests/ScalarFunctionITest.java
Outdated
Show resolved
Hide resolved
594cd71
to
4f3b01b
Compare
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.
looks good in general, thx!
assertThat(response.readShort()).isEqualTo((short) 1); | ||
assertThat(PostgresWireProtocol.readCString(response)).isEqualTo("($1 = ANY([1, 2, 3]))"); | ||
assertThat(PostgresWireProtocol.readCString(response)).isEqualTo("($1 IN (1, 2, 3))"); |
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.
How are these changes related?
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.
The IN
is converted to an ANY()
function call here:https://github.com/crate/crate/blob/master/server/src/main/java/io/crate/analyze/relations/select/SelectAnalyzer.java#L62
Previously we'd just the toColumn
when sending the row description here: https://github.com/crate/crate/pull/17858/files#diff-c6c87b42c88c54675f8ca239e2da30e854c4503fd570aa6ac28dd10ea3cbf794L444
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.
Is your link really pointing to the right code?
Anyway, thanks for the explanation.
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.
It doesn't, sorry, but here is on the static master code: https://github.com/crate/crate/blob/master/server/src/main/java/io/crate/protocols/postgres/Messages.java#L444
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.
👍 But lets drop the last commit, my fault, sorry about this!
This pull request has been removed from the queue for the following reason: Pull request #17858 has been dequeued, merge conditions unmatch:
You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. |
To conform with Postgres behaviour return the function name, without including the complete function call with the args, as output column name. Also, previously, for scalars that can be collapsed to a literal return value, we used that value for the output column name instead of the function name. For more details on the behavior change see the breaking change entry in release notes of 6.0.0. Closes: #17393 Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
df78bee
to
ea167cf
Compare
retest this please |
That is an excellent improvement that will boost ecosystem compatibility on a very important detail. Thank you so much! 💯 |
Change `AliasedAnalyzedRelation` to return the outputNames() from its underlining `relation` to keep any aliases set there. On top, when handling such `AlisedAnalyzedRelation`s use the `outputNames()` to retrieve a name if the list is not null and add special handling to `TableFunctionRelation` to return `"unnest"` name if there is no alias defined. Follows: #17858
Change `AliasedAnalyzedRelation` to return the outputNames() from its underlining `relation` to keep any aliases set there. On top, when handling such `AlisedAnalyzedRelation`s use the `outputNames()` to retrieve a name if the list is not null and add special handling to `TableFunctionRelation` to return `"unnest"` name if there is no alias defined. Follows: #17858
Change `AliasedAnalyzedRelation` to use `outputNames() underlining `relation` to keep any aliases set there. Follows: #17858
Change `AliasedAnalyzedRelation` to use `outputNames() underlining `relation` to keep any aliases set there. Follows: #17858
Change `AliasedAnalyzedRelation` to use `outputNames() underlining `relation` to keep any aliases set there. Follows: #17858
To conform with Postgres behaviour return the function name, without
including the complete function call with the args, as output column
name. Also, previously, for scalars that can be collapsed to a literal
return value, we used that value for the output column name instead of
the function name.
For more details on the behavior change see the breaking change entry
in release notes of 6.0.0.
Closes: #17393