-
Notifications
You must be signed in to change notification settings - Fork 149
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
Support TYPEOF
function with Calcite
#3446
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Lantao Jin <[email protected]>
Signed-off-by: Lantao Jin <[email protected]>
|
Signed-off-by: Lantao Jin <[email protected]>
@@ -250,6 +254,8 @@ static List<RexNode> translateArgument( | |||
throw new IllegalArgumentException("Log cannot accept argument list: " + argList); | |||
} | |||
return LogArgs; | |||
case "TYPEOF": | |||
return List.of(context.rexBuilder.makeFlag(argList.getFirst().getType().getSqlTypeName())); |
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's confusing to invoke makeFlag
here, why not using makeLiteral
?
@@ -182,6 +183,9 @@ static SqlOperator translate(String op) { | |||
return SqlStdOperatorTable.IS_NOT_NULL; | |||
case "IS NULL": | |||
return SqlStdOperatorTable.IS_NULL; | |||
case "TYPEOF": | |||
return TransferUserDefinedFunction( |
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.
Maybe leave a TODO here to optimize this function to ImplementableFunction
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 about return RexLiteral
directly instead RexCall
for TypeOf function? It also requires simple refactoring of this utils.
context.rexBuilder.makeLiteral(
OpenSearchTypeFactory.convertRelDataTypeToExprType(
argList.getFirst().getType()).legacyTypeName());
Description
Support
TYPEOF
function with limitation:Because the Expression type firstly converted to calcite RelDataType and later converted back to ExprType, external information lost. For example, Text and Keyword are all evaluated to basic RelDataType with String SqlTypeName.
To address it we will support UDT #3322 first.
Related Issues
Resolves #3418
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.