From f817412f45abaefd5a57996c2a9dc11b9b34071b Mon Sep 17 00:00:00 2001 From: Kevin Ge Date: Wed, 24 Jul 2024 15:07:20 -0400 Subject: [PATCH] rename (#518) --- ...onvertletTable.java => CoralConvertletTable.java} | 12 +++++++----- .../coral/hive/hive2rel/HiveToRelConverter.java | 2 +- .../coral/trino/trino2rel/TrinoToRelConverter.java | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) rename coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/{HiveConvertletTable.java => CoralConvertletTable.java} (79%) diff --git a/coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/HiveConvertletTable.java b/coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/CoralConvertletTable.java similarity index 79% rename from coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/HiveConvertletTable.java rename to coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/CoralConvertletTable.java index 5b82a8595..774e81d0f 100644 --- a/coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/HiveConvertletTable.java +++ b/coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/CoralConvertletTable.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2023 LinkedIn Corporation. All rights reserved. + * Copyright 2018-2024 LinkedIn Corporation. All rights reserved. * Licensed under the BSD-2 Clause license. * See LICENSE in the project root for license information. */ @@ -20,10 +20,11 @@ /** - * ConvertletTable for Hive Operators + * ConvertletTable for transformations only relevant to Coral's Intermediate Representation, not specific + * any SQL dialect. These transformations keep data parity between the SqlNode and RelNode layer, keeping the IR intact. * @see ReflectiveConvertletTable documentation for method naming and visibility rules */ -public class HiveConvertletTable extends ReflectiveConvertletTable { +public class CoralConvertletTable extends ReflectiveConvertletTable { @SuppressWarnings("unused") public RexNode convertFunctionFieldReferenceOperator(SqlRexContext cx, FunctionFieldReferenceOperator op, @@ -33,14 +34,15 @@ public RexNode convertFunctionFieldReferenceOperator(SqlRexContext cx, FunctionF return cx.getRexBuilder().makeFieldAccess(funcExpr, fieldName, false); } + /** + * Override {@link StandardConvertletTable#convertCast} to avoid cast optimizations that remove the cast. + */ @SuppressWarnings("unused") public RexNode convertCast(SqlRexContext cx, SqlCastFunction cast, SqlCall call) { final SqlNode left = call.operand(0); RexNode leftRex = cx.convertExpression(left); SqlDataTypeSpec dataType = call.operand(1); RelDataType castType = dataType.deriveType(cx.getValidator(), true); - // can not call RexBuilder.makeCast() since that optimizes to remove the cast - // we don't want to remove the cast return cx.getRexBuilder().makeAbstractCast(castType, leftRex); } diff --git a/coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverter.java b/coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverter.java index 1b6b5b31d..f19b61800 100644 --- a/coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverter.java +++ b/coral-hive/src/main/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverter.java @@ -70,7 +70,7 @@ public HiveFunctionResolver getFunctionResolver() { @Override protected SqlRexConvertletTable getConvertletTable() { - return new HiveConvertletTable(); + return new CoralConvertletTable(); } @Override diff --git a/coral-trino/src/main/java/com/linkedin/coral/trino/trino2rel/TrinoToRelConverter.java b/coral-trino/src/main/java/com/linkedin/coral/trino/trino2rel/TrinoToRelConverter.java index 2fc7ea6d6..25c2b6436 100644 --- a/coral-trino/src/main/java/com/linkedin/coral/trino/trino2rel/TrinoToRelConverter.java +++ b/coral-trino/src/main/java/com/linkedin/coral/trino/trino2rel/TrinoToRelConverter.java @@ -1,5 +1,5 @@ /** - * Copyright 2017-2023 LinkedIn Corporation. All rights reserved. + * Copyright 2017-2024 LinkedIn Corporation. All rights reserved. * Licensed under the BSD-2 Clause license. * See LICENSE in the project root for license information. */ @@ -24,8 +24,8 @@ import com.linkedin.coral.common.HiveMetastoreClient; import com.linkedin.coral.common.HiveRelBuilder; import com.linkedin.coral.common.ToRelConverter; +import com.linkedin.coral.hive.hive2rel.CoralConvertletTable; import com.linkedin.coral.hive.hive2rel.DaliOperatorTable; -import com.linkedin.coral.hive.hive2rel.HiveConvertletTable; import com.linkedin.coral.hive.hive2rel.HiveSqlValidator; import com.linkedin.coral.hive.hive2rel.functions.HiveFunctionResolver; import com.linkedin.coral.hive.hive2rel.functions.StaticHiveFunctionRegistry; @@ -63,7 +63,7 @@ public TrinoToRelConverter(Map>> localMetaStore @Override protected SqlRexConvertletTable getConvertletTable() { - return new HiveConvertletTable(); + return new CoralConvertletTable(); } @Override