-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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 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 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
44 changes: 0 additions & 44 deletions
44
...al/trino/rel2trino/transformers/GenericCoralRegistryOperatorRenameSqlCallTransformer.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
...ino/src/main/java/com/linkedin/coral/trino/rel2trino/transformers/HiveUDFTransformer.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright 2023-2024 LinkedIn Corporation. All rights reserved. | ||
* Licensed under the BSD-2 Clause license. | ||
* See LICENSE in the project root for license information. | ||
*/ | ||
package com.linkedin.coral.trino.rel2trino.transformers; | ||
|
||
import org.apache.calcite.sql.SqlCall; | ||
import org.apache.calcite.sql.SqlNodeList; | ||
import org.apache.calcite.sql.SqlOperator; | ||
import org.apache.calcite.sql.parser.SqlParserPos; | ||
|
||
import com.linkedin.coral.common.transformers.SqlCallTransformer; | ||
import com.linkedin.coral.hive.hive2rel.functions.VersionedSqlUserDefinedFunction; | ||
|
||
|
||
/** | ||
* This transformer converts the Hive UDF SqlCall name from the UDF class name to the | ||
* corresponding Trino function name. | ||
* i.e. from `com.linkedin.stdudfs.parsing.hive.Ip2Str` to `ip2str`. | ||
*/ | ||
public class HiveUDFTransformer extends SqlCallTransformer { | ||
|
||
@Override | ||
protected boolean condition(SqlCall sqlCall) { | ||
final SqlOperator operator = sqlCall.getOperator(); | ||
final String operatorName = operator.getName(); | ||
return operator instanceof VersionedSqlUserDefinedFunction && operatorName.contains(".") | ||
&& !operatorName.equals("."); | ||
} | ||
|
||
@Override | ||
protected SqlCall transform(SqlCall sqlCall) { | ||
final SqlOperator operator = sqlCall.getOperator(); | ||
final String trinoFunctionName = ((VersionedSqlUserDefinedFunction) operator).getTrinoFunctionName(); | ||
return createSqlOperator(trinoFunctionName, operator.getReturnTypeInference()) | ||
.createCall(new SqlNodeList(sqlCall.getOperandList(), SqlParserPos.ZERO)); | ||
} | ||
} |