-
Notifications
You must be signed in to change notification settings - Fork 200
Coral-Trino: Migrate UDF operator transformers based on JSON-infra into transformers based on native Java code #355
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
…rs based on native Java code
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.
Thanks @yiqiangin for this PR!
Please add the test part in the PR description.
| * matches the target values in the condition function. | ||
| */ | ||
| public abstract class SourceOperatorMatchSqlCallTransformer extends SqlCallTransformer { | ||
| public static final SqlOperator TIMESTAMP_OPERATOR = |
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 be protected.
| } | ||
| }; | ||
|
|
||
| protected final SqlOperator DATE_OPERATOR = new SqlUserDefinedFunction(new SqlIdentifier("date", SqlParserPos.ZERO), |
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 be static, should be aligned with TIMESTAMP_OPERATOR above.
| // math functions | ||
| new OperatorRenameSqlCallTransformer(SqlStdOperatorTable.RAND, 0, "RANDOM"), | ||
| new JsonTransformSqlCallTransformer(SqlStdOperatorTable.RAND, 1, "RANDOM", "[]", null, null), | ||
| new RandomOperatorWithOneOperandTransformer(), |
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 just use OperatorRenameSqlCallTransformer for this case?
| List<SqlNode> newOperands = new ArrayList<>(); | ||
| newOperands.add(sqlCall.getOperandList().get(1)); | ||
| return createCall(TARGET_OPERATOR, newOperands, SqlParserPos.ZERO); |
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 be simplified to return TARGET_OPERATOR.createCall(sqlCall.getParserPosition(), sqlCall.getOperandList().get(1));, and many similar parts can be simplified in this PR.
|
|
||
| /** | ||
| * This class is a subclass of {@link SourceOperatorMatchSqlCallTransformer} which transforms a Coral SqlCall of "date_add" | ||
| * operator with 2 operands into a Trino SqlCall of an operator named "date_add" |
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.
Please add examples for each transformer in the class javadoc.
| private static final SqlOperator HIVE_PATTERN_TO_TRINO_OPERATOR = | ||
| new SqlUserDefinedFunction(new SqlIdentifier("hive_pattern_to_trino", SqlParserPos.ZERO), | ||
| FunctionReturnTypes.STRING, null, OperandTypes.STRING, null, null); |
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 just use createSqlOperator? Feel that the operand type is not necessary here.
In order to migrate all the transformers in which any of operatorTransformer, operandTransformer and resultTransformer is defined as a JSON string into the transformers which define the transformation rule in native Java code, the following code changes are made in this PR:
Adding some classes to implement the transformers which extends
SourceOperatorMatchSqlCallTransformerand the specific transformation logic is defined as native Java code includingRemoving the code of
JsonSqlCallTransformerTo be noted that this is the replacement of PR #350