-
Notifications
You must be signed in to change notification settings - Fork 200
[Coral-schema] Generalize operand schema inference on ordinal return type UDF calls #548
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
Merged
KevinGe00
merged 4 commits into
linkedin:master
from
KevinGe00:coral-schema-udf-nullability
Feb 10, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /** | ||
| * Copyright 2019-2024 LinkedIn Corporation. All rights reserved. | ||
| * Copyright 2019-2025 LinkedIn Corporation. All rights reserved. | ||
| * Licensed under the BSD-2 Clause license. | ||
| * See LICENSE in the project root for license information. | ||
| */ | ||
|
|
@@ -433,25 +433,20 @@ public RexNode visitLiteral(RexLiteral rexLiteral) { | |
| @Override | ||
| public RexNode visitCall(RexCall rexCall) { | ||
| /** | ||
| * For SqlUserDefinedFunction and SqlOperator RexCall, no need to handle it recursively | ||
| * and only return type of udf or sql operator is relevant | ||
| */ | ||
|
|
||
| /** | ||
| * If the return type of RexCall is based on the ordinal of its input argument | ||
| * and the corresponding input argument refers to a field from the input schema, | ||
| * use the field's schema as is. | ||
| * If the return type of RexCall is based on an ordinal of its input arguments, then leverage SchemaRexShuttle | ||
| * to visit the input argument and use the argument's schema as is to infer the return type of the call | ||
| */ | ||
| if (rexCall.getOperator().getReturnTypeInference() instanceof OrdinalReturnTypeInferenceV2) { | ||
| int index = ((OrdinalReturnTypeInferenceV2) rexCall.getOperator().getReturnTypeInference()).getOrdinal(); | ||
| RexNode operand = rexCall.operands.get(index); | ||
|
|
||
| if (operand instanceof RexInputRef) { | ||
| appendRexInputRefField((RexInputRef) operand); | ||
| return rexCall; | ||
| } | ||
| operand.accept(this); | ||
| return rexCall; | ||
|
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 earlier return here causes the view doc string to no longer be produce. Discussed this with @KevinGe00 offline and it is a reasonable change given it is now more complex to construct the doc string when we recurse into the UDF. |
||
| } | ||
|
|
||
| /** | ||
| * For SqlUserDefinedFunction and SqlOperator RexCall, no need to handle it recursively | ||
| * and just directly use the return type of udf or sql operator as the field's schema | ||
| */ | ||
| RelDataType fieldType = rexCall.getType(); | ||
| boolean isNullable = SchemaUtilities.isFieldNullable(rexCall, inputSchema); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Noticed a change in the capitalization in the field name. This is because the string are now being fetched from the underlying schema instead of being generated programmatically by Coral.