You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2020/04/19 19:50:37 UTC
[hive] branch master updated: HIVE-23100: Create RexNode factory
and use it in CalcitePlanner (Jesus Camacho Rodriguez,
reviewed by Stephen Carlin, Vineet Garg, Zoltan Haindrich)
This is an automated email from the ASF dual-hosted git repository.
jcamacho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 91a92e3 HIVE-23100: Create RexNode factory and use it in CalcitePlanner (Jesus Camacho Rodriguez, reviewed by Stephen Carlin, Vineet Garg, Zoltan Haindrich)
91a92e3 is described below
commit 91a92e323a29a49b5ad3b860b9523f347b6b8d4c
Author: Jesus Camacho Rodriguez <jc...@apache.org>
AuthorDate: Sat Apr 4 21:30:16 2020 -0700
HIVE-23100: Create RexNode factory and use it in CalcitePlanner (Jesus Camacho Rodriguez, reviewed by Stephen Carlin, Vineet Garg, Zoltan Haindrich)
Close apache/hive#970
---
.../apache/hadoop/hive/cli/control/CliConfigs.java | 1 +
.../hadoop/hive/ql/exec/FunctionRegistry.java | 7 +
.../org/apache/hadoop/hive/ql/exec/RowSchema.java | 7 +-
.../ql/optimizer/ConstantPropagateProcFactory.java | 1 -
.../hive/ql/optimizer/PrunerOperatorFactory.java | 4 +-
.../hive/ql/optimizer/calcite/HiveCalciteUtil.java | 94 +-
.../ql/optimizer/calcite/HiveRexExecutorImpl.java | 36 +-
.../ql/optimizer/calcite/HiveTypeSystemImpl.java | 1 +
.../calcite/reloperators/HiveRexExprList.java | 74 ++
.../HiveToUnixTimestampSqlOperator.java | 32 +
.../calcite/rules/HiveFilterSortPredicates.java | 9 +-
.../calcite/rules/HiveJoinConstraintsRule.java | 3 +-
.../rules/jdbc/JDBCExpandExpressionsRule.java | 25 +-
.../ql/optimizer/calcite/stats/HiveRelMdSize.java | 16 +-
.../calcite/translator/ExprNodeConverter.java | 18 +-
.../calcite/translator/RexNodeConverter.java | 537 ++++-------
.../calcite/translator/SqlFunctionConverter.java | 15 +-
.../calcite/translator/TypeConverter.java | 33 +-
.../listbucketingpruner/LBProcFactory.java | 2 +-
.../hadoop/hive/ql/parse/CalcitePlanner.java | 963 +++++++++++--------
.../hive/ql/parse/DruidSqlOperatorConverter.java | 7 +-
.../hadoop/hive/ql/parse/SemanticAnalyzer.java | 83 +-
.../hadoop/hive/ql/parse/type/ExprFactory.java | 89 +-
.../ql/parse/type/ExprNodeDescExprFactory.java | 76 +-
.../hive/ql/parse/type/ExprNodeTypeCheck.java | 7 +-
.../hadoop/hive/ql/parse/type/FunctionHelper.java | 119 +++
.../hive/ql/parse/type/HiveFunctionHelper.java | 549 +++++++++++
.../parse/type/JoinCondTypeCheckProcFactory.java | 7 +-
.../hive/ql/parse/type/RexNodeExprFactory.java | 1010 ++++++++++++++++++++
...xprNodeTypeCheck.java => RexNodeTypeCheck.java} | 57 +-
.../hadoop/hive/ql/parse/type/TypeCheckCtx.java | 24 +
.../hive/ql/parse/type/TypeCheckProcFactory.java | 357 ++++---
.../ql/parse/type/TypeCheckProcFactoryUtils.java | 145 ---
.../hadoop/hive/ql/plan/ExprNodeDescUtils.java | 10 +-
.../hive/ql/plan/ExprNodeGenericFuncDesc.java | 24 -
.../ql/parse/type/TestTypeCheckProcFactory.java | 22 +-
.../hive/ql/plan/mapping/TestCounterMapping.java | 6 +-
.../hadoop/hive/ql/testutil/BaseScalarUdfTest.java | 4 +-
.../hive/ql/udf/generic/TestGenericUDFConcat.java | 4 +-
.../hive/ql/udf/generic/TestGenericUDFRound.java | 3 +-
.../clientpositive/partition_coltype_literals.q | 1 +
.../clientpositive/alter_partition_coltype.q.out | 2 +-
.../test/results/clientpositive/avrotblsjoin.q.out | 1 +
.../results/clientpositive/constprog_cast.q.out | 221 -----
.../clientpositive/decimal_precision2.q.out | 2 +-
.../clientpositive/druid/druid_timeseries.q.out | 2 +-
.../druid/druidkafkamini_basic.q.out | 2 +-
.../groupby_multi_single_reducer3.q.out | 16 +-
.../results/clientpositive/in_typecheck_char.q.out | 13 +-
.../clientpositive/in_typecheck_varchar.q.out | 5 +-
.../results/clientpositive/infer_const_type.q.out | 8 +-
.../results/clientpositive/llap/cbo_limit.q.out | 4 +-
.../clientpositive/llap/check_constraint.q.out | 6 +-
.../results/clientpositive/llap/collision.q.out | 2 +-
.../llap/constraints_optimization.q.out | 2 +-
.../llap/identity_project_remove_skip.q.out | 4 +-
.../results/clientpositive/llap/lineage3.q.out | 2 +-
.../llap/materialized_view_create_rewrite_3.q.out | 4 +-
.../llap/materialized_view_create_rewrite_4.q.out | 8 +-
.../llap/materialized_view_create_rewrite_5.q.out | 8 +-
...ialized_view_create_rewrite_rebuild_dummy.q.out | 4 +-
...erialized_view_create_rewrite_time_window.q.out | 4 +-
.../clientpositive/llap/orc_llap_counters.q.out | 18 +-
.../clientpositive/llap/orc_llap_counters1.q.out | 6 +-
.../clientpositive/llap/orc_ppd_basic.q.out | 8 +-
.../llap/orc_ppd_schema_evol_3a.q.out | 6 +-
.../llap/orc_predicate_pushdown.q.out | 30 +-
.../llap/parquet_predicate_pushdown.q.out | 18 +-
.../llap/partition_coltype_literals.q.out | 1 +
.../results/clientpositive/llap/subquery_ALL.q.out | 2 +-
.../results/clientpositive/llap/subquery_ANY.q.out | 2 +-
.../clientpositive/llap/union_assertion_type.q.out | 8 +-
.../clientpositive/llap/vector_between_in.q.out | 28 +-
.../clientpositive/llap/vector_case_when_2.q.out | 16 +-
.../clientpositive/llap/vectorization_10.q.out | 18 +-
.../llap/vectorization_short_regress.q.out | 104 +-
.../clientpositive/parquet_vectorization_10.q.out | 16 +-
ql/src/test/results/clientpositive/pcs.q.out | 12 +-
.../clientpositive/perf/spark/query37.q.out | 4 +-
.../clientpositive/perf/spark/query47.q.out | 2 +-
.../clientpositive/perf/spark/query48.q.out | 4 +-
.../clientpositive/perf/spark/query49.q.out | 12 +-
.../clientpositive/perf/spark/query82.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query10.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query11.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query12.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query13.q.out | 6 +-
.../clientpositive/perf/tez/cbo_query15.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query16.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query17.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query18.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query20.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query21.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query24.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query27.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query31.q.out | 6 +-
.../clientpositive/perf/tez/cbo_query33.q.out | 6 +-
.../clientpositive/perf/tez/cbo_query34.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query36.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query37.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query4.q.out | 6 +-
.../clientpositive/perf/tez/cbo_query40.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query43.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query46.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query47.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query48.q.out | 6 +-
.../clientpositive/perf/tez/cbo_query49.q.out | 12 +-
.../clientpositive/perf/tez/cbo_query53.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query56.q.out | 12 +-
.../clientpositive/perf/tez/cbo_query57.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query58.q.out | 6 +-
.../clientpositive/perf/tez/cbo_query60.q.out | 6 +-
.../clientpositive/perf/tez/cbo_query61.q.out | 8 +-
.../clientpositive/perf/tez/cbo_query63.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query64.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query65.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query66.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query68.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query69.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query71.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query73.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query74.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query75.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query8.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query80.q.out | 6 +-
.../clientpositive/perf/tez/cbo_query82.q.out | 2 +-
.../clientpositive/perf/tez/cbo_query83.q.out | 6 +-
.../clientpositive/perf/tez/cbo_query85.q.out | 8 +-
.../clientpositive/perf/tez/cbo_query89.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query91.q.out | 4 +-
.../clientpositive/perf/tez/cbo_query98.q.out | 2 +-
.../perf/tez/constraints/cbo_query10.q.out | 2 +-
.../perf/tez/constraints/cbo_query11.q.out | 4 +-
.../perf/tez/constraints/cbo_query12.q.out | 2 +-
.../perf/tez/constraints/cbo_query13.q.out | 6 +-
.../perf/tez/constraints/cbo_query15.q.out | 4 +-
.../perf/tez/constraints/cbo_query16.q.out | 2 +-
.../perf/tez/constraints/cbo_query17.q.out | 4 +-
.../perf/tez/constraints/cbo_query18.q.out | 2 +-
.../perf/tez/constraints/cbo_query20.q.out | 2 +-
.../perf/tez/constraints/cbo_query21.q.out | 2 +-
.../perf/tez/constraints/cbo_query24.q.out | 2 +-
.../perf/tez/constraints/cbo_query27.q.out | 2 +-
.../perf/tez/constraints/cbo_query31.q.out | 6 +-
.../perf/tez/constraints/cbo_query33.q.out | 6 +-
.../perf/tez/constraints/cbo_query34.q.out | 4 +-
.../perf/tez/constraints/cbo_query36.q.out | 2 +-
.../perf/tez/constraints/cbo_query37.q.out | 2 +-
.../perf/tez/constraints/cbo_query4.q.out | 6 +-
.../perf/tez/constraints/cbo_query40.q.out | 2 +-
.../perf/tez/constraints/cbo_query43.q.out | 2 +-
.../perf/tez/constraints/cbo_query46.q.out | 2 +-
.../perf/tez/constraints/cbo_query47.q.out | 2 +-
.../perf/tez/constraints/cbo_query48.q.out | 6 +-
.../perf/tez/constraints/cbo_query49.q.out | 12 +-
.../perf/tez/constraints/cbo_query53.q.out | 4 +-
.../perf/tez/constraints/cbo_query56.q.out | 12 +-
.../perf/tez/constraints/cbo_query57.q.out | 2 +-
.../perf/tez/constraints/cbo_query58.q.out | 6 +-
.../perf/tez/constraints/cbo_query60.q.out | 6 +-
.../perf/tez/constraints/cbo_query61.q.out | 8 +-
.../perf/tez/constraints/cbo_query63.q.out | 4 +-
.../perf/tez/constraints/cbo_query64.q.out | 4 +-
.../perf/tez/constraints/cbo_query65.q.out | 2 +-
.../perf/tez/constraints/cbo_query66.q.out | 4 +-
.../perf/tez/constraints/cbo_query68.q.out | 2 +-
.../perf/tez/constraints/cbo_query69.q.out | 2 +-
.../perf/tez/constraints/cbo_query71.q.out | 2 +-
.../perf/tez/constraints/cbo_query73.q.out | 4 +-
.../perf/tez/constraints/cbo_query74.q.out | 4 +-
.../perf/tez/constraints/cbo_query75.q.out | 2 +-
.../perf/tez/constraints/cbo_query8.q.out | 2 +-
.../perf/tez/constraints/cbo_query80.q.out | 6 +-
.../perf/tez/constraints/cbo_query82.q.out | 2 +-
.../perf/tez/constraints/cbo_query83.q.out | 6 +-
.../perf/tez/constraints/cbo_query85.q.out | 8 +-
.../perf/tez/constraints/cbo_query89.q.out | 4 +-
.../perf/tez/constraints/cbo_query91.q.out | 4 +-
.../perf/tez/constraints/cbo_query98.q.out | 2 +-
.../perf/tez/constraints/query37.q.out | 2 +-
.../perf/tez/constraints/query45.q.out | 226 +++--
.../perf/tez/constraints/query48.q.out | 10 +-
.../perf/tez/constraints/query49.q.out | 6 +-
.../perf/tez/constraints/query82.q.out | 2 +-
.../results/clientpositive/perf/tez/query37.q.out | 2 +-
.../results/clientpositive/perf/tez/query48.q.out | 10 +-
.../results/clientpositive/perf/tez/query49.q.out | 6 +-
.../results/clientpositive/perf/tez/query82.q.out | 2 +-
.../results/clientpositive/ppd_join_filter.q.out | 8 +-
ql/src/test/results/clientpositive/semijoin2.q.out | 4 +-
.../results/clientpositive/spark/cbo_limit.q.out | 4 +-
.../spark/groupby_multi_single_reducer3.q.out | 16 +-
.../spark/identity_project_remove_skip.q.out | 4 +-
.../spark/parquet_vectorization_10.q.out | 16 +-
.../clientpositive/spark/ppd_join_filter.q.out | 8 +-
.../clientpositive/spark/vector_between_in.q.out | 14 +-
.../clientpositive/spark/vectorization_10.q.out | 18 +-
.../spark/vectorization_short_regress.q.out | 62 +-
.../clientpositive/stat_estimate_related_col.q.out | 12 +-
ql/src/test/results/clientpositive/structin.q.out | 5 +-
.../temp_table_alter_partition_coltype.q.out | 2 +-
.../test/results/clientpositive/vector_const.q.out | 2 +-
202 files changed, 3823 insertions(+), 2115 deletions(-)
diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java
index 6bd9781..1c0c62f 100644
--- a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java
+++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java
@@ -70,6 +70,7 @@ public class CliConfigs {
excludeQuery("udaf_corr.q"); // disabled in HIVE-20741
excludeQuery("udaf_histogram_numeric.q"); // disabled in HIVE-20715
excludeQuery("vector_groupby_reduce.q"); // Disabled in HIVE-21396
+ excludeQuery("constprog_cast.q"); // TODO: Enable when we move to Calcite 1.23
setResultsDir("ql/src/test/results/clientpositive");
setLogDir("itests/qtest/target/qfile-results/clientpositive");
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
index b0c5862..76e460e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
@@ -1362,6 +1362,13 @@ public final class FunctionRegistry {
}
/**
+ * Returns whether the exprNodeDesc is a node of "negative".
+ */
+ public static boolean isOpNegative(ExprNodeDesc desc) {
+ return GenericUDFOPNegative.class == getGenericUDFClassFromExprDesc(desc);
+ }
+
+ /**
* Returns whether the exprNodeDesc is node of "cast".
*/
public static boolean isOpCast(ExprNodeDesc desc) {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/RowSchema.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/RowSchema.java
index 8e74f8a..8bd098b 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/RowSchema.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/RowSchema.java
@@ -65,16 +65,15 @@ public class RowSchema implements Serializable {
for (ColumnInfo columnInfo: this.signature) {
if (columnInfo.getTabAlias() == null) {
if (tabAlias == null) {
- if(columnInfo.getAlias() != null && alias != null &&
+ if(columnInfo.getAlias() != null &&
columnInfo.getAlias().equals(alias)) {
return columnInfo;
}
}
- }
- else {
+ } else {
if (tabAlias != null) {
if (columnInfo.getTabAlias().equals(tabAlias) &&
- columnInfo.getAlias() != null && alias != null &&
+ columnInfo.getAlias() != null &&
columnInfo.getAlias().equals(alias)) {
return columnInfo;
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java
index 3346f41..2d3daeb 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java
@@ -235,7 +235,6 @@ public final class ConstantPropagateProcFactory {
}
public static ExprNodeDesc foldExpr(ExprNodeGenericFuncDesc funcDesc) {
-
GenericUDF udf = funcDesc.getGenericUDF();
if (!isConstantFoldableUdf(udf, funcDesc.getChildren())) {
return funcDesc;
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/PrunerOperatorFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/PrunerOperatorFactory.java
index e04a2b1..8f5f4e9 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/PrunerOperatorFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/PrunerOperatorFactory.java
@@ -111,7 +111,7 @@ public abstract class PrunerOperatorFactory {
* @throws UDFArgumentException
*/
protected void addPruningPred(Map<TableScanOperator, ExprNodeDesc> opToPrunner,
- TableScanOperator top, ExprNodeDesc new_pruner_pred) throws UDFArgumentException {
+ TableScanOperator top, ExprNodeDesc new_pruner_pred) throws SemanticException {
ExprNodeDesc old_pruner_pred = opToPrunner.get(top);
ExprNodeDesc pruner_pred = null;
if (old_pruner_pred != null) {
@@ -139,7 +139,7 @@ public abstract class PrunerOperatorFactory {
*/
protected void addPruningPred(Map<TableScanOperator, Map<String, ExprNodeDesc>> opToPrunner,
TableScanOperator top, ExprNodeDesc new_pruner_pred, Partition part)
- throws UDFArgumentException {
+ throws SemanticException {
Map<String, ExprNodeDesc> oldPartToPruner = opToPrunner.get(top);
Map<String, ExprNodeDesc> partToPruner = null;
ExprNodeDesc pruner_pred = null;
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
index 4a18cfe..636c3a2 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
@@ -49,6 +49,7 @@ import org.apache.calcite.rex.RexLocalRef;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.rex.RexOver;
import org.apache.calcite.rex.RexPatternFieldRef;
+import org.apache.calcite.rex.RexShuttle;
import org.apache.calcite.rex.RexTableInputRef;
import org.apache.calcite.rex.RexRangeRef;
import org.apache.calcite.rex.RexSubQuery;
@@ -59,6 +60,8 @@ import org.apache.calcite.sql.SqlAggFunction;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.SqlOperator;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.type.SqlTypeFamily;
+import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.validate.SqlValidatorUtil;
import org.apache.calcite.util.ImmutableBitSet;
import org.apache.calcite.util.Pair;
@@ -80,8 +83,6 @@ import org.apache.hadoop.hive.ql.parse.ParseUtils;
import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
@@ -98,9 +99,6 @@ import com.google.common.collect.Sets;
public class HiveCalciteUtil {
- private static final Logger LOG = LoggerFactory.getLogger(HiveCalciteUtil.class);
-
-
/**
* Get list of virtual columns from the given list of projections.
* <p>
@@ -1062,6 +1060,25 @@ public class HiveCalciteUtil {
return HiveProject.create(input, copyInputRefs, null);
}
+ public static boolean isLiteral(RexNode expr) {
+ if (expr instanceof RexCall) {
+ RexCall call = (RexCall) expr;
+ if (call.getOperator() == SqlStdOperatorTable.ROW ||
+ call.getOperator() == SqlStdOperatorTable.ARRAY_VALUE_CONSTRUCTOR ||
+ call.getOperator() == SqlStdOperatorTable.MAP_VALUE_CONSTRUCTOR) {
+ // We check all operands
+ for (RexNode node : call.getOperands()) {
+ if (!isLiteral(node)) {
+ return false;
+ }
+ }
+ // All literals
+ return true;
+ }
+ }
+ return expr.isA(SqlKind.LITERAL);
+ }
+
/**
* Walks over an expression and determines whether it is constant.
*/
@@ -1157,4 +1174,71 @@ public class HiveCalciteUtil {
return inputRefSet;
}
}
+
+ /** Fixes up the type of all {@link RexInputRef}s in an
+ * expression to match differences in nullability.
+ *
+ * This can be useful in case a field is inferred to be not nullable,
+ * e.g., a not null literal, and the reference to the row type needs
+ * to be changed to adjust the nullability flag.
+ *
+ * In case of references created on top of a Calcite schema generated
+ * directly from a Hive schema, this is especially useful since Hive
+ * does not have a notion of nullability so all fields in the schema
+ * will be inferred to nullable. However, Calcite makes this distinction.
+ *
+ * <p>Throws if there any greater inconsistencies of type. */
+ public static List<RexNode> fixNullability(final RexBuilder rexBuilder,
+ List<RexNode> nodes, final List<RelDataType> fieldTypes) {
+ return new FixNullabilityShuttle(rexBuilder, fieldTypes).apply(nodes);
+ }
+
+ /** Fixes up the type of all {@link RexInputRef}s in an
+ * expression to match differences in nullability.
+ *
+ * <p>Throws if there any greater inconsistencies of type. */
+ public static RexNode fixNullability(final RexBuilder rexBuilder,
+ RexNode node, final List<RelDataType> fieldTypes) {
+ return new FixNullabilityShuttle(rexBuilder, fieldTypes).apply(node);
+ }
+
+ /** Shuttle that fixes up an expression to match changes in nullability of
+ * input fields. */
+ public static class FixNullabilityShuttle extends RexShuttle {
+ private final List<RelDataType> typeList;
+ private final RexBuilder rexBuilder;
+
+ public FixNullabilityShuttle(RexBuilder rexBuilder,
+ List<RelDataType> typeList) {
+ this.typeList = typeList;
+ this.rexBuilder = rexBuilder;
+ }
+
+ @Override public RexNode visitInputRef(RexInputRef ref) {
+ final RelDataType rightType = typeList.get(ref.getIndex());
+ final RelDataType refType = ref.getType();
+ if (refType == rightType) {
+ return ref;
+ }
+ final RelDataType refType2 =
+ rexBuilder.getTypeFactory().createTypeWithNullability(refType,
+ rightType.isNullable());
+ // This is a validation check which can become quite handy debugging type
+ // issues. Basically, we need both types to be equal, only difference should
+ // be nullability.
+ // However, we make an exception for Hive wrt CHAR type because Hive encodes
+ // the STRING type for literals within CHAR value (see {@link HiveNlsString})
+ // while Calcite always considers these literals to be a CHAR, which means
+ // that the reference may be created as a STRING or VARCHAR from AST node
+ // at parsing time but the actual type referenced is a CHAR.
+ if (refType2 == rightType) {
+ return new RexInputRef(ref.getIndex(), refType2);
+ } else if (refType2.getFamily() == SqlTypeFamily.CHARACTER &&
+ rightType.getSqlTypeName() == SqlTypeName.CHAR && !rightType.isNullable()) {
+ return new RexInputRef(ref.getIndex(), rightType);
+ }
+ throw new AssertionError("mismatched type " + ref + " " + rightType);
+ }
+ }
+
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRexExecutorImpl.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRexExecutorImpl.java
index 1dede0f..08b4e8d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRexExecutorImpl.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRexExecutorImpl.java
@@ -15,44 +15,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.hadoop.hive.ql.optimizer.calcite;
import java.util.HashSet;
import java.util.List;
-import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexExecutorImpl;
import org.apache.calcite.rex.RexNode;
import org.apache.hadoop.hive.ql.optimizer.ConstantPropagateProcFactory;
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.ExprNodeConverter;
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.RexNodeConverter;
+import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+/**
+ * Executor for {@link RexNode} based on Hive semantics.
+ */
public class HiveRexExecutorImpl extends RexExecutorImpl {
private static final Logger LOG = LoggerFactory.getLogger(HiveRexExecutorImpl.class);
- private final RelOptCluster cluster;
- public HiveRexExecutorImpl(RelOptCluster cluster) {
+ public HiveRexExecutorImpl() {
super(null);
- this.cluster = cluster;
}
@Override
public void reduce(RexBuilder rexBuilder, List<RexNode> constExps, List<RexNode> reducedValues) {
- RexNodeConverter rexNodeConverter = new RexNodeConverter(cluster);
+ RexNodeConverter rexNodeConverter = new RexNodeConverter(rexBuilder, rexBuilder.getTypeFactory());
for (RexNode rexNode : constExps) {
// initialize the converter
ExprNodeConverter converter = new ExprNodeConverter("", null, null, null,
- new HashSet<Integer>(), cluster.getTypeFactory());
+ new HashSet<>(), rexBuilder.getTypeFactory());
// convert RexNode to ExprNodeGenericFuncDesc
ExprNodeDesc expr = rexNode.accept(converter);
if (expr instanceof ExprNodeGenericFuncDesc) {
@@ -60,20 +59,27 @@ public class HiveRexExecutorImpl extends RexExecutorImpl {
ExprNodeDesc constant = ConstantPropagateProcFactory
.foldExpr((ExprNodeGenericFuncDesc) expr);
if (constant != null) {
- try {
- // convert constant back to RexNode
- reducedValues.add(rexNodeConverter.convert(constant));
- } catch (Exception e) {
- LOG.warn(e.getMessage());
- reducedValues.add(rexNode);
- }
+ addExpressionToList(constant, rexNode, rexNodeConverter, reducedValues);
} else {
reducedValues.add(rexNode);
}
+ } else if (expr instanceof ExprNodeConstantDesc) {
+ addExpressionToList(expr, rexNode, rexNodeConverter, reducedValues);
} else {
reducedValues.add(rexNode);
}
}
}
+ private void addExpressionToList(ExprNodeDesc reducedExpr, RexNode originalExpr,
+ RexNodeConverter rexNodeConverter, List<RexNode> reducedValues) {
+ try {
+ // convert constant back to RexNode
+ reducedValues.add(rexNodeConverter.convert(reducedExpr));
+ } catch (Exception e) {
+ LOG.warn(e.getMessage());
+ reducedValues.add(originalExpr);
+ }
+ }
+
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveTypeSystemImpl.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveTypeSystemImpl.java
index 4a5c9cc..5e301fd 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveTypeSystemImpl.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveTypeSystemImpl.java
@@ -78,6 +78,7 @@ public class HiveTypeSystemImpl extends RelDataTypeSystemImpl {
// Binary doesn't need any sizes; Decimal has the default of 10.
case BINARY:
case VARBINARY:
+ return RelDataType.PRECISION_NOT_SPECIFIED;
case TIME:
case TIMESTAMP:
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveRexExprList.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveRexExprList.java
new file mode 100644
index 0000000..707bcca
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveRexExprList.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.optimizer.calcite.reloperators;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rex.RexBiVisitor;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexVisitor;
+import org.apache.hadoop.hive.ql.plan.ExprNodeColumnListDesc;
+
+/**
+ * This class represents the equivalent to {@link ExprNodeColumnListDesc}
+ * in a Calcite expression. It is not supposed to be used through planning
+ * and should be immediately expanded after it has been generated by
+ * the parser.
+ */
+public class HiveRexExprList extends RexNode {
+
+ final List<RexNode> expressions = new ArrayList<>();
+
+ public void addExpression(RexNode expression) {
+ expressions.add(expression);
+ }
+
+ public List<RexNode> getExpressions() {
+ return expressions;
+ }
+
+ @Override
+ public RelDataType getType() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <R> R accept(RexVisitor<R> visitor) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <R, P> R accept(RexBiVisitor<R, P> visitor, P arg) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof HiveRexExprList) {
+ return this.expressions.equals(((HiveRexExprList) obj).expressions);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return expressions.hashCode();
+ }
+
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveToUnixTimestampSqlOperator.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveToUnixTimestampSqlOperator.java
new file mode 100644
index 0000000..b5ab01c
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveToUnixTimestampSqlOperator.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.optimizer.calcite.reloperators;
+
+import org.apache.calcite.sql.fun.SqlAbstractTimeFunction;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Sql UNIX_TIMESTAMP calcite operator.
+ */
+public class HiveToUnixTimestampSqlOperator extends SqlAbstractTimeFunction {
+ public static final HiveToUnixTimestampSqlOperator INSTANCE = new HiveToUnixTimestampSqlOperator();
+ protected HiveToUnixTimestampSqlOperator() {
+ super("UNIX_TIMESTAMP", SqlTypeName.BIGINT);
+ }
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveFilterSortPredicates.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveFilterSortPredicates.java
index 3b35570..780481f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveFilterSortPredicates.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveFilterSortPredicates.java
@@ -33,6 +33,7 @@ import org.apache.calcite.rex.RexLiteral;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.rex.RexShuttle;
import org.apache.calcite.rex.RexVisitorImpl;
+import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.util.Pair;
import org.apache.hadoop.hive.ql.optimizer.calcite.stats.FilterSelectivityEstimator;
import org.apache.hadoop.hive.ql.optimizer.calcite.stats.HiveRelMdSize;
@@ -223,7 +224,13 @@ public class HiveFilterSortPredicates extends RelOptRule {
return null;
}
cost += operandCost;
- Double size = HiveRelMdSize.averageTypeSize(operand.getType());
+ Double size;
+ if (operand.isA(SqlKind.LITERAL)) {
+ size = HiveRelMdSize.INSTANCE.typeValueSize(operand.getType(),
+ ((RexLiteral) operand).getValueAs(Comparable.class));
+ } else {
+ size = HiveRelMdSize.INSTANCE.averageTypeValueSize(operand.getType());
+ }
if (size == null) {
return null;
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinConstraintsRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinConstraintsRule.java
index 05c7368..8acecfc 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinConstraintsRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinConstraintsRule.java
@@ -39,6 +39,7 @@ import org.apache.calcite.util.ImmutableBitSet;
import org.apache.calcite.util.mapping.Mapping;
import org.apache.calcite.util.mapping.MappingType;
import org.apache.calcite.util.mapping.Mappings;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil;
import org.apache.hadoop.hive.ql.optimizer.calcite.HiveRelFactories;
import org.apache.hadoop.hive.ql.optimizer.calcite.HiveRelOptUtil;
import org.apache.hadoop.hive.ql.optimizer.calcite.HiveRelOptUtil.RewritablePKFKJoinInfo;
@@ -222,7 +223,7 @@ public class HiveJoinConstraintsRule extends RelOptRule {
.collect(Collectors.toList());
}
// Fix nullability in references to the input node
- topProjExprs = RexUtil.fixUp(rexBuilder, topProjExprs, RelOptUtil.getFieldTypeList(fkInput.getRowType()));
+ topProjExprs = HiveCalciteUtil.fixNullability(rexBuilder, topProjExprs, RelOptUtil.getFieldTypeList(fkInput.getRowType()));
// Trigger transformation
if (nullableNodes.isEmpty()) {
call.transformTo(call.builder()
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/jdbc/JDBCExpandExpressionsRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/jdbc/JDBCExpandExpressionsRule.java
index 1c8a100..c903bba 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/jdbc/JDBCExpandExpressionsRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/jdbc/JDBCExpandExpressionsRule.java
@@ -35,6 +35,8 @@ import org.apache.calcite.rex.RexShuttle;
import org.apache.calcite.rex.RexUtil;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil;
+import org.apache.hadoop.hive.ql.optimizer.calcite.translator.RexNodeConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -196,24 +198,11 @@ public abstract class JDBCExpandExpressionsRule extends RelOptRule {
return expression;
}
- final List<RexNode> disjuncts = new ArrayList<>(expression.getOperands().size() - 2);
- final RexCall columnExpressions = (RexCall) expression.getOperands().get(0);
- for (int i = 1; i < expression.getOperands().size(); i++) {
- List<RexNode> conjuncts = new ArrayList<>(columnExpressions.getOperands().size() - 1);
- RexCall valueExpressions = (RexCall) expression.getOperands().get(i);
- for (int j = 0; j < columnExpressions.getOperands().size(); j++) {
- conjuncts.add(rexBuilder.makeCall(
- SqlStdOperatorTable.EQUALS,
- columnExpressions.getOperands().get(j),
- valueExpressions.getOperands().get(j)));
- }
- if (conjuncts.size() > 1) {
- disjuncts.add(rexBuilder.makeCall(
- SqlStdOperatorTable.AND,
- conjuncts));
- } else {
- disjuncts.add(conjuncts.get(0));
- }
+ final List<RexNode> disjuncts = RexNodeConverter.transformInToOrOperands(
+ expression.getOperands(), rexBuilder);
+ if (disjuncts == null) {
+ // We could not execute transformation, return expression
+ return expression;
}
if (disjuncts.size() > 1) {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/HiveRelMdSize.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/HiveRelMdSize.java
index eebeb4c..d5a4e36 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/HiveRelMdSize.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/HiveRelMdSize.java
@@ -38,7 +38,7 @@ import com.google.common.collect.ImmutableList;
public class HiveRelMdSize extends RelMdSize {
- private static final HiveRelMdSize INSTANCE = new HiveRelMdSize();
+ public static final HiveRelMdSize INSTANCE = new HiveRelMdSize();
public static final RelMetadataProvider SOURCE =
ReflectiveRelMetadataProvider.reflectiveSource(INSTANCE,
@@ -129,10 +129,6 @@ public class HiveRelMdSize extends RelMdSize {
// supports all types
@Override
public Double averageTypeValueSize(RelDataType type) {
- return averageTypeSize(type);
- }
-
- public static Double averageTypeSize(RelDataType type) {
switch (type.getSqlTypeName()) {
case BOOLEAN:
case TINYINT:
@@ -145,10 +141,14 @@ public class HiveRelMdSize extends RelMdSize {
case DECIMAL:
case DATE:
case TIME:
+ case INTERVAL_YEAR:
+ case INTERVAL_YEAR_MONTH:
+ case INTERVAL_MONTH:
return 4d;
case BIGINT:
case DOUBLE:
case TIMESTAMP:
+ case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
case INTERVAL_DAY:
case INTERVAL_DAY_HOUR:
case INTERVAL_DAY_MINUTE:
@@ -158,10 +158,7 @@ public class HiveRelMdSize extends RelMdSize {
case INTERVAL_HOUR_SECOND:
case INTERVAL_MINUTE:
case INTERVAL_MINUTE_SECOND:
- case INTERVAL_MONTH:
case INTERVAL_SECOND:
- case INTERVAL_YEAR:
- case INTERVAL_YEAR_MONTH:
return 8d;
case BINARY:
return (double) type.getPrecision();
@@ -175,12 +172,11 @@ public class HiveRelMdSize extends RelMdSize {
case ROW:
Double average = 0.0;
for (RelDataTypeField field : type.getFieldList()) {
- average += averageTypeSize(field.getType());
+ average += averageTypeValueSize(field.getType());
}
return average;
default:
return null;
}
}
-
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
index cf104af..658d2cc 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
@@ -23,6 +23,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import org.apache.calcite.avatica.util.ByteString;
import org.apache.calcite.rel.RelFieldCollation;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
@@ -58,7 +59,6 @@ import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.optimizer.ConstantPropagateProcFactory;
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter.RexVisitor;
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter.Schema;
-import org.apache.hadoop.hive.ql.optimizer.calcite.translator.RexNodeConverter.HiveNlsString;
import org.apache.hadoop.hive.ql.parse.ASTNode;
import org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.NullOrder;
import org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.Order;
@@ -73,6 +73,7 @@ import org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowFrameSpec;
import org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowFunctionSpec;
import org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowSpec;
import org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowType;
+import org.apache.hadoop.hive.ql.parse.type.RexNodeExprFactory.HiveNlsString;
import org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
@@ -227,6 +228,10 @@ public class ExprNodeConverter extends RexVisitorImpl<ExprNodeDesc> {
@Override
public ExprNodeDesc visitLiteral(RexLiteral literal) {
+ return toExprNodeConstantDesc(literal);
+ }
+
+ public static ExprNodeConstantDesc toExprNodeConstantDesc(RexLiteral literal) {
RelDataType lType = literal.getType();
if (RexLiteral.value(literal) == null) {
@@ -259,12 +264,12 @@ public class ExprNodeConverter extends RexVisitorImpl<ExprNodeDesc> {
throw new RuntimeException(e);
}
return new ExprNodeConstantDesc(
- TypeInfoFactory.getTimestampTZTypeInfo(conf.getLocalTimeZone()), null);
+ TypeInfoFactory.getTimestampTZTypeInfo(conf.getLocalTimeZone()), null);
case BINARY:
return new ExprNodeConstantDesc(TypeInfoFactory.binaryTypeInfo, null);
case DECIMAL:
return new ExprNodeConstantDesc(
- TypeInfoFactory.getDecimalTypeInfo(lType.getPrecision(), lType.getScale()), null);
+ TypeInfoFactory.getDecimalTypeInfo(lType.getPrecision(), lType.getScale()), null);
case VARCHAR:
case CHAR:
return new ExprNodeConstantDesc(TypeInfoFactory.stringTypeInfo, null);
@@ -331,7 +336,8 @@ public class ExprNodeConverter extends RexVisitorImpl<ExprNodeDesc> {
return new ExprNodeConstantDesc(TypeInfoFactory.getTimestampTZTypeInfo(conf.getLocalTimeZone()),
TimestampTZUtil.parse(literal.getValueAs(TimestampString.class).toString() + " UTC"));
case BINARY:
- return new ExprNodeConstantDesc(TypeInfoFactory.binaryTypeInfo, literal.getValue3());
+ return new ExprNodeConstantDesc(TypeInfoFactory.binaryTypeInfo,
+ literal.getValueAs(ByteString.class).getBytes());
case DECIMAL:
return new ExprNodeConstantDesc(TypeInfoFactory.getDecimalTypeInfo(lType.getPrecision(),
lType.getScale()), HiveDecimal.create((BigDecimal)literal.getValue3()));
@@ -361,7 +367,7 @@ public class ExprNodeConverter extends RexVisitorImpl<ExprNodeDesc> {
case INTERVAL_YEAR_MONTH: {
BigDecimal monthsBd = (BigDecimal) literal.getValue();
return new ExprNodeConstantDesc(TypeInfoFactory.intervalYearMonthTypeInfo,
- new HiveIntervalYearMonth(monthsBd.intValue()));
+ new HiveIntervalYearMonth(monthsBd.intValue()));
}
case INTERVAL_DAY:
case INTERVAL_DAY_HOUR:
@@ -377,7 +383,7 @@ public class ExprNodeConverter extends RexVisitorImpl<ExprNodeDesc> {
// Calcite literal is in millis, we need to convert to seconds
BigDecimal secsBd = millisBd.divide(BigDecimal.valueOf(1000));
return new ExprNodeConstantDesc(TypeInfoFactory.intervalDayTimeTypeInfo,
- new HiveIntervalDayTime(secsBd));
+ new HiveIntervalDayTime(secsBd));
}
default:
return new ExprNodeConstantDesc(TypeInfoFactory.voidTypeInfo, literal.getValue3());
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java
index ba6eefb..bd1c84b 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java
@@ -19,36 +19,27 @@ package org.apache.hadoop.hive.ql.optimizer.calcite.translator;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import org.apache.calcite.avatica.util.TimeUnit;
import org.apache.calcite.avatica.util.TimeUnitRange;
-import org.apache.calcite.plan.RelOptCluster;
-import org.apache.calcite.rel.RelNode;
-import org.apache.calcite.rel.core.CorrelationId;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexCall;
import org.apache.calcite.rex.RexNode;
-import org.apache.calcite.rex.RexSubQuery;
import org.apache.calcite.rex.RexUtil;
import org.apache.calcite.sql.SqlBinaryOperator;
-import org.apache.calcite.sql.SqlCollation;
import org.apache.calcite.sql.SqlIntervalQualifier;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.SqlOperator;
import org.apache.calcite.sql.fun.SqlCastFunction;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
-import org.apache.calcite.sql.fun.SqlQuantifyOperator;
import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.type.SqlTypeUtil;
-import org.apache.calcite.util.ConversionUtil;
import org.apache.calcite.util.DateString;
-import org.apache.calcite.util.NlsString;
import org.apache.calcite.util.TimestampString;
import org.apache.hadoop.hive.common.type.Date;
import org.apache.hadoop.hive.common.type.Decimal128;
@@ -59,28 +50,22 @@ import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
import org.apache.hadoop.hive.common.type.HiveVarchar;
import org.apache.hadoop.hive.common.type.Timestamp;
import org.apache.hadoop.hive.common.type.TimestampTZ;
-import org.apache.hadoop.hive.ql.ErrorMsg;
import org.apache.hadoop.hive.ql.exec.FunctionRegistry;
import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException;
import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException.UnsupportedFeature;
-import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveExtractDate;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFloorDate;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveToDateSqlOperator;
-import org.apache.hadoop.hive.ql.optimizer.calcite.translator.RexNodeConverter.HiveNlsString.Interpretation;
-import org.apache.hadoop.hive.ql.parse.ASTNode;
-import org.apache.hadoop.hive.ql.parse.HiveParser;
-import org.apache.hadoop.hive.ql.parse.RowResolver;
import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.apache.hadoop.hive.ql.parse.type.ExprNodeTypeCheck;
-import org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc;
+import org.apache.hadoop.hive.ql.parse.type.RexNodeExprFactory;
+import org.apache.hadoop.hive.ql.parse.type.RexNodeExprFactory.HiveNlsString.Interpretation;
import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeDescUtils;
import org.apache.hadoop.hive.ql.plan.ExprNodeFieldDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc;
-import org.apache.hadoop.hive.ql.plan.ExprNodeSubQueryDesc;
-import org.apache.hadoop.hive.ql.plan.SubqueryType;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBaseBinary;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBaseCompare;
@@ -110,77 +95,27 @@ import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
import java.math.BigDecimal;
-import java.math.BigInteger;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
+/**
+ * Class that contains logic to translate Hive expressions ({@link ExprNodeDesc})
+ * into Calcite expressions ({@link RexNode}).
+ */
public class RexNodeConverter {
- private static class InputCtx {
- private final RelDataType calciteInpDataType;
- private final ImmutableMap<String, Integer> hiveNameToPosMap;
- private final RowResolver hiveRR;
- private final int offsetInCalciteSchema;
-
- private InputCtx(RelDataType calciteInpDataType, ImmutableMap<String, Integer> hiveNameToPosMap,
- RowResolver hiveRR, int offsetInCalciteSchema) {
- this.calciteInpDataType = calciteInpDataType;
- this.hiveNameToPosMap = hiveNameToPosMap;
- this.hiveRR = hiveRR;
- this.offsetInCalciteSchema = offsetInCalciteSchema;
- }
- };
-
- private final RelOptCluster cluster;
- private final ImmutableList<InputCtx> inputCtxs;
- private final boolean flattenExpr;
-
- //outerRR belongs to outer query and is required to resolve correlated references
- private final RowResolver outerRR;
- private final ImmutableMap<String, Integer> outerNameToPosMap;
- private int correlatedId;
- private final int maxNodesForInToOrTransformation;
-
- //Constructor used by HiveRexExecutorImpl
- public RexNodeConverter(RelOptCluster cluster) {
- this(cluster, new ArrayList<InputCtx>(), false);
- }
-
- //subqueries will need outer query's row resolver
- public RexNodeConverter(RelOptCluster cluster, RelDataType inpDataType,
- ImmutableMap<String, Integer> outerNameToPosMap,
- ImmutableMap<String, Integer> nameToPosMap, RowResolver hiveRR, RowResolver outerRR,
- int maxNodesForInToOrTransformation, int offset, boolean flattenExpr, int correlatedId) {
- this.cluster = cluster;
- this.inputCtxs = ImmutableList.of(new InputCtx(inpDataType, nameToPosMap, hiveRR, offset));
- this.flattenExpr = flattenExpr;
- this.outerRR = outerRR;
- this.outerNameToPosMap = outerNameToPosMap;
- this.correlatedId = correlatedId;
- this.maxNodesForInToOrTransformation = maxNodesForInToOrTransformation;
- }
+ private final RexBuilder rexBuilder;
+ private final RelDataTypeFactory typeFactory;
- public RexNodeConverter(RelOptCluster cluster, RelDataType inpDataType,
- ImmutableMap<String, Integer> nameToPosMap, int offset, boolean flattenExpr) {
- this.cluster = cluster;
- this.inputCtxs = ImmutableList.of(new InputCtx(inpDataType, nameToPosMap, null, offset));
- this.flattenExpr = flattenExpr;
- this.outerRR = null;
- this.outerNameToPosMap = null;
- this.maxNodesForInToOrTransformation = 0;
- }
- public RexNodeConverter(RelOptCluster cluster, List<InputCtx> inpCtxLst, boolean flattenExpr) {
- this.cluster = cluster;
- this.inputCtxs = ImmutableList.<InputCtx> builder().addAll(inpCtxLst).build();
- this.flattenExpr = flattenExpr;
- this.outerRR = null;
- this.outerNameToPosMap = null;
- this.maxNodesForInToOrTransformation = 0;
+ /**
+ * Constructor used by HiveRexExecutorImpl.
+ */
+ public RexNodeConverter(RexBuilder rexBuilder, RelDataTypeFactory typeFactory) {
+ this.rexBuilder = rexBuilder;
+ this.typeFactory = typeFactory;
}
public RexNode convert(ExprNodeDesc expr) throws SemanticException {
@@ -188,128 +123,19 @@ public class RexNodeConverter {
return convert((ExprNodeGenericFuncDesc) expr);
} else if (expr instanceof ExprNodeConstantDesc) {
return convert((ExprNodeConstantDesc) expr);
- } else if (expr instanceof ExprNodeColumnDesc) {
- return convert((ExprNodeColumnDesc) expr);
} else if (expr instanceof ExprNodeFieldDesc) {
return convert((ExprNodeFieldDesc) expr);
- } else if(expr instanceof ExprNodeSubQueryDesc) {
- return convert((ExprNodeSubQueryDesc) expr);
} else {
throw new RuntimeException("Unsupported Expression");
}
- // TODO: handle ExprNodeColumnListDesc
- }
-
- private RexNode getSomeSubquery(final RelNode subqueryRel, final RexNode lhs,
- final SqlQuantifyOperator quantifyOperator) {
- if(quantifyOperator == SqlStdOperatorTable.SOME_EQ) {
- return RexSubQuery.in(subqueryRel, ImmutableList.<RexNode>of(lhs));
- } else if (quantifyOperator == SqlStdOperatorTable.SOME_NE) {
- RexSubQuery subQuery = RexSubQuery.in(subqueryRel, ImmutableList.<RexNode>of(lhs));
- return cluster.getRexBuilder().makeCall(SqlStdOperatorTable.NOT, subQuery);
- } else {
- return RexSubQuery.some(subqueryRel, ImmutableList.of(lhs), quantifyOperator);
- }
- }
-
- private void throwInvalidSubqueryError(final ASTNode comparisonOp) throws SemanticException {
- throw new CalciteSubquerySemanticException(ErrorMsg.INVALID_SUBQUERY_EXPRESSION.getMsg(
- "Invalid operator:" + comparisonOp.toString()));
- }
-
- // <>ANY and =ALL is not supported
- private RexNode convertSubquerySomeAll(final ExprNodeSubQueryDesc subQueryDesc)
- throws SemanticException {
- assert(subQueryDesc.getType() == SubqueryType.SOME
- || subQueryDesc.getType() == SubqueryType.ALL);
-
- RexNode rexNodeLhs = convert(subQueryDesc.getSubQueryLhs());
- ASTNode comparisonOp = subQueryDesc.getComparisonOp();
- SqlQuantifyOperator quantifyOperator = null;
-
- switch (comparisonOp.getType()) {
- case HiveParser.EQUAL:
- if(subQueryDesc.getType() == SubqueryType.ALL) {
- throwInvalidSubqueryError(comparisonOp);
- }
- quantifyOperator = SqlStdOperatorTable.SOME_EQ;
- break;
- case HiveParser.LESSTHAN:
- quantifyOperator = SqlStdOperatorTable.SOME_LT;
- break;
- case HiveParser.LESSTHANOREQUALTO:
- quantifyOperator = SqlStdOperatorTable.SOME_LE;
- break;
- case HiveParser.GREATERTHAN:
- quantifyOperator = SqlStdOperatorTable.SOME_GT;
- break;
- case HiveParser.GREATERTHANOREQUALTO:
- quantifyOperator = SqlStdOperatorTable.SOME_GE;
- break;
- case HiveParser.NOTEQUAL:
- if(subQueryDesc.getType() == SubqueryType.SOME) {
- throwInvalidSubqueryError(comparisonOp);
- }
- quantifyOperator = SqlStdOperatorTable.SOME_NE;
- break;
- default:
- throw new CalciteSubquerySemanticException(ErrorMsg.INVALID_SUBQUERY_EXPRESSION.getMsg(
- "Invalid operator:" + comparisonOp.toString()));
- }
-
- if(subQueryDesc.getType() == SubqueryType.ALL) {
- quantifyOperator = SqlStdOperatorTable.some(quantifyOperator.comparisonKind.negateNullSafe());
- }
- RexNode someQuery = getSomeSubquery(subQueryDesc.getRexSubQuery(), rexNodeLhs,
- quantifyOperator);
- if(subQueryDesc.getType() == SubqueryType.ALL) {
- return cluster.getRexBuilder().makeCall(SqlStdOperatorTable.NOT, someQuery);
- }
- return someQuery;
- }
-
- private RexNode convert(final ExprNodeSubQueryDesc subQueryDesc) throws SemanticException {
- if(subQueryDesc.getType() == SubqueryType.IN) {
- /*
- * Check.5.h :: For In and Not In the SubQuery must implicitly or
- * explicitly only contain one select item.
- */
- if(subQueryDesc.getRexSubQuery().getRowType().getFieldCount() > 1) {
- throw new CalciteSubquerySemanticException(ErrorMsg.INVALID_SUBQUERY_EXPRESSION.getMsg(
- "SubQuery can contain only 1 item in Select List."));
- }
- //create RexNode for LHS
- RexNode rexNodeLhs = convert(subQueryDesc.getSubQueryLhs());
-
- //create RexSubQuery node
- RexNode rexSubQuery = RexSubQuery.in(subQueryDesc.getRexSubQuery(),
- ImmutableList.<RexNode>of(rexNodeLhs));
- return rexSubQuery;
- } else if(subQueryDesc.getType() == SubqueryType.EXISTS) {
- RexNode subQueryNode = RexSubQuery.exists(subQueryDesc.getRexSubQuery());
- return subQueryNode;
- } else if(subQueryDesc.getType() == SubqueryType.SCALAR){
- if(subQueryDesc.getRexSubQuery().getRowType().getFieldCount() > 1) {
- throw new CalciteSubquerySemanticException(ErrorMsg.INVALID_SUBQUERY_EXPRESSION.getMsg(
- "SubQuery can contain only 1 item in Select List."));
- }
- //create RexSubQuery node
- RexNode rexSubQuery = RexSubQuery.scalar(subQueryDesc.getRexSubQuery());
- return rexSubQuery;
- } else if(subQueryDesc.getType() == SubqueryType.SOME
- || subQueryDesc.getType() == SubqueryType.ALL) {
- return convertSubquerySomeAll(subQueryDesc);
- } else {
- throw new CalciteSubquerySemanticException(ErrorMsg.INVALID_SUBQUERY_EXPRESSION.getMsg(
- "Invalid subquery: " + subQueryDesc.getType()));
- }
+ // TODO: Handle ExprNodeColumnDesc, ExprNodeColumnListDesc
}
private RexNode convert(final ExprNodeFieldDesc fieldDesc) throws SemanticException {
RexNode rexNode = convert(fieldDesc.getDesc());
if (rexNode.getType().isStruct()) {
// regular case of accessing nested field in a column
- return cluster.getRexBuilder().makeFieldAccess(rexNode, fieldDesc.getFieldName(), true);
+ return rexBuilder.makeFieldAccess(rexNode, fieldDesc.getFieldName(), true);
} else {
// This may happen for schema-less tables, where columns are dynamically
// supplied by serdes.
@@ -399,32 +225,31 @@ public class RexNodeConverter {
isAllPrimitive =
isAllPrimitive && tmpExprNode.getTypeInfo().getCategory() == Category.PRIMITIVE;
- argTypeBldr.add(TypeConverter.convert(tmpExprNode.getTypeInfo(), cluster.getTypeFactory()));
+ argTypeBldr.add(TypeConverter.convert(tmpExprNode.getTypeInfo(), typeFactory));
tmpRN = convert(tmpExprNode);
childRexNodeLst.add(tmpRN);
}
// See if this is an explicit cast.
- RexNode expr = null;
- RelDataType retType = null;
- expr = handleExplicitCast(func, childRexNodeLst);
+ RelDataType retType = TypeConverter.convert(func.getTypeInfo(), typeFactory);
+ RexNode expr = handleExplicitCast(func.getGenericUDF(), retType, childRexNodeLst,
+ rexBuilder);
if (expr == null) {
// This is not a cast; process the function.
- retType = TypeConverter.convert(func.getTypeInfo(), cluster.getTypeFactory());
SqlOperator calciteOp = SqlFunctionConverter.getCalciteOperator(func.getFuncText(),
func.getGenericUDF(), argTypeBldr.build(), retType);
if (calciteOp.getKind() == SqlKind.CASE) {
// If it is a case operator, we need to rewrite it
- childRexNodeLst = rewriteCaseChildren(func, childRexNodeLst);
+ childRexNodeLst = rewriteCaseChildren(func.getFuncText(), childRexNodeLst, rexBuilder);
// Adjust branch types by inserting explicit casts if the actual is ambigous
- childRexNodeLst = adjustCaseBranchTypes(childRexNodeLst, retType);
+ childRexNodeLst = adjustCaseBranchTypes(childRexNodeLst, retType, rexBuilder);
} else if (HiveExtractDate.ALL_FUNCTIONS.contains(calciteOp)) {
// If it is a extract operator, we need to rewrite it
- childRexNodeLst = rewriteExtractDateChildren(calciteOp, childRexNodeLst);
+ childRexNodeLst = rewriteExtractDateChildren(calciteOp, childRexNodeLst, rexBuilder);
} else if (HiveFloorDate.ALL_FUNCTIONS.contains(calciteOp)) {
// If it is a floor <date> operator, we need to rewrite it
- childRexNodeLst = rewriteFloorDateChildren(calciteOp, childRexNodeLst);
+ childRexNodeLst = rewriteFloorDateChildren(calciteOp, childRexNodeLst, rexBuilder);
} else if (calciteOp.getKind() == SqlKind.IN && isAllPrimitive) {
if (childRexNodeLst.size() == 2) {
// if it is a single item in an IN clause, transform A IN (B) to A = B
@@ -437,27 +262,19 @@ public class RexNodeConverter {
// except complex types
// Rewrite to OR is done only if number of operands are less than
// the threshold configured
- boolean rewriteToOr = true;
- if(this.maxNodesForInToOrTransformation != 0) {
- if(childRexNodeLst.size() > this.maxNodesForInToOrTransformation) {
- rewriteToOr = false;
- }
- }
- if(rewriteToOr) {
- childRexNodeLst = rewriteInClauseChildren(calciteOp, childRexNodeLst);
- calciteOp = SqlStdOperatorTable.OR;
- }
+ childRexNodeLst = rewriteInClauseChildren(calciteOp, childRexNodeLst, rexBuilder);
+ calciteOp = SqlStdOperatorTable.OR;
}
} else if (calciteOp.getKind() == SqlKind.COALESCE &&
childRexNodeLst.size() > 1) {
// Rewrite COALESCE as a CASE
// This allows to be further reduced to OR, if possible
calciteOp = SqlStdOperatorTable.CASE;
- childRexNodeLst = rewriteCoalesceChildren(func, childRexNodeLst);
+ childRexNodeLst = rewriteCoalesceChildren(childRexNodeLst, rexBuilder);
// Adjust branch types by inserting explicit casts if the actual is ambigous
- childRexNodeLst = adjustCaseBranchTypes(childRexNodeLst, retType);
+ childRexNodeLst = adjustCaseBranchTypes(childRexNodeLst, retType, rexBuilder);
} else if (calciteOp == HiveToDateSqlOperator.INSTANCE) {
- childRexNodeLst = rewriteToDateChildren(childRexNodeLst);
+ childRexNodeLst = rewriteToDateChildren(childRexNodeLst, rexBuilder);
} else if (calciteOp.getKind() == SqlKind.BETWEEN) {
assert childRexNodeLst.get(0).isAlwaysTrue() || childRexNodeLst.get(0).isAlwaysFalse();
boolean invert = childRexNodeLst.get(0).isAlwaysTrue();
@@ -473,29 +290,29 @@ public class RexNodeConverter {
RexNode rangeL = childRexNodeLst.get(2);
RexNode rangeH = childRexNodeLst.get(3);
childRexNodeLst.clear();
- childRexNodeLst.add(cluster.getRexBuilder().makeCall(cmpOp, rangeL, op));
- childRexNodeLst.add(cluster.getRexBuilder().makeCall(cmpOp, op, rangeH));
+ childRexNodeLst.add(rexBuilder.makeCall(cmpOp, rangeL, op));
+ childRexNodeLst.add(rexBuilder.makeCall(cmpOp, op, rangeH));
}
- expr = cluster.getRexBuilder().makeCall(retType, calciteOp, childRexNodeLst);
+ expr = rexBuilder.makeCall(retType, calciteOp, childRexNodeLst);
} else {
retType = expr.getType();
}
// TODO: Cast Function in Calcite have a bug where it infer type on cast throws
// an exception
- if (flattenExpr && (expr instanceof RexCall)
+ if (expr instanceof RexCall
&& !(((RexCall) expr).getOperator() instanceof SqlCastFunction)) {
RexCall call = (RexCall) expr;
- expr = cluster.getRexBuilder().makeCall(retType, call.getOperator(),
+ expr = rexBuilder.makeCall(retType, call.getOperator(),
RexUtil.flatten(call.getOperands(), call.getOperator()));
}
return expr;
}
- private boolean castExprUsingUDFBridge(GenericUDF gUDF) {
+ private static boolean castExprUsingUDFBridge(GenericUDF gUDF) {
boolean castExpr = false;
- if (gUDF != null && gUDF instanceof GenericUDFBridge) {
+ if (gUDF instanceof GenericUDFBridge) {
String udfClassName = ((GenericUDFBridge) gUDF).getUdfClassName();
if (udfClassName != null) {
int sp = udfClassName.lastIndexOf('.');
@@ -515,20 +332,17 @@ public class RexNodeConverter {
return castExpr;
}
- private RexNode handleExplicitCast(ExprNodeGenericFuncDesc func, List<RexNode> childRexNodeLst)
- throws CalciteSemanticException {
+ public static RexNode handleExplicitCast(GenericUDF udf, RelDataType returnType, List<RexNode> childRexNodeLst,
+ RexBuilder rexBuilder) {
RexNode castExpr = null;
if (childRexNodeLst != null && childRexNodeLst.size() == 1) {
- GenericUDF udf = func.getGenericUDF();
if ((udf instanceof GenericUDFToChar) || (udf instanceof GenericUDFToVarchar)
|| (udf instanceof GenericUDFToString)
|| (udf instanceof GenericUDFToDecimal) || (udf instanceof GenericUDFToDate)
|| (udf instanceof GenericUDFTimestamp) || (udf instanceof GenericUDFToTimestampLocalTZ)
|| (udf instanceof GenericUDFToBinary) || castExprUsingUDFBridge(udf)) {
- castExpr = cluster.getRexBuilder().makeAbstractCast(
- TypeConverter.convert(func.getTypeInfo(), cluster.getTypeFactory()),
- childRexNodeLst.get(0));
+ castExpr = rexBuilder.makeAbstractCast(returnType, childRexNodeLst.get(0));
}
}
@@ -550,10 +364,10 @@ public class RexNodeConverter {
* It will be transformed into:
* CASE WHEN =(x + y, 1) THEN 'fee' WHEN =(x + y, 2) THEN 'fie' ELSE null END
*/
- private List<RexNode> rewriteCaseChildren(ExprNodeGenericFuncDesc func, List<RexNode> childRexNodeLst)
- throws SemanticException {
- List<RexNode> newChildRexNodeLst = new ArrayList<RexNode>();
- if (FunctionRegistry.getNormalizedFunctionName(func.getFuncText()).equals("case")) {
+ public static List<RexNode> rewriteCaseChildren(String funcText, List<RexNode> childRexNodeLst,
+ RexBuilder rexBuilder) throws SemanticException {
+ List<RexNode> newChildRexNodeLst = new ArrayList<>();
+ if (FunctionRegistry.getNormalizedFunctionName(funcText).equals("case")) {
RexNode firstPred = childRexNodeLst.get(0);
int length = childRexNodeLst.size() % 2 == 1 ?
childRexNodeLst.size() : childRexNodeLst.size() - 1;
@@ -561,7 +375,7 @@ public class RexNodeConverter {
if (i % 2 == 1) {
// We rewrite it
newChildRexNodeLst.add(
- cluster.getRexBuilder().makeCall(
+ rexBuilder.makeCall(
SqlStdOperatorTable.EQUALS, firstPred, childRexNodeLst.get(i)));
} else {
newChildRexNodeLst.add(childRexNodeLst.get(i));
@@ -576,7 +390,7 @@ public class RexNodeConverter {
}
// Calcite always needs the else clause to be defined explicitly
if (newChildRexNodeLst.size() % 2 == 0) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeNullLiteral(
+ newChildRexNodeLst.add(rexBuilder.makeNullLiteral(
newChildRexNodeLst.get(newChildRexNodeLst.size()-1).getType()));
}
return newChildRexNodeLst;
@@ -588,13 +402,13 @@ public class RexNodeConverter {
* Calcite is more stricter than hive w.r.t type conversions.
* If a CASE has branches with string/int/boolean branch types; there is no common type.
*/
- private List<RexNode> adjustCaseBranchTypes(List<RexNode> nodes, RelDataType retType) {
+ public static List<RexNode> adjustCaseBranchTypes(List<RexNode> nodes, RelDataType retType, RexBuilder rexBuilder) {
List<RexNode> newNodes = new ArrayList<>();
for (int i = 0; i < nodes.size(); i++) {
RexNode node = nodes.get(i);
if ((i % 2 == 1 || i == nodes.size() - 1)
&& !node.getType().getSqlTypeName().equals(retType.getSqlTypeName())) {
- newNodes.add(cluster.getRexBuilder().makeCast(retType, node));
+ newNodes.add(rexBuilder.makeCast(retType, node));
} else {
newNodes.add(node);
}
@@ -602,33 +416,33 @@ public class RexNodeConverter {
return newNodes;
}
- private List<RexNode> rewriteExtractDateChildren(SqlOperator op, List<RexNode> childRexNodeLst)
- throws SemanticException {
+ public static List<RexNode> rewriteExtractDateChildren(SqlOperator op, List<RexNode> childRexNodeLst,
+ RexBuilder rexBuilder) {
List<RexNode> newChildRexNodeLst = new ArrayList<>(2);
final boolean isTimestampLevel;
if (op == HiveExtractDate.YEAR) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.YEAR));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.YEAR));
isTimestampLevel = false;
} else if (op == HiveExtractDate.QUARTER) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.QUARTER));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.QUARTER));
isTimestampLevel = false;
} else if (op == HiveExtractDate.MONTH) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.MONTH));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.MONTH));
isTimestampLevel = false;
} else if (op == HiveExtractDate.WEEK) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.WEEK));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.WEEK));
isTimestampLevel = false;
} else if (op == HiveExtractDate.DAY) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.DAY));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.DAY));
isTimestampLevel = false;
} else if (op == HiveExtractDate.HOUR) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.HOUR));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.HOUR));
isTimestampLevel = true;
} else if (op == HiveExtractDate.MINUTE) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.MINUTE));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.MINUTE));
isTimestampLevel = true;
} else if (op == HiveExtractDate.SECOND) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.SECOND));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.SECOND));
isTimestampLevel = true;
} else {
isTimestampLevel = false;
@@ -640,76 +454,144 @@ public class RexNodeConverter {
} else {
// We need to add a cast to DATETIME Family
if (isTimestampLevel) {
- newChildRexNodeLst.add(makeCast(SqlTypeName.TIMESTAMP, child));
+ newChildRexNodeLst.add(makeCast(SqlTypeName.TIMESTAMP, child, rexBuilder));
} else {
- newChildRexNodeLst.add(makeCast(SqlTypeName.DATE, child));
+ newChildRexNodeLst.add(makeCast(SqlTypeName.DATE, child, rexBuilder));
}
}
return newChildRexNodeLst;
}
- private RexNode makeCast(SqlTypeName typeName, final RexNode child) {
- RelDataType sqlType = cluster.getTypeFactory().createSqlType(typeName);
- RelDataType nullableType = cluster.getTypeFactory().createTypeWithNullability(sqlType, true);
- return cluster.getRexBuilder().makeCast(nullableType, child);
+ private static RexNode makeCast(SqlTypeName typeName, final RexNode child, RexBuilder rexBuilder) {
+ RelDataType sqlType = rexBuilder.getTypeFactory().createSqlType(typeName);
+ RelDataType nullableType = rexBuilder.getTypeFactory().createTypeWithNullability(sqlType, true);
+ return rexBuilder.makeCast(nullableType, child);
}
- private List<RexNode> rewriteFloorDateChildren(SqlOperator op, List<RexNode> childRexNodeLst)
- throws SemanticException {
- List<RexNode> newChildRexNodeLst = new ArrayList<RexNode>();
+ public static List<RexNode> rewriteFloorDateChildren(SqlOperator op, List<RexNode> childRexNodeLst,
+ RexBuilder rexBuilder) {
+ List<RexNode> newChildRexNodeLst = new ArrayList<>();
assert childRexNodeLst.size() == 1;
newChildRexNodeLst.add(childRexNodeLst.get(0));
if (op == HiveFloorDate.YEAR) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.YEAR));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.YEAR));
} else if (op == HiveFloorDate.QUARTER) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.QUARTER));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.QUARTER));
} else if (op == HiveFloorDate.MONTH) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.MONTH));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.MONTH));
} else if (op == HiveFloorDate.WEEK) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.WEEK));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.WEEK));
} else if (op == HiveFloorDate.DAY) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.DAY));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.DAY));
} else if (op == HiveFloorDate.HOUR) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.HOUR));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.HOUR));
} else if (op == HiveFloorDate.MINUTE) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.MINUTE));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.MINUTE));
} else if (op == HiveFloorDate.SECOND) {
- newChildRexNodeLst.add(cluster.getRexBuilder().makeFlag(TimeUnitRange.SECOND));
+ newChildRexNodeLst.add(rexBuilder.makeFlag(TimeUnitRange.SECOND));
}
return newChildRexNodeLst;
}
- private List<RexNode> rewriteToDateChildren(List<RexNode> childRexNodeLst) {
- List<RexNode> newChildRexNodeLst = new ArrayList<RexNode>();
+ public static List<RexNode> rewriteToDateChildren(List<RexNode> childRexNodeLst, RexBuilder rexBuilder) {
+ List<RexNode> newChildRexNodeLst = new ArrayList<>();
assert childRexNodeLst.size() == 1;
RexNode child = childRexNodeLst.get(0);
if (SqlTypeUtil.isDatetime(child.getType()) || SqlTypeUtil.isInterval(child.getType())) {
newChildRexNodeLst.add(child);
} else {
- newChildRexNodeLst.add(makeCast(SqlTypeName.TIMESTAMP, child));
+ newChildRexNodeLst.add(makeCast(SqlTypeName.TIMESTAMP, child, rexBuilder));
}
return newChildRexNodeLst;
}
- private List<RexNode> rewriteInClauseChildren(SqlOperator op, List<RexNode> childRexNodeLst)
- throws SemanticException {
+ /**
+ * The method tries to rewrite an the operands of an IN function call into
+ * the operands for an OR function call.
+ * For instance:
+ * <pre>
+ * (c) IN ( v1, v2, ...) => c=v1 || c=v2 || ...
+ * Input: (c, v1, v2, ...)
+ * Output: (c=v1, c=v2, ...)
+ * </pre>
+ * Or:
+ * <pre>
+ * (c,d) IN ( (v1,v2), (v3,v4), ...) => (c=v1 && d=v2) || (c=v3 && d=v4) || ...
+ * Input: ((c,d), (v1,v2), (v3,v4), ...)
+ * Output: (c=v1 && d=v2, c=v3 && d=v4, ...)
+ * </pre>
+ *
+ * Returns null if the transformation fails, e.g., when non-deterministic
+ * calls are found in the expressions.
+ */
+ public static List<RexNode> transformInToOrOperands(List<RexNode> operands, RexBuilder rexBuilder) {
+ final List<RexNode> disjuncts = new ArrayList<>(operands.size() - 2);
+ if (operands.get(0).getKind() != SqlKind.ROW) {
+ final RexNode columnExpression = operands.get(0);
+ if (!HiveCalciteUtil.isDeterministic(columnExpression)) {
+ // Bail out
+ return null;
+ }
+ for (int i = 1; i < operands.size(); i++) {
+ final RexNode valueExpression = operands.get(i);
+ if (!HiveCalciteUtil.isDeterministic(valueExpression)) {
+ // Bail out
+ return null;
+ }
+ disjuncts.add(rexBuilder.makeCall(
+ SqlStdOperatorTable.EQUALS,
+ columnExpression,
+ valueExpression));
+ }
+ } else {
+ final RexCall columnExpressions = (RexCall) operands.get(0);
+ if (!HiveCalciteUtil.isDeterministic(columnExpressions)) {
+ // Bail out
+ return null;
+ }
+ for (int i = 1; i < operands.size(); i++) {
+ List<RexNode> conjuncts = new ArrayList<>(columnExpressions.getOperands().size() - 1);
+ RexCall valueExpressions = (RexCall) operands.get(i);
+ if (!HiveCalciteUtil.isDeterministic(valueExpressions)) {
+ // Bail out
+ return null;
+ }
+ for (int j = 0; j < columnExpressions.getOperands().size(); j++) {
+ conjuncts.add(rexBuilder.makeCall(
+ SqlStdOperatorTable.EQUALS,
+ columnExpressions.getOperands().get(j),
+ valueExpressions.getOperands().get(j)));
+ }
+ if (conjuncts.size() > 1) {
+ disjuncts.add(rexBuilder.makeCall(
+ SqlStdOperatorTable.AND,
+ conjuncts));
+ } else {
+ disjuncts.add(conjuncts.get(0));
+ }
+ }
+ }
+ return disjuncts;
+ }
+
+ public static List<RexNode> rewriteInClauseChildren(SqlOperator op, List<RexNode> childRexNodeLst,
+ RexBuilder rexBuilder) throws SemanticException {
assert op.getKind() == SqlKind.IN;
RexNode firstPred = childRexNodeLst.get(0);
List<RexNode> newChildRexNodeLst = new ArrayList<RexNode>();
for (int i = 1; i < childRexNodeLst.size(); i++) {
newChildRexNodeLst.add(
- cluster.getRexBuilder().makeCall(
+ rexBuilder.makeCall(
SqlStdOperatorTable.EQUALS, firstPred, childRexNodeLst.get(i)));
}
return newChildRexNodeLst;
}
- private List<RexNode> rewriteCoalesceChildren(
- ExprNodeGenericFuncDesc func, List<RexNode> childRexNodeLst) {
+ public static List<RexNode> rewriteCoalesceChildren(
+ List<RexNode> childRexNodeLst, RexBuilder rexBuilder) {
final List<RexNode> convertedChildList = Lists.newArrayList();
assert childRexNodeLst.size() > 0;
- final RexBuilder rexBuilder = cluster.getRexBuilder();
int i=0;
for (; i < childRexNodeLst.size()-1; ++i) {
// WHEN child not null THEN child
@@ -741,77 +623,7 @@ public class RexNodeConverter {
return false;
}
- private InputCtx getInputCtx(ExprNodeColumnDesc col) throws SemanticException {
- InputCtx ctxLookingFor = null;
-
- if (inputCtxs.size() == 1 && inputCtxs.get(0).hiveRR == null) {
- ctxLookingFor = inputCtxs.get(0);
- } else {
- String tableAlias = col.getTabAlias();
- String colAlias = col.getColumn();
- int noInp = 0;
- for (InputCtx ic : inputCtxs) {
- if (tableAlias == null || ic.hiveRR.hasTableAlias(tableAlias)) {
- if (ic.hiveRR.getPosition(colAlias) >= 0) {
- ctxLookingFor = ic;
- noInp++;
- }
- }
- }
-
- if (noInp > 1) {
- throw new RuntimeException("Ambiguous column mapping");
- }
- }
-
- return ctxLookingFor;
- }
-
- protected RexNode convert(ExprNodeColumnDesc col) throws SemanticException {
- //if this is co-rrelated we need to make RexCorrelVariable(with id and type)
- // id and type should be retrieved from outerRR
- InputCtx ic = getInputCtx(col);
- if(ic == null) {
- // we have correlated column, build data type from outer rr
- RelDataType rowType = TypeConverter.getType(cluster, this.outerRR, null);
- if (this.outerNameToPosMap.get(col.getColumn()) == null) {
- throw new SemanticException(ErrorMsg.INVALID_COLUMN_NAME.getMsg(col.getColumn()));
- }
-
- int pos = this.outerNameToPosMap.get(col.getColumn());
- CorrelationId colCorr = new CorrelationId(this.correlatedId);
- RexNode corExpr = cluster.getRexBuilder().makeCorrel(rowType, colCorr);
- return cluster.getRexBuilder().makeFieldAccess(corExpr, pos);
- }
- int pos = ic.hiveNameToPosMap.get(col.getColumn());
- return cluster.getRexBuilder().makeInputRef(
- ic.calciteInpDataType.getFieldList().get(pos).getType(), pos + ic.offsetInCalciteSchema);
- }
-
- private static final BigInteger MIN_LONG_BI = BigInteger.valueOf(Long.MIN_VALUE),
- MAX_LONG_BI = BigInteger.valueOf(Long.MAX_VALUE);
-
- private static NlsString makeHiveUnicodeString(Interpretation interpretation, String text) {
- return new HiveNlsString(interpretation, text, ConversionUtil.NATIVE_UTF16_CHARSET_NAME, SqlCollation.IMPLICIT);
- }
-
- static class HiveNlsString extends NlsString {
-
- enum Interpretation {
- CHAR, VARCHAR, STRING;
- }
-
- public final Interpretation interpretation;
-
- public HiveNlsString(Interpretation interpretation, String value, String charsetName, SqlCollation collation) {
- super(value, charsetName, collation);
- this.interpretation = interpretation;
- }
-
- }
-
protected RexNode convert(ExprNodeConstantDesc literal) throws CalciteSemanticException {
- final RexBuilder rexBuilder = cluster.getRexBuilder();
final RelDataTypeFactory dtFactory = rexBuilder.getTypeFactory();
final PrimitiveTypeInfo hiveType = (PrimitiveTypeInfo) literal.getTypeInfo();
final RelDataType calciteDataType = TypeConverter.convert(hiveType, dtFactory);
@@ -844,7 +656,6 @@ public class RexNodeConverter {
case LONG:
calciteLiteral = rexBuilder.makeBigintLiteral(new BigDecimal((Long) value));
break;
- // TODO: is Decimal an exact numeric or approximate numeric?
case DECIMAL:
if (value instanceof HiveDecimal) {
value = ((HiveDecimal) value).bigDecimalValue();
@@ -867,8 +678,6 @@ public class RexNodeConverter {
// TODO: return createNullLiteral(literal);
}
BigDecimal bd = (BigDecimal) value;
- BigInteger unscaled = bd.unscaledValue();
-
int precision = bd.unscaledValue().abs().toString().length();
int scale = bd.scale();
@@ -877,11 +686,11 @@ public class RexNodeConverter {
if (precision > scale) {
// bd is greater than or equal to 1
relType =
- cluster.getTypeFactory().createSqlType(SqlTypeName.DECIMAL, precision, scale);
+ typeFactory.createSqlType(SqlTypeName.DECIMAL, precision, scale);
} else {
// bd is less than 1
relType =
- cluster.getTypeFactory().createSqlType(SqlTypeName.DECIMAL, scale + 1, scale);
+ typeFactory.createSqlType(SqlTypeName.DECIMAL, scale + 1, scale);
}
calciteLiteral = rexBuilder.makeExactLiteral(bd, relType);
break;
@@ -901,16 +710,19 @@ public class RexNodeConverter {
if (value instanceof HiveChar) {
value = ((HiveChar) value).getValue();
}
- calciteLiteral = rexBuilder.makeCharLiteral(makeHiveUnicodeString(Interpretation.CHAR, (String) value));
+ calciteLiteral = rexBuilder.makeCharLiteral(
+ RexNodeExprFactory.makeHiveUnicodeString(Interpretation.CHAR, (String) value));
break;
case VARCHAR:
if (value instanceof HiveVarchar) {
value = ((HiveVarchar) value).getValue();
}
- calciteLiteral = rexBuilder.makeCharLiteral(makeHiveUnicodeString(Interpretation.VARCHAR, (String) value));
+ calciteLiteral = rexBuilder.makeCharLiteral(
+ RexNodeExprFactory.makeHiveUnicodeString(Interpretation.VARCHAR, (String) value));
break;
case STRING:
- calciteLiteral = rexBuilder.makeCharLiteral(makeHiveUnicodeString(Interpretation.STRING, (String) value));
+ calciteLiteral = rexBuilder.makeCharLiteral(
+ RexNodeExprFactory.makeHiveUnicodeString(Interpretation.STRING, (String) value));
break;
case DATE:
final Date date = (Date) value;
@@ -936,14 +748,10 @@ public class RexNodeConverter {
break;
case TIMESTAMPLOCALTZ:
final TimestampString tsLocalTZString;
- if (value == null) {
- tsLocalTZString = null;
- } else {
- Instant i = ((TimestampTZ)value).getZonedDateTime().toInstant();
- tsLocalTZString = TimestampString
- .fromMillisSinceEpoch(i.toEpochMilli())
- .withNanos(i.getNano());
- }
+ Instant i = ((TimestampTZ)value).getZonedDateTime().toInstant();
+ tsLocalTZString = TimestampString
+ .fromMillisSinceEpoch(i.toEpochMilli())
+ .withNanos(i.getNano());
calciteLiteral = rexBuilder.makeTimestampWithLocalTimeZoneLiteral(
tsLocalTZString,
rexBuilder.getTypeFactory().getTypeSystem().getDefaultPrecision(SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE));
@@ -973,25 +781,10 @@ public class RexNodeConverter {
case BINARY:
case UNKNOWN:
default:
- throw new RuntimeException("UnSupported Literal");
+ throw new RuntimeException("Unsupported Literal");
}
return calciteLiteral;
}
- public static RexNode convert(RelOptCluster cluster, ExprNodeDesc joinCondnExprNode,
- List<RelNode> inputRels, LinkedHashMap<RelNode, RowResolver> relToHiveRR,
- Map<RelNode, ImmutableMap<String, Integer>> relToHiveColNameCalcitePosMap, boolean flattenExpr)
- throws SemanticException {
- List<InputCtx> inputCtxLst = new ArrayList<InputCtx>();
-
- int offSet = 0;
- for (RelNode r : inputRels) {
- inputCtxLst.add(new InputCtx(r.getRowType(), relToHiveColNameCalcitePosMap.get(r), relToHiveRR
- .get(r), offSet));
- offSet += r.getRowType().getFieldCount();
- }
-
- return (new RexNodeConverter(cluster, inputCtxLst, flattenExpr)).convert(joinCondnExprNode);
- }
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/SqlFunctionConverter.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/SqlFunctionConverter.java
index 07ca87f..9819f4a 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/SqlFunctionConverter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/SqlFunctionConverter.java
@@ -62,6 +62,7 @@ import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveIn;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSqlFunction;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveToDateSqlOperator;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTruncSqlOperator;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveToUnixTimestampSqlOperator;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveUnixTimestampSqlOperator;
import org.apache.hadoop.hive.ql.parse.ASTNode;
import org.apache.hadoop.hive.ql.parse.HiveParser;
@@ -243,6 +244,8 @@ public class SqlFunctionConverter {
case IN:
case BETWEEN:
case ROW:
+ case ARRAY_VALUE_CONSTRUCTOR:
+ case MAP_VALUE_CONSTRUCTOR:
case IS_NOT_TRUE:
case IS_TRUE:
case IS_NOT_FALSE:
@@ -381,6 +384,8 @@ public class SqlFunctionConverter {
registerFunction("in", HiveIn.INSTANCE, hToken(HiveParser.Identifier, "in"));
registerFunction("between", HiveBetween.INSTANCE, hToken(HiveParser.Identifier, "between"));
registerFunction("struct", SqlStdOperatorTable.ROW, hToken(HiveParser.Identifier, "struct"));
+ registerFunction("array", SqlStdOperatorTable.ARRAY_VALUE_CONSTRUCTOR, hToken(HiveParser.Identifier, "array"));
+ registerFunction("map", SqlStdOperatorTable.MAP_VALUE_CONSTRUCTOR, hToken(HiveParser.Identifier, "map"));
registerFunction("isnotnull", SqlStdOperatorTable.IS_NOT_NULL, hToken(HiveParser.Identifier, "isnotnull"));
registerFunction("isnull", SqlStdOperatorTable.IS_NULL, hToken(HiveParser.Identifier, "isnull"));
registerFunction("isnottrue", SqlStdOperatorTable.IS_NOT_TRUE, hToken(HiveParser.Identifier, "isnottrue"));
@@ -464,12 +469,12 @@ public class SqlFunctionConverter {
);
registerFunction("trunc", HiveTruncSqlOperator.INSTANCE, hToken(HiveParser.Identifier, "trunc"));
registerFunction("to_date", HiveToDateSqlOperator.INSTANCE, hToken(HiveParser.Identifier, "to_date"));
- registerFunction("to_unix_timestamp", HiveUnixTimestampSqlOperator.INSTANCE,
- hToken(HiveParser.Identifier, "to_unix_timestamp")
- );
+ registerFunction("to_unix_timestamp", HiveToUnixTimestampSqlOperator.INSTANCE,
+ hToken(HiveParser.Identifier, "to_unix_timestamp"));
+ registerFunction("unix_timestamp", HiveUnixTimestampSqlOperator.INSTANCE,
+ hToken(HiveParser.Identifier, "unix_timestamp"));
registerFunction("from_unixtime", HiveFromUnixTimeSqlOperator.INSTANCE,
- hToken(HiveParser.Identifier, "from_unixtime")
- );
+ hToken(HiveParser.Identifier, "from_unixtime"));
registerFunction("date_add", HiveDateAddSqlOperator.INSTANCE, hToken(HiveParser.Identifier, "date_add"));
registerFunction("date_sub", HiveDateSubSqlOperator.INSTANCE, hToken(HiveParser.Identifier, "date_sub"));
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/TypeConverter.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/TypeConverter.java
index ed4a73e..fc019a7 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/TypeConverter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/TypeConverter.java
@@ -29,6 +29,7 @@ import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rel.type.RelDataTypeField;
import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexLiteral;
import org.apache.calcite.sql.SqlCollation;
import org.apache.calcite.sql.SqlIntervalQualifier;
import org.apache.calcite.sql.parser.SqlParserPos;
@@ -46,6 +47,7 @@ import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException.Unsu
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.SqlFunctionConverter.HiveToken;
import org.apache.hadoop.hive.ql.parse.HiveParser;
import org.apache.hadoop.hive.ql.parse.RowResolver;
+import org.apache.hadoop.hive.ql.parse.type.RexNodeExprFactory.HiveNlsString;
import org.apache.hadoop.hive.serde.serdeConstants;
import org.apache.hadoop.hive.serde2.typeinfo.BaseCharTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo;
@@ -140,7 +142,7 @@ public class TypeConverter {
}
public static RelDataType convert(TypeInfo type, RelDataTypeFactory dtFactory)
- throws CalciteSemanticException{
+ throws CalciteSemanticException {
RelDataType convertedType = null;
switch (type.getCategory()) {
@@ -272,6 +274,35 @@ public class TypeConverter {
throw new CalciteSemanticException("Union type is not supported", UnsupportedFeature.Union_type);
}
+ /**
+ * This method exists because type information for CHAR literals
+ * is encoded within the literal value itself. The reason is that
+ * Calcite considers any character literal as CHAR type by default,
+ * while Hive is more flexible and may consider them STRING, VARCHAR,
+ * or CHAR.
+ */
+ public static TypeInfo convertLiteralType(RexLiteral literal) {
+ if (literal.getType().getSqlTypeName() == SqlTypeName.CHAR) {
+ HiveNlsString string = (HiveNlsString) RexLiteral.value(literal);
+ if (string == null) {
+ // Original type
+ return TypeConverter.convertPrimitiveType(literal.getType());
+ }
+ // Interpret
+ switch (string.interpretation) {
+ case STRING:
+ return TypeInfoFactory.stringTypeInfo;
+ case VARCHAR:
+ return TypeInfoFactory.getVarcharTypeInfo(
+ literal.getType().getPrecision());
+ case CHAR:
+ return TypeInfoFactory.getCharTypeInfo(
+ literal.getType().getPrecision());
+ }
+ }
+ return TypeConverter.convertPrimitiveType(literal.getType());
+ }
+
public static TypeInfo convert(RelDataType rType) {
if (rType.isStruct()) {
return convertStructType(rType);
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/listbucketingpruner/LBProcFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/listbucketingpruner/LBProcFactory.java
index eb0d8aa..b81e51f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/listbucketingpruner/LBProcFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/listbucketingpruner/LBProcFactory.java
@@ -42,7 +42,7 @@ public final class LBProcFactory extends PrunerOperatorFactory {
@Override
protected void generatePredicate(NodeProcessorCtx procCtx, FilterOperator fop,
- TableScanOperator top) throws SemanticException, UDFArgumentException {
+ TableScanOperator top) throws SemanticException {
LBOpWalkerCtx owc = (LBOpWalkerCtx) procCtx;
// Otherwise this is not a sampling predicate and we need to
ExprNodeDesc predicate = fop.getConf().getPredicate();
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
index ee3aaa5..7b2e201 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hive.ql.parse;
import com.google.common.base.Function;
import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableMap;
@@ -26,6 +27,8 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
+import java.util.Map.Entry;
+import java.util.Optional;
import java.util.regex.Pattern;
import org.antlr.runtime.ClassicToken;
import org.antlr.runtime.CommonToken;
@@ -78,6 +81,7 @@ import org.apache.calcite.rel.RelVisitor;
import org.apache.calcite.rel.convert.ConverterImpl;
import org.apache.calcite.rel.core.Aggregate;
import org.apache.calcite.rel.core.AggregateCall;
+import org.apache.calcite.rel.core.CorrelationId;
import org.apache.calcite.rel.core.Filter;
import org.apache.calcite.rel.core.JoinRelType;
import org.apache.calcite.rel.core.Project;
@@ -100,9 +104,12 @@ import org.apache.calcite.rel.type.RelDataTypeImpl;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexCall;
import org.apache.calcite.rex.RexExecutor;
+import org.apache.calcite.rex.RexFieldAccess;
import org.apache.calcite.rex.RexFieldCollation;
import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexLiteral;
import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexShuttle;
import org.apache.calcite.rex.RexUtil;
import org.apache.calcite.rex.RexWindowBound;
import org.apache.calcite.schema.SchemaPlus;
@@ -118,7 +125,6 @@ import org.apache.calcite.sql.SqlOperator;
import org.apache.calcite.sql.SqlWindow;
import org.apache.calcite.sql.dialect.HiveSqlDialect;
import org.apache.calcite.sql.parser.SqlParserPos;
-import org.apache.calcite.sql.type.ArraySqlType;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.validate.SqlValidatorUtil;
import org.apache.calcite.tools.Frameworks;
@@ -147,11 +153,27 @@ import org.apache.hadoop.hive.ql.exec.Utilities;
import org.apache.hadoop.hive.ql.lib.Node;
import org.apache.hadoop.hive.ql.log.PerfLogger;
import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.metadata.HiveUtils;
import org.apache.hadoop.hive.ql.metadata.NotNullConstraint;
import org.apache.hadoop.hive.ql.metadata.PrimaryKeyInfo;
import org.apache.hadoop.hive.ql.metadata.Table;
import org.apache.hadoop.hive.ql.metadata.VirtualColumn;
-import org.apache.hadoop.hive.ql.optimizer.calcite.*;
+import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException;
+import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubqueryRuntimeException;
+import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException;
+import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteViewSemanticException;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveConfPlannerContext;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveDefaultRelMetadataProvider;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HivePlannerContext;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveRelDistribution;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveRelFactories;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveRelOptMaterializationValidator;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveRelOptUtil;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveRexExecutorImpl;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveTypeSystemImpl;
+import org.apache.hadoop.hive.ql.optimizer.calcite.RelOptHiveTable;
+import org.apache.hadoop.hive.ql.optimizer.calcite.TraitsUtil;
import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException.UnsupportedFeature;
import org.apache.hadoop.hive.ql.optimizer.calcite.cost.HiveAlgorithmsConf;
import org.apache.hadoop.hive.ql.optimizer.calcite.cost.HiveVolcanoPlanner;
@@ -164,6 +186,7 @@ import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveJoin;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveMultiJoin;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveProject;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveRelNode;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveRexExprList;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSemiJoin;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSortExchange;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSortLimit;
@@ -242,10 +265,11 @@ import org.apache.hadoop.hive.ql.optimizer.calcite.rules.views.HiveNoAggregateIn
import org.apache.hadoop.hive.ql.optimizer.calcite.rules.views.MaterializedViewRewritingRelVisitor;
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTBuilder;
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter;
-import org.apache.hadoop.hive.ql.parse.type.ExprNodeTypeCheck;
+import org.apache.hadoop.hive.ql.parse.type.FunctionHelper;
+import org.apache.hadoop.hive.ql.parse.type.FunctionHelper.AggregateInfo;
+import org.apache.hadoop.hive.ql.parse.type.HiveFunctionHelper;
import org.apache.hadoop.hive.ql.parse.type.JoinTypeCheckCtx;
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.PlanModifierForReturnPath;
-import org.apache.hadoop.hive.ql.optimizer.calcite.translator.RexNodeConverter;
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.SqlFunctionConverter;
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.TypeConverter;
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.opconventer.HiveOpConverter;
@@ -259,26 +283,19 @@ import org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowExpressionSpec;
import org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowFunctionSpec;
import org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowSpec;
import org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowType;
+import org.apache.hadoop.hive.ql.parse.type.RexNodeTypeCheck;
import org.apache.hadoop.hive.ql.parse.type.TypeCheckCtx;
import org.apache.hadoop.hive.ql.parse.type.TypeCheckProcFactory;
import org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc;
-import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
-import org.apache.hadoop.hive.ql.plan.ExprNodeDescUtils;
-import org.apache.hadoop.hive.ql.plan.GroupByDesc;
import org.apache.hadoop.hive.ql.plan.HiveOperation;
import org.apache.hadoop.hive.ql.plan.SelectDesc;
import org.apache.hadoop.hive.ql.plan.mapper.EmptyStatsSource;
import org.apache.hadoop.hive.ql.plan.mapper.StatsSource;
import org.apache.hadoop.hive.ql.session.SessionState;
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDFArray;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDTFInline;
-import org.apache.hadoop.hive.serde.serdeConstants;
-import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.StandardStructObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.StructField;
import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
@@ -1774,13 +1791,13 @@ public class CalcitePlanner extends SemanticAnalyzer {
private class CalcitePlannerAction implements Frameworks.PlannerAction<RelNode> {
private RelOptCluster cluster;
private RelOptSchema relOptSchema;
+ private FunctionHelper functionHelper;
private final Map<String, PrunedPartitionList> partitionCache;
private final Map<String, ColumnStatsList> colStatsCache;
private final ColumnAccessInfo columnAccessInfo;
private Map<HiveProject, Table> viewProjectToTableSchema;
- //correlated vars across subqueries within same query needs to have different ID
- // this will be used in RexNodeConverter to create cor var
+ // correlated vars across subqueries within same query needs to have different ID
private int subqueryId;
// this is to keep track if a subquery is correlated and contains aggregate
@@ -1819,6 +1836,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
this.cluster = optCluster;
this.relOptSchema = relOptSchema;
+ this.functionHelper = new HiveFunctionHelper(rexBuilder);
PerfLogger perfLogger = SessionState.getPerfLogger();
// 1. Gen Calcite Plan
@@ -1836,7 +1854,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
perfLogger.PerfLogEnd(this.getClass().getName(), PerfLogger.OPTIMIZER, "Calcite: Plan generation");
// Create executor
- RexExecutor executorProvider = new HiveRexExecutorImpl(optCluster);
+ RexExecutor executorProvider = new HiveRexExecutorImpl();
calciteGenPlan.getCluster().getPlanner().setExecutor(executorProvider);
// We need to get the ColumnAccessInfo and viewToTableSchema for views.
@@ -2734,18 +2752,13 @@ public class CalcitePlanner extends SemanticAnalyzer {
} else if (unparseTranslator != null && unparseTranslator.isEnabled()) {
genAllExprNodeDesc(joinCond, input, jCtx);
}
- Map<ASTNode, ExprNodeDesc> exprNodes = ExprNodeTypeCheck.genExprNodeJoinCond(
- joinCond, jCtx);
+ Map<ASTNode, RexNode> exprNodes = RexNodeTypeCheck.genExprNodeJoinCond(
+ joinCond, jCtx, cluster.getRexBuilder());
if (jCtx.getError() != null) {
throw new SemanticException(SemanticAnalyzer.generateErrorMessage(jCtx.getErrorSrcNode(),
jCtx.getError()));
}
- ExprNodeDesc joinCondnExprNode = exprNodes.get(joinCond);
- List<RelNode> inputRels = new ArrayList<RelNode>();
- inputRels.add(leftRel);
- inputRels.add(rightRel);
- calciteJoinCond = RexNodeConverter.convert(cluster, joinCondnExprNode, inputRels,
- relToHiveRR, relToHiveColNameCalcitePosMap, false);
+ calciteJoinCond = exprNodes.get(joinCond);
} else {
calciteJoinCond = cluster.getRexBuilder().makeLiteral(true);
}
@@ -2802,8 +2815,13 @@ public class CalcitePlanner extends SemanticAnalyzer {
RexUtil.composeConjunction(cluster.getRexBuilder(),
ImmutableList.of(remainingEquiCond, nonEquiConds), false) :
nonEquiConds;
+ final RelDataType combinedRowType = SqlValidatorUtil.createJoinType(
+ cluster.getTypeFactory(), inputRels[0].getRowType(), inputRels[1].getRowType(),
+ null, ImmutableList.of());
topRel = HiveSemiJoin.getSemiJoin(cluster, cluster.traitSetOf(HiveRelNode.CONVENTION),
- inputRels[0], inputRels[1], calciteJoinCond);
+ inputRels[0], inputRels[1],
+ HiveCalciteUtil.fixNullability(cluster.getRexBuilder(),
+ calciteJoinCond, RelOptUtil.getFieldTypeList(combinedRowType)));
// Create join RR: we need to check whether we need to update left RR in case
// previous call to projectNonColumnEquiConditions updated it
@@ -2845,7 +2863,14 @@ public class CalcitePlanner extends SemanticAnalyzer {
LOG.warn("Duplicates detected when adding columns to RR: see previous message");
}
} else {
- topRel = HiveJoin.getJoin(cluster, leftRel, rightRel, calciteJoinCond, calciteJoinType);
+ final RelDataType combinedRowType = SqlValidatorUtil.createJoinType(
+ cluster.getTypeFactory(), leftRel.getRowType(), rightRel.getRowType(),
+ null, ImmutableList.of());
+ topRel = HiveJoin.getJoin(
+ cluster, leftRel, rightRel,
+ HiveCalciteUtil.fixNullability(cluster.getRexBuilder(),
+ calciteJoinCond, RelOptUtil.getFieldTypeList(combinedRowType)),
+ calciteJoinType);
topRR = RowResolver.getCombinedRR(leftRR, rightRR);
if (namedColumns != null) {
List<String> tableAliases = new ArrayList<>();
@@ -3235,13 +3260,13 @@ public class CalcitePlanner extends SemanticAnalyzer {
return TableType.NATIVE;
}
- private RelNode genFilterRelNode(ASTNode filterExpr, RelNode srcRel,
+ private RelNode genFilterRelNode(ASTNode filterNode, RelNode srcRel,
ImmutableMap<String, Integer> outerNameToPosMap, RowResolver outerRR,
boolean useCaching) throws SemanticException {
- ExprNodeDesc filterCondn = genExprNodeDesc(filterExpr, relToHiveRR.get(srcRel),
- outerRR, null, useCaching);
- if (filterCondn instanceof ExprNodeConstantDesc
- && !filterCondn.getTypeString().equals(serdeConstants.BOOLEAN_TYPE_NAME)) {
+ RexNode filterExpression = genRexNode(filterNode, relToHiveRR.get(srcRel),
+ outerRR, null, useCaching, cluster.getRexBuilder());
+ if (RexUtil.isLiteral(filterExpression, false)
+ && filterExpression.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) {
// queries like select * from t1 where 'foo';
// Calcite's rule PushFilterThroughProject chokes on it. Arguably, we
// can insert a cast to
@@ -3252,16 +3277,16 @@ public class CalcitePlanner extends SemanticAnalyzer {
throw new CalciteSemanticException("Filter expression with non-boolean return type.",
UnsupportedFeature.Filter_expression_with_non_boolean_return_type);
}
- ImmutableMap<String, Integer> hiveColNameCalcitePosMap = this.relToHiveColNameCalcitePosMap
- .get(srcRel);
- RexNode convertedFilterExpr = new RexNodeConverter(cluster, srcRel.getRowType(),
- outerNameToPosMap, hiveColNameCalcitePosMap, relToHiveRR.get(srcRel), outerRR,
- HiveConf.getIntVar(conf, HiveConf.ConfVars.HIVEOPT_TRANSFORM_IN_MAXNODES),
- 0, true, subqueryId).convert(filterCondn);
- RexNode factoredFilterExpr = RexUtil
- .pullFactors(cluster.getRexBuilder(), convertedFilterExpr);
- RelNode filterRel = new HiveFilter(cluster, cluster.traitSetOf(HiveRelNode.CONVENTION),
- srcRel, factoredFilterExpr);
+ final ImmutableMap<String, Integer> hiveColNameCalcitePosMap =
+ this.relToHiveColNameCalcitePosMap.get(srcRel);
+ filterExpression = new CorrelationConverter(
+ new InputContext(srcRel.getRowType(), hiveColNameCalcitePosMap, relToHiveRR.get(srcRel)),
+ outerNameToPosMap, outerRR, subqueryId).apply(filterExpression);
+ RexNode factoredFilterExpression = RexUtil
+ .pullFactors(cluster.getRexBuilder(), filterExpression);
+ RelNode filterRel = new HiveFilter(cluster, cluster.traitSetOf(HiveRelNode.CONVENTION), srcRel,
+ HiveCalciteUtil.fixNullability(cluster.getRexBuilder(),
+ factoredFilterExpression, RelOptUtil.getFieldTypeList(srcRel.getRowType())));
this.relToHiveColNameCalcitePosMap.put(filterRel, hiveColNameCalcitePosMap);
relToHiveRR.put(filterRel, relToHiveRR.get(srcRel));
relToHiveColNameCalcitePosMap.put(filterRel, hiveColNameCalcitePosMap);
@@ -3269,6 +3294,60 @@ public class CalcitePlanner extends SemanticAnalyzer {
return filterRel;
}
+ /**
+ * Shuttle that replaces certain references with correlation variables
+ * if needed.
+ */
+ private class CorrelationConverter extends RexShuttle {
+ private final InputContext inputContext;
+ private final ImmutableMap<Integer, String> outerPositionToColumnName;
+ private final RowResolver outerRowResolver;
+ private final int correlatedId;
+
+ private CorrelationConverter(InputContext inputContext,
+ ImmutableMap<String, Integer> outerColumnNameToPosition, RowResolver outerRowResolver,
+ int correlatedId) {
+ this.inputContext = inputContext;
+ this.outerPositionToColumnName = outerColumnNameToPosition == null ?
+ null : ImmutableBiMap.copyOf(outerColumnNameToPosition).inverse();
+ this.outerRowResolver = outerRowResolver;
+ this.correlatedId = correlatedId;
+ }
+
+ @Override
+ public RexNode visitInputRef(RexInputRef col) {
+ InputContext context = null;
+ if (inputContext.inputRowResolver == null) {
+ context = inputContext;
+ } else {
+ int index = col.getIndex();
+ String colName = inputContext.positionToColumnName.get(index);
+ if (colName != null) {
+ context = inputContext;
+ }
+ }
+
+ if(context == null) {
+ // we have correlated column, build data type from outer rr
+ RelDataType rowType;
+ try {
+ rowType = TypeConverter.getType(cluster, outerRowResolver, null);
+ } catch (CalciteSemanticException e) {
+ throw new RuntimeException("Error converting type", e);
+ }
+ int index = col.getIndex() - inputContext.inputRowType.getFieldList().size();
+ if (outerPositionToColumnName.get(index) == null) {
+ throw new RuntimeException(ErrorMsg.INVALID_COLUMN_NAME.getMsg());
+ }
+ CorrelationId colCorr = new CorrelationId(correlatedId);
+ RexNode corExpr = cluster.getRexBuilder().makeCorrel(rowType, colCorr);
+ return cluster.getRexBuilder().makeFieldAccess(corExpr, index);
+ }
+ int pos = col.getIndex();
+ return cluster.getRexBuilder().makeInputRef(
+ context.inputRowType.getFieldList().get(pos).getType(), pos);
+ }
+ }
private RelNode genLateralViewPlans(ASTNode lateralView, Map<String, RelNode> aliasToRel)
throws SemanticException {
@@ -3324,19 +3403,18 @@ public class CalcitePlanner extends SemanticAnalyzer {
// Output types. They will be the concatenation of the input refs types and
// the types of the expressions for the lateral view generated rows
// Generate all expressions from lateral view
- ExprNodeDesc valuesExpr = genExprNodeDesc(valuesClause, inputRR, false, false);
- RexCall convertedOriginalValuesExpr = (RexCall) new RexNodeConverter(this.cluster, inputRel.getRowType(),
- inputPosMap, 0, false).convert(valuesExpr);
- RelDataType valuesRowType = ((ArraySqlType) convertedOriginalValuesExpr.getType()).getComponentType();
+ RexCall valuesExpr = (RexCall) genRexNode(
+ valuesClause, inputRR, false, false, cluster.getRexBuilder());
+ RelDataType valuesRowType = valuesExpr.getType().getComponentType();
List<RexNode> newStructExprs = new ArrayList<>();
- for (RexNode structExpr : convertedOriginalValuesExpr.getOperands()) {
+ for (RexNode structExpr : valuesExpr.getOperands()) {
RexCall structCall = (RexCall) structExpr;
List<RexNode> exprs = new ArrayList<>(inputRefs);
exprs.addAll(structCall.getOperands());
newStructExprs.add(rexBuilder.makeCall(structCall.op, exprs));
}
RexNode convertedFinalValuesExpr =
- rexBuilder.makeCall(convertedOriginalValuesExpr.op, newStructExprs);
+ rexBuilder.makeCall(valuesExpr.op, newStructExprs);
// The return type will be the concatenation of input type and original values type
RelDataType retType = SqlValidatorUtil.deriveJoinRowType(inputRel.getRowType(),
valuesRowType, JoinRelType.INNER, dtFactory, null, ImmutableList.of());
@@ -3394,7 +3472,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
columnAliases.add(SemanticAnalyzer.getColumnInternalName(i));
}
}
- ListTypeInfo listTypeInfo = (ListTypeInfo) valuesExpr.getTypeInfo(); // Array should have ListTypeInfo
+ ListTypeInfo listTypeInfo = (ListTypeInfo) TypeConverter.convert(valuesExpr.getType()); // Array should have ListTypeInfo
StructTypeInfo typeInfos = (StructTypeInfo) listTypeInfo.getListElementTypeInfo(); // Within the list, we extract types
for (int i = 0, j = 0; i < columnAliases.size(); i++) {
String internalColName;
@@ -3470,26 +3548,21 @@ public class CalcitePlanner extends SemanticAnalyzer {
private RelNode genFilterRelNode(QB qb, ASTNode searchCond, RelNode srcRel,
ImmutableMap<String, Integer> outerNameToPosMap, RowResolver outerRR, boolean forHavingClause)
throws SemanticException {
-
- Map<ASTNode, RelNode> subQueryToRelNode = new HashMap<>();
- boolean isSubQuery = genSubQueryRelNode(qb, searchCond, srcRel, forHavingClause,
- subQueryToRelNode);
+ final Map<ASTNode, RelNode> subQueryToRelNode = new HashMap<>();
+ boolean isSubQuery = genSubQueryRelNode(qb, searchCond, srcRel, forHavingClause, subQueryToRelNode);
if(isSubQuery) {
- ExprNodeDesc subQueryExpr = genExprNodeDesc(searchCond, relToHiveRR.get(srcRel),
- outerRR, subQueryToRelNode, forHavingClause);
+ RexNode filterExpression = genRexNode(searchCond, relToHiveRR.get(srcRel),
+ outerRR, subQueryToRelNode, forHavingClause, cluster.getRexBuilder());
ImmutableMap<String, Integer> hiveColNameCalcitePosMap = this.relToHiveColNameCalcitePosMap
- .get(srcRel);
- RexNode convertedFilterLHS = new RexNodeConverter(cluster, srcRel.getRowType(),
- outerNameToPosMap, hiveColNameCalcitePosMap, relToHiveRR.get(srcRel),
- outerRR, HiveConf.getIntVar(conf, HiveConf.ConfVars.HIVEOPT_TRANSFORM_IN_MAXNODES),
- 0, true, subqueryId).convert(subQueryExpr);
+ .get(srcRel);
+ filterExpression = new CorrelationConverter(
+ new InputContext(srcRel.getRowType(), hiveColNameCalcitePosMap, relToHiveRR.get(srcRel)),
+ outerNameToPosMap, outerRR, subqueryId).apply(filterExpression);
RelNode filterRel = new HiveFilter(cluster, cluster.traitSetOf(HiveRelNode.CONVENTION),
- srcRel, convertedFilterLHS);
-
- this.relToHiveColNameCalcitePosMap.put(filterRel, this.relToHiveColNameCalcitePosMap
- .get(srcRel));
+ srcRel, filterExpression);
+ relToHiveColNameCalcitePosMap.put(filterRel, relToHiveColNameCalcitePosMap.get(srcRel));
relToHiveRR.put(filterRel, relToHiveRR.get(srcRel));
return filterRel;
} else {
@@ -3511,42 +3584,17 @@ public class CalcitePlanner extends SemanticAnalyzer {
return filterRel;
}
- /**
- * Class to store GenericUDAF related information.
- */
- private class AggInfo {
- private final List<ExprNodeDesc> m_aggParams;
- private final TypeInfo m_returnType;
- private final String m_udfName;
- private final boolean m_distinct;
-
- private AggInfo(List<ExprNodeDesc> aggParams, TypeInfo returnType, String udfName,
- boolean isDistinct) {
- m_aggParams = aggParams;
- m_returnType = returnType;
- m_udfName = udfName;
- m_distinct = isDistinct;
- }
- }
-
- private AggregateCall convertGBAgg(AggInfo agg, List<RexNode> gbChildProjLst, RexNodeConverter converter,
+ private AggregateCall convertGBAgg(AggregateInfo agg, List<RexNode> gbChildProjLst,
HashMap<String, Integer> rexNodeToPosMap, Integer childProjLstIndx) throws SemanticException {
-
// 1. Get agg fn ret type in Calcite
- RelDataType aggFnRetType = TypeConverter.convert(agg.m_returnType,
+ RelDataType aggFnRetType = TypeConverter.convert(agg.getReturnType(),
this.cluster.getTypeFactory());
// 2. Convert Agg Fn args and type of args to Calcite
- // TODO: Does HQL allows expressions as aggregate args or can it only be
- // projections from child?
- Integer inputIndx;
- List<Integer> argList = new ArrayList<Integer>();
- RexNode rexNd = null;
- RelDataTypeFactory dtFactory = this.cluster.getTypeFactory();
- ImmutableList.Builder<RelDataType> aggArgRelDTBldr = new ImmutableList.Builder<RelDataType>();
- for (ExprNodeDesc expr : agg.m_aggParams) {
- rexNd = converter.convert(expr);
- inputIndx = rexNodeToPosMap.get(rexNd.toString());
+ List<Integer> argList = new ArrayList<>();
+ ImmutableList.Builder<RelDataType> aggArgRelDTBldr = ImmutableList.builder();
+ for (RexNode rexNd : agg.getParameters()) {
+ Integer inputIndx = rexNodeToPosMap.get(rexNd.toString());
if (inputIndx == null) {
gbChildProjLst.add(rexNd);
rexNodeToPosMap.put(rexNd.toString(), childProjLstIndx);
@@ -3555,35 +3603,28 @@ public class CalcitePlanner extends SemanticAnalyzer {
}
argList.add(inputIndx);
- // TODO: does arg need type cast?
- aggArgRelDTBldr.add(TypeConverter.convert(expr.getTypeInfo(), dtFactory));
+ aggArgRelDTBldr.add(rexNd.getType());
}
// 3. Get Aggregation FN from Calcite given name, ret type and input arg
// type
- final SqlAggFunction aggregation = SqlFunctionConverter.getCalciteAggFn(agg.m_udfName, agg.m_distinct,
+ final SqlAggFunction aggregation = SqlFunctionConverter.getCalciteAggFn(agg.getAggregateName(), agg.isDistinct(),
aggArgRelDTBldr.build(), aggFnRetType);
- return new AggregateCall(aggregation, agg.m_distinct, argList, aggFnRetType, null);
+ return new AggregateCall(aggregation, agg.isDistinct(), argList, aggFnRetType, null);
}
- private RelNode genGBRelNode(List<ExprNodeDesc> gbExprs, List<AggInfo> aggInfoLst,
+ private RelNode genGBRelNode(List<RexNode> gbExprs, List<AggregateInfo> aggInfoLst,
List<Long> groupSets, RelNode srcRel) throws SemanticException {
- ImmutableMap<String, Integer> posMap = this.relToHiveColNameCalcitePosMap.get(srcRel);
- RexNodeConverter converter = new RexNodeConverter(this.cluster, srcRel.getRowType(), posMap,
- 0, false);
-
final boolean hasGroupSets = groupSets != null && !groupSets.isEmpty();
final List<RexNode> gbChildProjLst = Lists.newArrayList();
- final HashMap<String, Integer> rexNodeToPosMap = new HashMap<String, Integer>();
+ final HashMap<String, Integer> rexNodeToPosMap = new HashMap<>();
final List<Integer> groupSetPositions = Lists.newArrayList();
Integer gbIndx = 0;
- RexNode rnd;
- for (ExprNodeDesc key : gbExprs) {
- rnd = converter.convert(key);
- gbChildProjLst.add(rnd);
+ for (RexNode gbExpr : gbExprs) {
+ gbChildProjLst.add(gbExpr);
groupSetPositions.add(gbIndx);
- rexNodeToPosMap.put(rnd.toString(), gbIndx);
+ rexNodeToPosMap.put(gbExpr.toString(), gbIndx);
gbIndx++;
}
final ImmutableBitSet groupSet = ImmutableBitSet.of(groupSetPositions);
@@ -3593,19 +3634,19 @@ public class CalcitePlanner extends SemanticAnalyzer {
List<ImmutableBitSet> transformedGroupSets = null;
if(hasGroupSets) {
Set<ImmutableBitSet> setTransformedGroupSets =
- new HashSet<ImmutableBitSet>(groupSets.size());
+ new HashSet<>(groupSets.size());
for(long val: groupSets) {
setTransformedGroupSets.add(convert(val, groupSet.cardinality()));
}
// Calcite expects the grouping sets sorted and without duplicates
- transformedGroupSets = new ArrayList<ImmutableBitSet>(setTransformedGroupSets);
+ transformedGroupSets = new ArrayList<>(setTransformedGroupSets);
Collections.sort(transformedGroupSets, ImmutableBitSet.COMPARATOR);
}
List<AggregateCall> aggregateCalls = Lists.newArrayList();
- for (AggInfo agg : aggInfoLst) {
- aggregateCalls.add(convertGBAgg(agg, gbChildProjLst, converter, rexNodeToPosMap,
- gbChildProjLst.size()));
+ for (AggregateInfo agg : aggInfoLst) {
+ aggregateCalls.add(
+ convertGBAgg(agg, gbChildProjLst, rexNodeToPosMap, gbChildProjLst.size()));
}
if (hasGroupSets) {
// Create GroupingID column
@@ -3621,7 +3662,12 @@ public class CalcitePlanner extends SemanticAnalyzer {
// first element from srcRel
gbChildProjLst.add(this.cluster.getRexBuilder().makeInputRef(srcRel, 0));
}
- RelNode gbInputRel = HiveProject.create(srcRel, gbChildProjLst, null);
+
+ // Create input project fixing up nullability of inputs
+ RelNode gbInputRel = HiveProject.create(
+ srcRel,
+ HiveCalciteUtil.fixNullability(cluster.getRexBuilder(), gbChildProjLst, RelOptUtil.getFieldTypeList(srcRel.getRowType())),
+ null);
HiveRelNode aggregateRel = new HiveAggregate(cluster, cluster.traitSetOf(HiveRelNode.CONVENTION),
gbInputRel, groupSet, transformedGroupSets, aggregateCalls);
@@ -3673,120 +3719,59 @@ public class CalcitePlanner extends SemanticAnalyzer {
}
private void addToGBExpr(RowResolver groupByOutputRowResolver,
- RowResolver groupByInputRowResolver, ASTNode grpbyExpr, ExprNodeDesc grpbyExprNDesc,
- List<ExprNodeDesc> gbExprNDescLst, List<String> outputColumnNames) {
- // TODO: Should we use grpbyExprNDesc.getTypeInfo()? what if expr is
- // UDF
+ RowResolver groupByInputRowResolver, ASTNode grpbyExpr, RexNode grpbyExprNDesc,
+ List<RexNode> gbExprNDescLst, List<String> outputColumnNames) {
int i = gbExprNDescLst.size();
String field = SemanticAnalyzer.getColumnInternalName(i);
outputColumnNames.add(field);
gbExprNDescLst.add(grpbyExprNDesc);
- ColumnInfo oColInfo = new ColumnInfo(field, grpbyExprNDesc.getTypeInfo(), null, false);
+ ColumnInfo oColInfo = new ColumnInfo(field, TypeConverter.convert(grpbyExprNDesc.getType()), null, false);
groupByOutputRowResolver.putExpression(grpbyExpr, oColInfo);
addAlternateGByKeyMappings(grpbyExpr, oColInfo, groupByInputRowResolver,
groupByOutputRowResolver);
}
- private AggInfo getHiveAggInfo(ASTNode aggAst, int aggFnLstArgIndx, RowResolver inputRR)
+ private AggregateInfo getHiveAggInfo(ASTNode aggAst, int aggFnLstArgIndx, RowResolver inputRR)
throws SemanticException {
- AggInfo aInfo = null;
-
- // 1 Convert UDAF Params to ExprNodeDesc
- ArrayList<ExprNodeDesc> aggParameters = new ArrayList<ExprNodeDesc>();
+ List<RexNode> aggParameters = new ArrayList<>();
for (int i = 1; i <= aggFnLstArgIndx; i++) {
- ASTNode paraExpr = (ASTNode) aggAst.getChild(i);
- ExprNodeDesc paraExprNode = genExprNodeDesc(paraExpr, inputRR);
- aggParameters.add(paraExprNode);
+ RexNode parameterExpr = genRexNode(
+ (ASTNode) aggAst.getChild(i), inputRR, cluster.getRexBuilder());
+ aggParameters.add(parameterExpr);
}
-
- // 2. Is this distinct UDAF
boolean isDistinct = aggAst.getType() == HiveParser.TOK_FUNCTIONDI;
-
- // 3. Determine type of UDAF
- TypeInfo udafRetType = null;
-
- // 3.1 Obtain UDAF name
+ boolean isAllColumns = aggAst.getType() == HiveParser.TOK_FUNCTIONSTAR;
String aggName = unescapeIdentifier(aggAst.getChild(0).getText());
- // 3.2 Rank functions type is 'int'/'double'
- if (FunctionRegistry.isRankingFunction(aggName)) {
- if (aggName.equalsIgnoreCase("percent_rank")) {
- udafRetType = TypeInfoFactory.doubleTypeInfo;
- } else {
- udafRetType = TypeInfoFactory.intTypeInfo;
- }
- } else {
- // 3.3 Try obtaining UDAF evaluators to determine the ret type
- try {
- boolean isAllColumns = aggAst.getType() == HiveParser.TOK_FUNCTIONSTAR;
-
- // 3.3.1 Get UDAF Evaluator
- Mode amode = SemanticAnalyzer.groupByDescModeToUDAFMode(GroupByDesc.Mode.COMPLETE,
- isDistinct);
-
- GenericUDAFEvaluator genericUDAFEvaluator = null;
- if (aggName.toLowerCase().equals(FunctionRegistry.LEAD_FUNC_NAME)
- || aggName.toLowerCase().equals(FunctionRegistry.LAG_FUNC_NAME)) {
- List<ObjectInspector> originalParameterTypeInfos = SemanticAnalyzer
- .getWritableObjectInspector(aggParameters);
- genericUDAFEvaluator = FunctionRegistry.getGenericWindowingEvaluator(aggName,
- originalParameterTypeInfos, isDistinct, isAllColumns);
- GenericUDAFInfo udaf = SemanticAnalyzer.getGenericUDAFInfo(genericUDAFEvaluator, amode,
- aggParameters);
- udafRetType = ((ListTypeInfo) udaf.returnType).getListElementTypeInfo();
- } else {
- genericUDAFEvaluator = SemanticAnalyzer.getGenericUDAFEvaluator(aggName, aggParameters,
- aggAst, isDistinct, isAllColumns);
- assert (genericUDAFEvaluator != null);
-
- // 3.3.2 Get UDAF Info using UDAF Evaluator
- GenericUDAFInfo udaf = SemanticAnalyzer.getGenericUDAFInfo(genericUDAFEvaluator, amode,
- aggParameters);
- if (FunctionRegistry.pivotResult(aggName)) {
- udafRetType = ((ListTypeInfo)udaf.returnType).getListElementTypeInfo();
- } else {
- udafRetType = udaf.returnType;
- }
- }
- } catch (Exception e) {
- LOG.debug("CBO: Couldn't Obtain UDAF evaluators for " + aggName
- + ", trying to translate to GenericUDF");
- }
+ AggregateInfo aInfo = functionHelper.getWindowAggregateFunctionInfo(
+ isDistinct, isAllColumns, aggName, aggParameters);
- // 3.4 Try GenericUDF translation
- if (udafRetType == null) {
- TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR);
- // We allow stateful functions in the SELECT list (but nowhere else)
- tcCtx.setAllowStatefulFunctions(true);
- tcCtx.setAllowDistinctFunctions(false);
- ExprNodeDesc exp = genExprNodeDesc((ASTNode) aggAst.getChild(0), inputRR, tcCtx);
- udafRetType = exp.getTypeInfo();
- }
+ // If that did not work, try GenericUDF translation
+ if (aInfo == null) {
+ TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR, cluster.getRexBuilder());
+ // We allow stateful functions in the SELECT list (but nowhere else)
+ tcCtx.setAllowStatefulFunctions(true);
+ tcCtx.setAllowDistinctFunctions(false);
+ RexNode exp = genRexNode((ASTNode) aggAst.getChild(0), inputRR, tcCtx);
+ aInfo = new AggregateInfo(
+ aggParameters, TypeConverter.convert(exp.getType()), aggName, isDistinct);
}
- // 4. Construct AggInfo
- aInfo = new AggInfo(aggParameters, udafRetType, aggName, isDistinct);
-
return aInfo;
}
/**
- * Generate GB plan.
- *
- * @param qb
- * @param srcRel
- * @return TODO: 1. Grouping Sets (roll up..)
- * @throws SemanticException
+ * Generate a group by plan.
*/
private RelNode genGBLogicalPlan(QB qb, RelNode srcRel) throws SemanticException {
- RelNode gbRel = null;
+ RelNode groupByRel = null;
QBParseInfo qbp = getQBParseInfo(qb);
// 1. Gather GB Expressions (AST) (GB + Aggregations)
// NOTE: Multi Insert is not supported
- String detsClauseName = qbp.getClauseNames().iterator().next();
+ String destClauseName = qbp.getClauseNames().iterator().next();
// Check and transform group by *. This will only happen for select distinct *.
// Here the "genSelectPlan" is being leveraged.
// The main benefits are (1) remove virtual columns that should
@@ -3794,7 +3779,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
// so that view is supported. The drawback is that an additional SEL op is added. If it is
// not necessary, it will be removed by NonBlockingOpDeDupProc Optimizer because it will match
// SEL%SEL% rule.
- ASTNode selExprList = qb.getParseInfo().getSelForClause(detsClauseName);
+ ASTNode selExprList = qb.getParseInfo().getSelForClause(destClauseName);
SubQueryUtils.checkForTopLevelSubqueries(selExprList);
if (selExprList.getToken().getType() == HiveParser.TOK_SELECTDI
&& selExprList.getChildCount() == 1 && selExprList.getChild(0).getChildCount() == 1) {
@@ -3802,8 +3787,8 @@ public class CalcitePlanner extends SemanticAnalyzer {
if (node.getToken().getType() == HiveParser.TOK_ALLCOLREF) {
// As we said before, here we use genSelectLogicalPlan to rewrite AllColRef
srcRel = genSelectLogicalPlan(qb, srcRel, srcRel, null, null, true).getKey();
- RowResolver rr = this.relToHiveRR.get(srcRel);
- qbp.setSelExprForClause(detsClauseName, genSelectDIAST(rr));
+ RowResolver rr = relToHiveRR.get(srcRel);
+ qbp.setSelExprForClause(destClauseName, genSelectDIAST(rr));
}
}
@@ -3813,18 +3798,17 @@ public class CalcitePlanner extends SemanticAnalyzer {
return null;
}
- List<ASTNode> grpByAstExprs = getGroupByForClause(qbp, detsClauseName);
- Map<String, ASTNode> aggregationTrees = qbp.getAggregationExprsForClause(detsClauseName);
- boolean hasGrpByAstExprs = (grpByAstExprs != null && !grpByAstExprs.isEmpty()) ? true : false;
- boolean hasAggregationTrees = (aggregationTrees != null && !aggregationTrees.isEmpty()) ? true
- : false;
+ List<ASTNode> groupByNodes = getGroupByForClause(qbp, destClauseName);
+ Map<String, ASTNode> aggregationTrees = qbp.getAggregationExprsForClause(destClauseName);
+ boolean hasGrpByAstExprs = groupByNodes != null && !groupByNodes.isEmpty();
+ boolean hasAggregationTrees = aggregationTrees != null && !aggregationTrees.isEmpty();
final boolean cubeRollupGrpSetPresent = (!qbp.getDestRollups().isEmpty()
|| !qbp.getDestGroupingSets().isEmpty() || !qbp.getDestCubes().isEmpty());
// 2. Sanity check
if (conf.getBoolVar(HiveConf.ConfVars.HIVEGROUPBYSKEW)
- && qbp.getDistinctFuncExprsForClause(detsClauseName).size() > 1) {
+ && qbp.getDistinctFuncExprsForClause(destClauseName).size() > 1) {
throw new SemanticException(ErrorMsg.UNSUPPORTED_MULTIPLE_DISTINCTS.getMsg());
}
if (cubeRollupGrpSetPresent) {
@@ -3833,9 +3817,9 @@ public class CalcitePlanner extends SemanticAnalyzer {
}
if (conf.getBoolVar(HiveConf.ConfVars.HIVEGROUPBYSKEW)) {
- checkExpressionsForGroupingSet(grpByAstExprs, qb.getParseInfo()
- .getDistinctFuncExprsForClause(detsClauseName), aggregationTrees,
- this.relToHiveRR.get(srcRel));
+ checkExpressionsForGroupingSet(groupByNodes,
+ qb.getParseInfo().getDistinctFuncExprsForClause(destClauseName),
+ aggregationTrees, relToHiveRR.get(srcRel));
if (qbp.getDestGroupingSets().size() > conf
.getIntVar(HiveConf.ConfVars.HIVE_NEW_JOB_GROUPING_SET_CARDINALITY)) {
@@ -3847,10 +3831,9 @@ public class CalcitePlanner extends SemanticAnalyzer {
}
}
-
if (hasGrpByAstExprs || hasAggregationTrees) {
- ArrayList<ExprNodeDesc> gbExprNDescLst = new ArrayList<ExprNodeDesc>();
- ArrayList<String> outputColumnNames = new ArrayList<String>();
+ List<RexNode> groupByExpressions = new ArrayList<>();
+ List<String> outputColumnNames = new ArrayList<>();
// 3. Input, Output Row Resolvers
RowResolver groupByInputRowResolver = this.relToHiveRR.get(srcRel);
@@ -3859,29 +3842,30 @@ public class CalcitePlanner extends SemanticAnalyzer {
if (hasGrpByAstExprs) {
// 4. Construct GB Keys (ExprNode)
- for (int i = 0; i < grpByAstExprs.size(); ++i) {
- ASTNode grpbyExpr = grpByAstExprs.get(i);
- Map<ASTNode, ExprNodeDesc> astToExprNDescMap = genAllExprNodeDesc(grpbyExpr, groupByInputRowResolver);
- ExprNodeDesc grpbyExprNDesc = astToExprNDescMap.get(grpbyExpr);
- if (grpbyExprNDesc == null) {
- throw new CalciteSemanticException("Invalid Column Reference: " + grpbyExpr.dump(),
+ for (int i = 0; i < groupByNodes.size(); ++i) {
+ ASTNode groupByNode = groupByNodes.get(i);
+ Map<ASTNode, RexNode> astToRexNodeMap = genAllRexNode(
+ groupByNode, groupByInputRowResolver, cluster.getRexBuilder());
+ RexNode groupByExpression = astToRexNodeMap.get(groupByNode);
+ if (groupByExpression == null) {
+ throw new CalciteSemanticException("Invalid Column Reference: " + groupByNode.dump(),
UnsupportedFeature.Invalid_column_reference);
}
- addToGBExpr(groupByOutputRowResolver, groupByInputRowResolver, grpbyExpr,
- grpbyExprNDesc, gbExprNDescLst, outputColumnNames);
+ addToGBExpr(groupByOutputRowResolver, groupByInputRowResolver, groupByNode,
+ groupByExpression, groupByExpressions, outputColumnNames);
}
}
// 5. GroupingSets, Cube, Rollup
- int groupingColsSize = gbExprNDescLst.size();
+ int groupingColsSize = groupByExpressions.size();
List<Long> groupingSets = null;
if (cubeRollupGrpSetPresent) {
- groupingSets = getGroupByGroupingSetsForClause(qbp, detsClauseName).getRight();
+ groupingSets = getGroupByGroupingSetsForClause(qbp, destClauseName).getRight();
}
// 6. Construct aggregation function Info
- ArrayList<AggInfo> aggregations = new ArrayList<AggInfo>();
+ ArrayList<AggregateInfo> aggregations = new ArrayList<AggregateInfo>();
if (hasAggregationTrees) {
assert (aggregationTrees != null);
for (ASTNode value : aggregationTrees.values()) {
@@ -3892,26 +3876,20 @@ public class CalcitePlanner extends SemanticAnalyzer {
boolean isAllColumns = value.getType() == HiveParser.TOK_FUNCTIONSTAR;
// 6.2 Convert UDAF Params to ExprNodeDesc
- ArrayList<ExprNodeDesc> aggParameters = new ArrayList<ExprNodeDesc>();
+ List<RexNode> aggParameters = new ArrayList<>();
for (int i = 1; i < value.getChildCount(); i++) {
- ASTNode paraExpr = (ASTNode) value.getChild(i);
- ExprNodeDesc paraExprNode = genExprNodeDesc(paraExpr, groupByInputRowResolver);
- aggParameters.add(paraExprNode);
+ RexNode parameterExpr = genRexNode(
+ (ASTNode) value.getChild(i), groupByInputRowResolver, cluster.getRexBuilder());
+ aggParameters.add(parameterExpr);
}
- Mode amode = SemanticAnalyzer.groupByDescModeToUDAFMode(GroupByDesc.Mode.COMPLETE,
- isDistinct);
- GenericUDAFEvaluator genericUDAFEvaluator = SemanticAnalyzer.getGenericUDAFEvaluator(
- aggName, aggParameters, value, isDistinct, isAllColumns);
- assert (genericUDAFEvaluator != null);
- GenericUDAFInfo udaf = SemanticAnalyzer.getGenericUDAFInfo(genericUDAFEvaluator, amode,
- aggParameters);
- AggInfo aInfo = new AggInfo(aggParameters, udaf.returnType, aggName, isDistinct);
+ AggregateInfo aInfo = functionHelper.getAggregateFunctionInfo(
+ isDistinct, isAllColumns, aggName, aggParameters);
aggregations.add(aInfo);
String field = getColumnInternalName(groupingColsSize + aggregations.size() - 1);
outputColumnNames.add(field);
- groupByOutputRowResolver.putExpression(value, new ColumnInfo(field, aInfo.m_returnType,
- "", false));
+ groupByOutputRowResolver.putExpression(value,
+ new ColumnInfo(field, aInfo.getReturnType(), "", false));
}
}
@@ -3928,12 +3906,12 @@ public class CalcitePlanner extends SemanticAnalyzer {
}
// 8. We create the group_by operator
- gbRel = genGBRelNode(gbExprNDescLst, aggregations, groupingSets, srcRel);
- relToHiveColNameCalcitePosMap.put(gbRel, buildHiveToCalciteColumnMap(groupByOutputRowResolver));
- this.relToHiveRR.put(gbRel, groupByOutputRowResolver);
+ groupByRel = genGBRelNode(groupByExpressions, aggregations, groupingSets, srcRel);
+ relToHiveColNameCalcitePosMap.put(groupByRel, buildHiveToCalciteColumnMap(groupByOutputRowResolver));
+ relToHiveRR.put(groupByRel, groupByOutputRowResolver);
}
- return gbRel;
+ return groupByRel;
}
/**
@@ -3948,8 +3926,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
* @throws SemanticException
*/
private RelNode genOBLogicalPlan(QB qb, Pair<RelNode, RowResolver> selPair,
- boolean outermostOB) throws SemanticException {
-
+ boolean outermostOB) throws SemanticException {
QBParseInfo qbp = getQBParseInfo(qb);
String dest = qbp.getClauseNames().iterator().next();
ASTNode obAST = qbp.getOrderByForClause(dest);
@@ -3982,8 +3959,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
}
private RelNode genSBLogicalPlan(QB qb, Pair<RelNode, RowResolver> selPair,
- boolean outermostOB) throws SemanticException {
-
+ boolean outermostOB) throws SemanticException {
QBParseInfo qbp = getQBParseInfo(qb);
String dest = qbp.getClauseNames().iterator().next();
ASTNode sbAST = qbp.getSortByForClause(dest);
@@ -4023,7 +3999,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
// - Add Child Project Rel if needed,
// - Generate Output RR, input Sel Rel for top constraining Sel
private OBLogicalPlanGenState beginGenOBLogicalPlan(
- ASTNode obAST, Pair<RelNode, RowResolver> selPair, boolean outermostOB) throws SemanticException {
+ ASTNode obAST, Pair<RelNode, RowResolver> selPair, boolean outermostOB) throws SemanticException {
// selPair.getKey() is the operator right before OB
// selPair.getValue() is RR which only contains columns needed in result
// set. Extra columns needed by order by will be absent from it.
@@ -4041,15 +4017,12 @@ public class CalcitePlanner extends SemanticAnalyzer {
RowResolver inputRR = relToHiveRR.get(srcRel);
RowResolver outputRR = new RowResolver();
- RexNode rnd;
- RexNodeConverter converter = new RexNodeConverter(cluster, srcRel.getRowType(),
- relToHiveColNameCalcitePosMap.get(srcRel), 0, false);
int srcRelRecordSz = srcRel.getRowType().getFieldCount();
for (int i = 0; i < obASTExprLst.size(); i++) {
// 2.1 Convert AST Expr to ExprNode
- ASTNode obASTExpr = (ASTNode) obASTExprLst.get(i);
- ASTNode nullObASTExpr = (ASTNode) obASTExpr.getChild(0);
+ ASTNode orderByNode = (ASTNode) obASTExprLst.get(i);
+ ASTNode nullObASTExpr = (ASTNode) orderByNode.getChild(0);
ASTNode ref = (ASTNode) nullObASTExpr.getChild(0);
boolean isBothByPos = HiveConf.getBoolVar(conf, ConfVars.HIVE_GROUPBY_ORDERBY_POSITION_ALIAS);
@@ -4066,25 +4039,24 @@ public class CalcitePlanner extends SemanticAnalyzer {
"the position alias will be ignored.");
}
} else {
- ExprNodeDesc obExprNDesc = getOrderByExprNodeDesc(selectOutputRR, inputRR, obASTExpr, ref);
// 2.2 Convert ExprNode to RexNode
- rnd = converter.convert(obExprNDesc);
+ RexNode orderByExpression = getOrderByExpression(selectOutputRR, inputRR, orderByNode, ref);
// 2.3 Determine the index of ob expr in child schema
// NOTE: Calcite can not take compound exprs in OB without it being
// present in the child (& hence we add a child Project Rel)
- if (rnd instanceof RexInputRef) {
- fieldIndex = ((RexInputRef) rnd).getIndex();
+ if (orderByExpression instanceof RexInputRef) {
+ fieldIndex = ((RexInputRef) orderByExpression).getIndex();
} else {
fieldIndex = srcRelRecordSz + newVCLst.size();
- newVCLst.add(rnd);
- vcASTTypePairs.add(new Pair<>(ref, obExprNDesc.getTypeInfo()));
+ newVCLst.add(orderByExpression);
+ vcASTTypePairs.add(new Pair<>(ref, TypeConverter.convert(orderByExpression.getType())));
}
}
// 2.4 Determine the Direction of order by
RelFieldCollation.Direction order = RelFieldCollation.Direction.DESCENDING;
- if (obASTExpr.getType() == HiveParser.TOK_TABSORTCOLNAMEASC) {
+ if (orderByNode.getType() == HiveParser.TOK_TABSORTCOLNAMEASC) {
order = RelFieldCollation.Direction.ASCENDING;
}
RelFieldCollation.NullDirection nullOrder;
@@ -4146,16 +4118,16 @@ public class CalcitePlanner extends SemanticAnalyzer {
return new OBLogicalPlanGenState(obInputRel, fieldCollations, selectOutputRR, outputRR, srcRel);
}
- private ExprNodeDesc getOrderByExprNodeDesc(
- RowResolver selectOutputRR, RowResolver inputRR, ASTNode obASTExpr, ASTNode ref)
- throws SemanticException {
+ private RexNode getOrderByExpression(
+ RowResolver selectOutputRR, RowResolver inputRR, ASTNode orderByNode, ASTNode ref)
+ throws SemanticException {
// first try to get it from select
// in case of udtf, selectOutputRR may be null.
- ExprNodeDesc obExprNDesc = null;
+ RexNode orderByExpression = null;
if (selectOutputRR != null) {
try {
- Map<ASTNode, ExprNodeDesc> astToExprNDescMap = genAllExprNodeDesc(ref, selectOutputRR);
- obExprNDesc = astToExprNDescMap.get(ref);
+ Map<ASTNode, RexNode> astToExprNDescMap = genAllRexNode(ref, selectOutputRR, cluster.getRexBuilder());
+ orderByExpression = astToExprNDescMap.get(ref);
} catch (SemanticException ex) {
// we can tolerate this as this is the previous behavior
LOG.debug("Can not find column in " + ref.getText() + ". The error msg is "
@@ -4163,14 +4135,14 @@ public class CalcitePlanner extends SemanticAnalyzer {
}
}
// then try to get it from all
- if (obExprNDesc == null) {
- Map<ASTNode, ExprNodeDesc> astToExprNDescMap = genAllExprNodeDesc(ref, inputRR);
- obExprNDesc = astToExprNDescMap.get(ref);
+ if (orderByExpression == null) {
+ Map<ASTNode, RexNode> astToExprNDescMap = genAllRexNode(ref, inputRR, cluster.getRexBuilder());
+ orderByExpression = astToExprNDescMap.get(ref);
}
- if (obExprNDesc == null) {
- throw new SemanticException("Invalid order by expression: " + obASTExpr.toString());
+ if (orderByExpression == null) {
+ throw new SemanticException("Invalid order by expression: " + orderByNode.toString());
}
- return obExprNDesc;
+ return orderByExpression;
}
// SELECT a, b FROM t ORDER BY 1
@@ -4249,32 +4221,31 @@ public class CalcitePlanner extends SemanticAnalyzer {
return sortRel;
}
- private List<RexNode> getPartitionKeys(PartitionSpec ps, RexNodeConverter converter,
+ private List<RexNode> getPartitionKeys(PartitionSpec ps,
RowResolver inputRR) throws SemanticException {
- List<RexNode> pKeys = new ArrayList<RexNode>();
+ List<RexNode> pKeys = new ArrayList<>();
if (ps != null) {
List<PartitionExpression> pExprs = ps.getExpressions();
for (PartitionExpression pExpr : pExprs) {
- TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR);
+ TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR, cluster.getRexBuilder());
tcCtx.setAllowStatefulFunctions(true);
- ExprNodeDesc exp = genExprNodeDesc(pExpr.getExpression(), inputRR, tcCtx);
- pKeys.add(converter.convert(exp));
+ RexNode exp = genRexNode(pExpr.getExpression(), inputRR, tcCtx);
+ pKeys.add(exp);
}
}
return pKeys;
}
- private List<RexFieldCollation> getOrderKeys(OrderSpec os, RexNodeConverter converter,
+ private List<RexFieldCollation> getOrderKeys(OrderSpec os,
RowResolver inputRR) throws SemanticException {
- List<RexFieldCollation> oKeys = new ArrayList<RexFieldCollation>();
+ List<RexFieldCollation> oKeys = new ArrayList<>();
if (os != null) {
List<OrderExpression> oExprs = os.getExpressions();
for (OrderExpression oExpr : oExprs) {
- TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR);
+ TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR, cluster.getRexBuilder());
tcCtx.setAllowStatefulFunctions(true);
- ExprNodeDesc exp = genExprNodeDesc(oExpr.getExpression(), inputRR, tcCtx);
- RexNode ordExp = converter.convert(exp);
+ RexNode ordExp = genRexNode(oExpr.getExpression(), inputRR, tcCtx);
Set<SqlKind> flags = new HashSet<SqlKind>();
if (oExpr.getOrder() == org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.Order.DESC) {
flags.add(SqlKind.DESCENDING);
@@ -4360,50 +4331,44 @@ public class CalcitePlanner extends SemanticAnalyzer {
// TODO: do we need to get to child?
int wndSpecASTIndx = getWindowSpecIndx(windowProjAst);
// 2. Get Hive Aggregate Info
- AggInfo hiveAggInfo = getHiveAggInfo(windowProjAst, wndSpecASTIndx - 1,
+ AggregateInfo hiveAggInfo = getHiveAggInfo(windowProjAst, wndSpecASTIndx - 1,
this.relToHiveRR.get(srcRel));
// 3. Get Calcite Return type for Agg Fn
- wHiveRetType = hiveAggInfo.m_returnType;
- RelDataType calciteAggFnRetType = TypeConverter.convert(hiveAggInfo.m_returnType,
+ wHiveRetType = hiveAggInfo.getReturnType();
+ RelDataType calciteAggFnRetType = TypeConverter.convert(hiveAggInfo.getReturnType(),
this.cluster.getTypeFactory());
// 4. Convert Agg Fn args to Calcite
- ImmutableMap<String, Integer> posMap = this.relToHiveColNameCalcitePosMap.get(srcRel);
- RexNodeConverter converter = new RexNodeConverter(this.cluster, srcRel.getRowType(),
- posMap, 0, false);
- Builder<RexNode> calciteAggFnArgsBldr = ImmutableList.<RexNode> builder();
- Builder<RelDataType> calciteAggFnArgsTypeBldr = ImmutableList.<RelDataType> builder();
- for (int i = 0; i < hiveAggInfo.m_aggParams.size(); i++) {
- calciteAggFnArgsBldr.add(converter.convert(hiveAggInfo.m_aggParams.get(i)));
- calciteAggFnArgsTypeBldr.add(TypeConverter.convert(hiveAggInfo.m_aggParams.get(i)
- .getTypeInfo(), this.cluster.getTypeFactory()));
+ List<RexNode> calciteAggFnArgs = hiveAggInfo.getParameters();
+ Builder<RelDataType> calciteAggFnArgsTypeBldr = ImmutableList.builder();
+ for (int i = 0; i < hiveAggInfo.getParameters().size(); i++) {
+ calciteAggFnArgsTypeBldr.add(hiveAggInfo.getParameters().get(i).getType());
}
- ImmutableList<RexNode> calciteAggFnArgs = calciteAggFnArgsBldr.build();
ImmutableList<RelDataType> calciteAggFnArgsType = calciteAggFnArgsTypeBldr.build();
// 5. Get Calcite Agg Fn
final SqlAggFunction calciteAggFn = SqlFunctionConverter.getCalciteAggFn(
- hiveAggInfo.m_udfName, hiveAggInfo.m_distinct, calciteAggFnArgsType, calciteAggFnRetType);
+ hiveAggInfo.getAggregateName(), hiveAggInfo.isDistinct(), calciteAggFnArgsType, calciteAggFnRetType);
// 6. Translate Window spec
RowResolver inputRR = relToHiveRR.get(srcRel);
WindowSpec wndSpec = ((WindowFunctionSpec) wExpSpec).getWindowSpec();
- List<RexNode> partitionKeys = getPartitionKeys(wndSpec.getPartition(), converter, inputRR);
- List<RexFieldCollation> orderKeys = getOrderKeys(wndSpec.getOrder(), converter, inputRR);
+ List<RexNode> partitionKeys = getPartitionKeys(wndSpec.getPartition(), inputRR);
+ List<RexFieldCollation> orderKeys = getOrderKeys(wndSpec.getOrder(), inputRR);
RexWindowBound upperBound = getBound(wndSpec.getWindowFrame().getStart());
RexWindowBound lowerBound = getBound(wndSpec.getWindowFrame().getEnd());
boolean isRows = wndSpec.getWindowFrame().getWindowType() == WindowType.ROWS;
w = cluster.getRexBuilder().makeOver(calciteAggFnRetType, calciteAggFn, calciteAggFnArgs,
partitionKeys, ImmutableList.<RexFieldCollation> copyOf(orderKeys), lowerBound,
- upperBound, isRows, true, false, hiveAggInfo.m_distinct);
+ upperBound, isRows, true, false, hiveAggInfo.isDistinct());
} else {
// TODO: Convert to Semantic Exception
throw new RuntimeException("Unsupported window Spec");
}
- return new Pair<RexNode, TypeInfo>(w, wHiveRetType);
+ return new Pair<>(w, wHiveRetType);
}
private RelNode genSelectForWindowing(QB qb, RelNode srcRel, HashSet<ColumnInfo> newColumns)
@@ -4469,12 +4434,12 @@ public class CalcitePlanner extends SemanticAnalyzer {
private RelNode genSelectRelNode(List<RexNode> calciteColLst, RowResolver out_rwsch,
RelNode srcRel, List<WindowExpressionSpec> windowExpressions) throws CalciteSemanticException {
// 1. Build Column Names
- Set<String> colNamesSet = new HashSet<String>();
+ Set<String> colNamesSet = new HashSet<>();
List<ColumnInfo> cInfoLst = out_rwsch.getRowSchema().getSignature();
- ArrayList<String> columnNames = new ArrayList<String>();
+ List<String> columnNames = new ArrayList<>();
Map<String,String> windowToAlias = null;
if (windowExpressions != null ) {
- windowToAlias = new HashMap<String,String>();
+ windowToAlias = new HashMap<>();
for (WindowExpressionSpec wes : windowExpressions) {
windowToAlias.put(wes.getExpression().toStringTree().toLowerCase(), wes.getAlias());
}
@@ -4515,8 +4480,11 @@ public class CalcitePlanner extends SemanticAnalyzer {
}
// 3 Build Calcite Rel Node for project using converted projections & col
- // names
- HiveRelNode selRel = HiveProject.create(srcRel, calciteColLst, columnNames);
+ // names. Fix nullability
+ HiveRelNode selRel = HiveProject.create(
+ srcRel,
+ HiveCalciteUtil.fixNullability(cluster.getRexBuilder(), calciteColLst, RelOptUtil.getFieldTypeList(srcRel.getRowType())),
+ columnNames);
// 4. Keep track of colname-to-posmap && RR for new select
this.relToHiveColNameCalcitePosMap.put(selRel, buildHiveToCalciteColumnMap(out_rwsch));
@@ -4577,7 +4545,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
RelNode selForWindow = genSelectForWindowing(qb, srcRel, excludedColumns);
srcRel = (selForWindow == null) ? srcRel : selForWindow;
- ArrayList<ExprNodeDesc> col_list = new ArrayList<ExprNodeDesc>();
+ List<RexNode> columnList = new ArrayList<>();
// 1. Get Select Expression List
QBParseInfo qbp = getQBParseInfo(qb);
@@ -4591,7 +4559,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
|| !qbp.getDestGroupingSets().isEmpty() || !qbp.getDestCubes().isEmpty());
// 2.Row resolvers for input, output
- RowResolver out_rwsch = new RowResolver();
+ RowResolver outputRR = new RowResolver();
Integer pos = Integer.valueOf(0);
// TODO: will this also fix windowing? try
RowResolver inputRR = this.relToHiveRR.get(srcRel), starRR = inputRR;
@@ -4602,7 +4570,6 @@ public class CalcitePlanner extends SemanticAnalyzer {
// 3. Query Hints
// TODO: Handle Query Hints; currently we ignore them
- boolean selectStar = false;
int posn = 0;
boolean hintPresent = (selExprList.getChild(0).getType() == HiveParser.QUERY_HINT);
if (hintPresent) {
@@ -4635,9 +4602,9 @@ public class CalcitePlanner extends SemanticAnalyzer {
if (!fi.isNative()) {
unparseTranslator.addIdentifierTranslation((ASTNode) expr.getChild(0));
}
- if (genericUDTF != null && (selectStar = exprType == HiveParser.TOK_FUNCTIONSTAR)) {
- genColListRegex(".*", null, (ASTNode) expr.getChild(0),
- col_list, null, inputRR, starRR, pos, out_rwsch, qb.getAliases(), false);
+ if (genericUDTF != null && exprType == HiveParser.TOK_FUNCTIONSTAR) {
+ genRexNodeRegex(".*", null, (ASTNode) expr.getChild(0),
+ columnList, null, inputRR, starRR, pos, outputRR, qb.getAliases(), false);
}
}
}
@@ -4727,13 +4694,14 @@ public class CalcitePlanner extends SemanticAnalyzer {
boolean isSubQuery = genSubQueryRelNode(qb, expr, srcRel, false,
subQueryToRelNode);
if(isSubQuery) {
- ExprNodeDesc subQueryExpr = genExprNodeDesc(expr, relToHiveRR.get(srcRel),
- outerRR, subQueryToRelNode, true);
- col_list.add(subQueryExpr);
-
+ RexNode subQueryExpr = genRexNode(expr, relToHiveRR.get(srcRel),
+ outerRR, subQueryToRelNode, true, cluster.getRexBuilder());
+ columnList.add(subQueryExpr);
ColumnInfo colInfo = new ColumnInfo(SemanticAnalyzer.getColumnInternalName(pos),
- subQueryExpr.getWritableObjectInspector(), tabAlias, false);
- if (!out_rwsch.putWithCheck(tabAlias, colAlias, null, colInfo)) {
+ TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(
+ TypeConverter.convert(subQueryExpr.getType())),
+ tabAlias, false);
+ if (!outputRR.putWithCheck(tabAlias, colAlias, null, colInfo)) {
throw new CalciteSemanticException("Cannot add column to RR: " + tabAlias + "."
+ colAlias + " => " + colInfo + " due to duplication, see previous warnings",
UnsupportedFeature.Duplicates_in_RR);
@@ -4743,10 +4711,9 @@ public class CalcitePlanner extends SemanticAnalyzer {
// 6.4 Build ExprNode corresponding to colums
if (expr.getType() == HiveParser.TOK_ALLCOLREF) {
- pos = genColListRegex(".*", expr.getChildCount() == 0 ? null :
- getUnescapedName((ASTNode) expr.getChild(0)).toLowerCase(), expr, col_list,
- excludedColumns, inputRR, starRR, pos, out_rwsch, qb.getAliases(), true);
- selectStar = true;
+ pos = genRexNodeRegex(".*",
+ expr.getChildCount() == 0 ? null : getUnescapedName((ASTNode) expr.getChild(0)).toLowerCase(),
+ expr, columnList, excludedColumns, inputRR, starRR, pos, outputRR, qb.getAliases(), true);
} else if (expr.getType() == HiveParser.TOK_TABLE_OR_COL
&& !hasAsClause
&& !inputRR.getIsExprResolver()
@@ -4755,8 +4722,8 @@ public class CalcitePlanner extends SemanticAnalyzer {
// In case the expression is a regex COL.
// This can only happen without AS clause
// We don't allow this for ExprResolver - the Group By case
- pos = genColListRegex(unescapeIdentifier(expr.getChild(0).getText()), null, expr, col_list, excludedColumns,
- inputRR, starRR, pos, out_rwsch, qb.getAliases(), true);
+ pos = genRexNodeRegex(unescapeIdentifier(expr.getChild(0).getText()), null,
+ expr, columnList, excludedColumns, inputRR, starRR, pos, outputRR, qb.getAliases(), true);
} else if (expr.getType() == HiveParser.DOT
&& expr.getChild(0).getType() == HiveParser.TOK_TABLE_OR_COL
&& inputRR.hasTableAlias(unescapeIdentifier(expr.getChild(0)
@@ -4768,11 +4735,11 @@ public class CalcitePlanner extends SemanticAnalyzer {
// In case the expression is TABLE.COL (col can be regex).
// This can only happen without AS clause
// We don't allow this for ExprResolver - the Group By case
- pos = genColListRegex(
+ pos = genRexNodeRegex(
unescapeIdentifier(expr.getChild(1).getText()),
unescapeIdentifier(expr.getChild(0).getChild(0).getText().toLowerCase()),
- expr, col_list, excludedColumns, inputRR, starRR, pos,
- out_rwsch, qb.getAliases(), true);
+ expr, columnList, excludedColumns, inputRR, starRR, pos,
+ outputRR, qb.getAliases(), true);
} else if (ParseUtils.containsTokenOfType(expr, HiveParser.TOK_FUNCTIONDI)
&& !(srcRel instanceof HiveAggregate)) {
// Likely a malformed query eg, select hash(distinct c1) from t1;
@@ -4780,7 +4747,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
UnsupportedFeature.Distinct_without_an_aggreggation);
} else {
// Case when this is an expression
- TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR);
+ TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR, cluster.getRexBuilder());
// We allow stateful functions in the SELECT list (but nowhere else)
tcCtx.setAllowStatefulFunctions(true);
if (!qbp.getDestToGroupBy().isEmpty()) {
@@ -4788,35 +4755,36 @@ public class CalcitePlanner extends SemanticAnalyzer {
expr = rewriteGroupingFunctionAST(getGroupByForClause(qbp, selClauseName), expr,
!cubeRollupGrpSetPresent);
}
- ExprNodeDesc exp = genExprNodeDesc(expr, inputRR, tcCtx);
- String recommended = recommendName(exp, colAlias);
- if (recommended != null && out_rwsch.get(null, recommended) == null) {
+ RexNode expression = genRexNode(expr, inputRR, tcCtx);
+
+ String recommended = recommendName(expression, colAlias, inputRR);
+ if (recommended != null && outputRR.get(null, recommended) == null) {
colAlias = recommended;
}
- col_list.add(exp);
+ columnList.add(expression);
+ TypeInfo typeInfo = expression.isA(SqlKind.LITERAL) ?
+ TypeConverter.convertLiteralType((RexLiteral) expression) :
+ TypeConverter.convert(expression.getType());
ColumnInfo colInfo = new ColumnInfo(SemanticAnalyzer.getColumnInternalName(pos),
- exp.getWritableObjectInspector(), tabAlias, false);
- colInfo.setSkewedCol((exp instanceof ExprNodeColumnDesc) ? ((ExprNodeColumnDesc) exp)
- .isSkewedCol() : false);
- out_rwsch.put(tabAlias, colAlias, colInfo);
+ TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(typeInfo),
+ tabAlias, false);
+ outputRR.put(tabAlias, colAlias, colInfo);
pos = Integer.valueOf(pos.intValue() + 1);
}
}
}
- selectStar = selectStar && exprList.getChildCount() == posn + 1;
- // 7. Convert Hive projections to Calcite
- List<RexNode> calciteColLst = new ArrayList<RexNode>();
-
- RexNodeConverter rexNodeConv = new RexNodeConverter(cluster, srcRel.getRowType(),
- outerNameToPosMap, buildHiveColNameToInputPosMap(col_list, inputRR), relToHiveRR.get(srcRel),
- outerRR, HiveConf.getIntVar(conf, HiveConf.ConfVars.HIVEOPT_TRANSFORM_IN_MAXNODES),
- 0, false, subqueryId);
- for (ExprNodeDesc colExpr : col_list) {
- calciteColLst.add(rexNodeConv.convert(colExpr));
- }
+ // 7. For correlated queries
+ ImmutableMap<String, Integer> hiveColNameCalcitePosMap =
+ buildHiveColNameToInputPosMap(columnList, inputRR);
+ CorrelationConverter cc = new CorrelationConverter(
+ new InputContext(srcRel.getRowType(), hiveColNameCalcitePosMap, relToHiveRR.get(srcRel)),
+ outerNameToPosMap, outerRR, subqueryId);
+ columnList = columnList.stream()
+ .map(cc::apply)
+ .collect(Collectors.toList());
// 8. Build Calcite Rel
RelNode outputRel = null;
@@ -4828,7 +4796,7 @@ public class CalcitePlanner extends SemanticAnalyzer {
// In OP return path, we need to generate a SEL and then a UDTF
// following old semantic analyzer.
outputRel = genUDTFPlan(genericUDTF, genericUDTFName, udtfTableAlias, udtfColAliases, qb,
- calciteColLst, out_rwsch, srcRel);
+ columnList, outputRR, srcRel);
} else {
String dest = qbp.getClauseNames().iterator().next();
ASTNode obAST = qbp.getOrderByForClause(dest);
@@ -4863,27 +4831,27 @@ public class CalcitePlanner extends SemanticAnalyzer {
return new RexInputRef(input.getIndex(), input.getType());
}
});
- originalRR = out_rwsch.duplicate();
+ originalRR = outputRR.duplicate();
for (int i = 0; i < inputRR.getColumnInfos().size(); i++) {
ColumnInfo colInfo = new ColumnInfo(inputRR.getColumnInfos().get(i));
- String internalName = SemanticAnalyzer.getColumnInternalName(out_rwsch.getColumnInfos()
+ String internalName = SemanticAnalyzer.getColumnInternalName(outputRR.getColumnInfos()
.size() + i);
colInfo.setInternalName(internalName);
// if there is any confict, then we do not generate it in the new select
// otherwise, we add it into the calciteColLst and generate the new select
- if (!out_rwsch.putWithCheck(colInfo.getTabAlias(), colInfo.getAlias(), internalName,
+ if (!outputRR.putWithCheck(colInfo.getTabAlias(), colInfo.getAlias(), internalName,
colInfo)) {
LOG.trace("Column already present in RR. skipping.");
} else {
- calciteColLst.add(originalInputRefs.get(i));
+ columnList.add(originalInputRefs.get(i));
}
}
- outputRel = genSelectRelNode(calciteColLst, out_rwsch, srcRel);
+ outputRel = genSelectRelNode(columnList, outputRR, srcRel);
// outputRel is the generated augmented select with extra unselected
// columns, and originalRR is the original generated select
return new Pair<RelNode, RowResolver>(outputRel, originalRR);
} else {
- outputRel = genSelectRelNode(calciteColLst, out_rwsch, srcRel);
+ outputRel = genSelectRelNode(columnList, outputRR, srcRel);
}
}
// 9. Handle select distinct as GBY if there exist windowing functions
@@ -4892,8 +4860,8 @@ public class CalcitePlanner extends SemanticAnalyzer {
outputRel = new HiveAggregate(cluster, cluster.traitSetOf(HiveRelNode.CONVENTION),
outputRel, groupSet, null, new ArrayList<AggregateCall>());
RowResolver groupByOutputRowResolver = new RowResolver();
- for (int i = 0; i < out_rwsch.getColumnInfos().size(); i++) {
- ColumnInfo colInfo = out_rwsch.getColumnInfos().get(i);
+ for (int i = 0; i < outputRR.getColumnInfos().size(); i++) {
+ ColumnInfo colInfo = outputRR.getColumnInfos().get(i);
ColumnInfo newColInfo = new ColumnInfo(colInfo.getInternalName(),
colInfo.getType(), colInfo.getTabAlias(), colInfo.getIsVirtualCol());
groupByOutputRowResolver.put(colInfo.getTabAlias(), colInfo.getAlias(), newColInfo);
@@ -4906,6 +4874,19 @@ public class CalcitePlanner extends SemanticAnalyzer {
return new Pair<RelNode, RowResolver>(outputRel, null);
}
+ Integer genRexNodeRegex(String colRegex, String tabAlias, ASTNode sel,
+ List<RexNode> exprList, Set<ColumnInfo> excludeCols, RowResolver input,
+ RowResolver colSrcRR, Integer pos, RowResolver output, List<String> aliases,
+ boolean ensureUniqueCols) throws SemanticException {
+ List<org.apache.commons.lang3.tuple.Pair<ColumnInfo, RowResolver>> colList = new ArrayList<>();
+ Integer i = genColListRegex(colRegex, tabAlias, sel,
+ colList, excludeCols, input, colSrcRR, pos, output, aliases, ensureUniqueCols);
+ for (org.apache.commons.lang3.tuple.Pair<ColumnInfo, RowResolver> p : colList) {
+ exprList.add(RexNodeTypeCheck.toExprNode(p.getLeft(), p.getRight(), 0, cluster.getRexBuilder()));
+ }
+ return i;
+ }
+
private RelNode genUDTFPlan(GenericUDTF genericUDTF, String genericUDTFName, String outputTableAlias,
ArrayList<String> colAliases, QB qb, List<RexNode> selectColLst, RowResolver selectRR, RelNode input) throws SemanticException {
@@ -4929,29 +4910,18 @@ public class CalcitePlanner extends SemanticAnalyzer {
LOG.debug("Table alias: " + outputTableAlias + " Col aliases: " + colAliases);
- // Use the RowResolver from the input operator to generate a input
- // ObjectInspector that can be used to initialize the UDTF. Then, the
- // resulting output object inspector can be used to make the RowResolver
- // for the UDTF operator
- List<ColumnInfo> inputCols = selectRR.getColumnInfos();
-
- // Create the object inspector for the input columns and initialize the
+ // Create the return type info for the input columns and initialize the
// UDTF
- List<String> colNames = new ArrayList<String>();
- ObjectInspector[] colOIs = new ObjectInspector[inputCols.size()];
- for (int i = 0; i < inputCols.size(); i++) {
- colNames.add(inputCols.get(i).getInternalName());
- colOIs[i] = inputCols.get(i).getObjectInspector();
- }
- StandardStructObjectInspector rowOI = ObjectInspectorFactory
- .getStandardStructObjectInspector(colNames, Arrays.asList(colOIs));
- StructObjectInspector outputOI = genericUDTF.initialize(rowOI);
+ StructTypeInfo type = (StructTypeInfo) TypeConverter.convert(
+ functionHelper.getReturnType(
+ functionHelper.getFunctionInfo(genericUDTFName),
+ selectColLst));
- int numUdtfCols = outputOI.getAllStructFieldRefs().size();
+ int numUdtfCols = type.getAllStructFieldNames().size();
if (colAliases.isEmpty()) {
// user did not specfied alias names, infer names from outputOI
- for (StructField field : outputOI.getAllStructFieldRefs()) {
- colAliases.add(field.getFieldName());
+ for (String fieldName : type.getAllStructFieldNames()) {
+ colAliases.add(fieldName);
}
}
// Make sure that the number of column aliases in the AS clause matches
@@ -4966,7 +4936,9 @@ public class CalcitePlanner extends SemanticAnalyzer {
List<ColumnInfo> udtfCols = new ArrayList<ColumnInfo>();
Iterator<String> colAliasesIter = colAliases.iterator();
- for (StructField sf : outputOI.getAllStructFieldRefs()) {
+ for (int i = 0; i < type.getAllStructFieldTypeInfos().size(); i++) {
+ final String fieldName = type.getAllStructFieldNames().get(i);
+ final TypeInfo fieldTypeInfo = type.getAllStructFieldTypeInfos().get(i);
String colAlias = colAliasesIter.next();
assert (colAlias != null);
@@ -4974,23 +4946,21 @@ public class CalcitePlanner extends SemanticAnalyzer {
// Since the UDTF operator feeds into a LVJ operator that will rename
// all the internal names, we can just use field name from the UDTF's OI
// as the internal name
- ColumnInfo col = new ColumnInfo(sf.getFieldName(),
- TypeInfoUtils.getTypeInfoFromObjectInspector(sf.getFieldObjectInspector()),
- outputTableAlias, false);
+ ColumnInfo col = new ColumnInfo(fieldName, fieldTypeInfo, outputTableAlias, false);
udtfCols.add(col);
}
// Create the row resolver for this operator from the output columns
- RowResolver out_rwsch = new RowResolver();
+ RowResolver outputRR = new RowResolver();
for (int i = 0; i < udtfCols.size(); i++) {
- out_rwsch.put(outputTableAlias, colAliases.get(i), udtfCols.get(i));
+ outputRR.put(outputTableAlias, colAliases.get(i), udtfCols.get(i));
}
// Add the UDTFOperator to the operator DAG
RelTraitSet traitSet = TraitsUtil.getDefaultTraitSet(cluster);
// Build row type from field <type, name>
- RelDataType retType = TypeConverter.getType(cluster, out_rwsch, null);
+ RelDataType retType = TypeConverter.getType(cluster, outputRR, null);
Builder<RelDataType> argTypeBldr = ImmutableList.<RelDataType> builder();
@@ -5013,8 +4983,8 @@ public class CalcitePlanner extends SemanticAnalyzer {
RelNode udtf = HiveTableFunctionScan.create(cluster, traitSet, list, rexNode, null, retType,
null);
// Add new rel & its RR to the maps
- relToHiveColNameCalcitePosMap.put(udtf, buildHiveToCalciteColumnMap(out_rwsch));
- relToHiveRR.put(udtf, out_rwsch);
+ relToHiveColNameCalcitePosMap.put(udtf, buildHiveToCalciteColumnMap(outputRR));
+ relToHiveRR.put(udtf, outputRR);
return udtf;
}
@@ -5291,18 +5261,15 @@ public class CalcitePlanner extends SemanticAnalyzer {
}
private ImmutableMap<String, Integer> buildHiveColNameToInputPosMap(
- List<ExprNodeDesc> col_list, RowResolver inputRR) {
- // Build a map of Hive column Names (ExprNodeColumnDesc Name)
- // to the positions of those projections in the input
- Multimap<Integer, ExprNodeColumnDesc> hashCodeTocolumnDescMap = ArrayListMultimap.create();
- ExprNodeDescUtils.getExprNodeColumnDesc(col_list, hashCodeTocolumnDescMap);
- ImmutableMap.Builder<String, Integer> hiveColNameToInputPosMapBuilder = new ImmutableMap.Builder<String, Integer>();
- String exprNodecolName;
- for (ExprNodeColumnDesc exprDesc : hashCodeTocolumnDescMap.values()) {
- exprNodecolName = exprDesc.getColumn();
- hiveColNameToInputPosMapBuilder.put(exprNodecolName, inputRR.getPosition(exprNodecolName));
+ List<RexNode> columnList, RowResolver inputRR) {
+ final ImmutableBitSet refs =
+ RelOptUtil.InputFinder.bits(columnList, null);
+ ImmutableMap.Builder<String, Integer> hiveColNameToInputPosMapBuilder =
+ new ImmutableMap.Builder<>();
+ for (int ref : refs) {
+ hiveColNameToInputPosMapBuilder.put(
+ inputRR.getColumnInfos().get(ref).getInternalName(), ref);
}
-
return hiveColNameToInputPosMapBuilder.build();
}
@@ -5368,6 +5335,216 @@ public class CalcitePlanner extends SemanticAnalyzer {
return tabNameToTabObject.get(fullyQualName);
}
+ RexNode genRexNode(ASTNode expr, RowResolver input,
+ RowResolver outerRR, Map<ASTNode, RelNode> subqueryToRelNode,
+ boolean useCaching, RexBuilder rexBuilder) throws SemanticException {
+ TypeCheckCtx tcCtx = new TypeCheckCtx(input, rexBuilder, useCaching, false);
+ tcCtx.setOuterRR(outerRR);
+ tcCtx.setSubqueryToRelNode(subqueryToRelNode);
+ return genRexNode(expr, input, tcCtx);
+ }
+
+ /**
+ * Generates a Calcite {@link RexNode} for the expression with TypeCheckCtx.
+ */
+ RexNode genRexNode(ASTNode expr, RowResolver input, RexBuilder rexBuilder)
+ throws SemanticException {
+ // Since the user didn't supply a customized type-checking context,
+ // use default settings.
+ return genRexNode(expr, input, true, false, rexBuilder);
+ }
+
+ RexNode genRexNode(ASTNode expr, RowResolver input, boolean useCaching,
+ boolean foldExpr, RexBuilder rexBuilder) throws SemanticException {
+ TypeCheckCtx tcCtx = new TypeCheckCtx(input, rexBuilder, useCaching, foldExpr);
+ return genRexNode(expr, input, tcCtx);
+ }
+
+ /**
+ * Generates a Calcite {@link RexNode} for the expression and children of it
+ * with default TypeCheckCtx.
+ */
+ Map<ASTNode, RexNode> genAllRexNode(ASTNode expr, RowResolver input, RexBuilder rexBuilder)
+ throws SemanticException {
+ TypeCheckCtx tcCtx = new TypeCheckCtx(input, rexBuilder);
+ return genAllRexNode(expr, input, tcCtx);
+ }
+
+ /**
+ * Returns a Calcite {@link RexNode} for the expression.
+ * If it is evaluated already in previous operator, it can be retrieved from cache.
+ */
+ RexNode genRexNode(ASTNode expr, RowResolver input,
+ TypeCheckCtx tcCtx) throws SemanticException {
+ RexNode cached = null;
+ if (tcCtx.isUseCaching()) {
+ cached = getRexNodeCached(expr, input, tcCtx);
+ }
+ if (cached == null) {
+ Map<ASTNode, RexNode> allExprs = genAllRexNode(expr, input, tcCtx);
+ return allExprs.get(expr);
+ }
+ return cached;
+ }
+
+ /**
+ * Find RexNode for the expression cached in the RowResolver. Returns null if not exists.
+ */
+ private RexNode getRexNodeCached(ASTNode node, RowResolver input,
+ TypeCheckCtx tcCtx) throws SemanticException {
+ ColumnInfo colInfo = input.getExpression(node);
+ if (colInfo != null) {
+ ASTNode source = input.getExpressionSource(node);
+ if (source != null) {
+ unparseTranslator.addCopyTranslation(node, source);
+ }
+ return RexNodeTypeCheck.toExprNode(colInfo, input, 0, tcCtx.getRexBuilder());
+ }
+ return null;
+ }
+
+ /**
+ * Generates all of the Calcite {@link RexNode}s for the expression and children of it
+ * passed in the arguments. This function uses the row resolver and the metadata information
+ * that are passed as arguments to resolve the column names to internal names.
+ *
+ * @param expr
+ * The expression
+ * @param input
+ * The row resolver
+ * @param tcCtx
+ * Customized type-checking context
+ * @return expression to exprNodeDesc mapping
+ * @throws SemanticException Failed to evaluate expression
+ */
+ Map<ASTNode, RexNode> genAllRexNode(ASTNode expr, RowResolver input,
+ TypeCheckCtx tcCtx) throws SemanticException {
+ // Create the walker and the rules dispatcher.
+ tcCtx.setUnparseTranslator(unparseTranslator);
+
+ Map<ASTNode, RexNode> nodeOutputs =
+ RexNodeTypeCheck.genExprNode(expr, tcCtx);
+ RexNode desc = nodeOutputs.get(expr);
+ if (desc == null) {
+ String tableOrCol = BaseSemanticAnalyzer.unescapeIdentifier(expr
+ .getChild(0).getText());
+ ColumnInfo colInfo = input.get(null, tableOrCol);
+ String errMsg;
+ if (colInfo == null && input.getIsExprResolver()){
+ errMsg = ASTErrorUtils.getMsg(
+ ErrorMsg.NON_KEY_EXPR_IN_GROUPBY.getMsg(), expr);
+ } else {
+ errMsg = tcCtx.getError();
+ }
+ throw new SemanticException(Optional.ofNullable(errMsg).orElse("Error in parsing "));
+ }
+ if (desc instanceof HiveRexExprList) {
+ throw new SemanticException("TOK_ALLCOLREF is not supported in current context");
+ }
+
+ if (!unparseTranslator.isEnabled()) {
+ // Not creating a view, so no need to track view expansions.
+ return nodeOutputs;
+ }
+
+ List<ASTNode> fieldDescList = new ArrayList<>();
+
+ for (Map.Entry<ASTNode, RexNode> entry : nodeOutputs.entrySet()) {
+ if (!(entry.getValue() instanceof RexInputRef)) {
+ // we need to translate the RexFieldAccess too, e.g., identifiers in
+ // struct<>.
+ if (entry.getValue() instanceof RexFieldAccess) {
+ fieldDescList.add(entry.getKey());
+ }
+ continue;
+ }
+ ASTNode node = entry.getKey();
+ RexInputRef columnDesc = (RexInputRef) entry.getValue();
+ int index = columnDesc.getIndex();
+ String[] tmp;
+ if (index < input.getColumnInfos().size()) {
+ ColumnInfo columnInfo = input.getColumnInfos().get(index);
+ if (columnInfo.getTabAlias() == null
+ || columnInfo.getTabAlias().length() == 0) {
+ // These aren't real column refs; instead, they are special
+ // internal expressions used in the representation of aggregation.
+ continue;
+ }
+ tmp = input.reverseLookup(columnInfo.getInternalName());
+ } else {
+ // in subquery case, tmp may be from outside.
+ ColumnInfo columnInfo = tcCtx.getOuterRR().getColumnInfos().get(
+ index - input.getColumnInfos().size());
+ if (columnInfo.getTabAlias() == null
+ || columnInfo.getTabAlias().length() == 0) {
+ continue;
+ }
+ tmp = tcCtx.getOuterRR().reverseLookup(columnInfo.getInternalName());
+ }
+ StringBuilder replacementText = new StringBuilder();
+ replacementText.append(HiveUtils.unparseIdentifier(tmp[0], conf));
+ replacementText.append(".");
+ replacementText.append(HiveUtils.unparseIdentifier(tmp[1], conf));
+ unparseTranslator.addTranslation(node, replacementText.toString());
+ }
+
+ for (ASTNode node : fieldDescList) {
+ Map<ASTNode, String> map = translateFieldDesc(node);
+ for (Entry<ASTNode, String> entry : map.entrySet()) {
+ unparseTranslator.addTranslation(entry.getKey(), entry.getValue());
+ }
+ }
+
+ return nodeOutputs;
+ }
+
+ private String recommendName(RexNode exp, String colAlias, RowResolver rowResolver) {
+ if (!colAlias.startsWith(autogenColAliasPrfxLbl)) {
+ return null;
+ }
+ String column = recommendInputName(exp, rowResolver);
+ if (column != null && !column.startsWith(autogenColAliasPrfxLbl)) {
+ return column;
+ }
+ return null;
+ }
+
+ /**
+ * Recommend name for the expression
+ */
+ private static String recommendInputName(RexNode desc, RowResolver rowResolver) {
+ Integer pos = null;
+ if (desc instanceof RexInputRef) {
+ pos = ((RexInputRef) desc).getIndex();
+ }
+ if (desc.isA(SqlKind.CAST)) {
+ RexNode input = ((RexCall) desc).operands.get(0);
+ if (input instanceof RexInputRef) {
+ pos = ((RexInputRef) input).getIndex();
+ }
+ }
+ return pos != null ?
+ rowResolver.getColumnInfos().get(pos).getInternalName() :
+ null;
+ }
+
+
+ /**
+ * Contains information useful to decorrelate queries.
+ */
+ protected static class InputContext {
+ protected final RelDataType inputRowType;
+ protected final ImmutableBiMap<Integer, String> positionToColumnName;
+ protected final RowResolver inputRowResolver;
+
+ protected InputContext(RelDataType inputRowType, ImmutableMap<String, Integer> columnNameToPosition,
+ RowResolver inputRowResolver) {
+ this.inputRowType = inputRowType;
+ this.positionToColumnName = ImmutableBiMap.copyOf(columnNameToPosition).inverse();
+ this.inputRowResolver = inputRowResolver.duplicate();
+ }
+ }
+
/**
* This method can be called at startup time to pre-register all the
* additional Hive classes (compared to Calcite core classes) that may
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/DruidSqlOperatorConverter.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/DruidSqlOperatorConverter.java
index ece6e77..36c3af5 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/DruidSqlOperatorConverter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/DruidSqlOperatorConverter.java
@@ -28,7 +28,6 @@ import org.apache.calcite.adapter.druid.DruidExpressions;
import org.apache.calcite.adapter.druid.DruidQuery;
import org.apache.calcite.adapter.druid.ExtractOperatorConversion;
import org.apache.calcite.adapter.druid.FloorOperatorConversion;
-import org.apache.calcite.adapter.druid.UnarySuffixOperatorConversion;
import org.apache.calcite.config.CalciteConnectionConfig;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rex.RexCall;
@@ -48,7 +47,7 @@ import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFloorDate;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFromUnixTimeSqlOperator;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveToDateSqlOperator;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTruncSqlOperator;
-import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveUnixTimestampSqlOperator;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveToUnixTimestampSqlOperator;
import org.joda.time.Period;
import javax.annotation.Nullable;
@@ -97,7 +96,7 @@ public class DruidSqlOperatorConverter {
druidOperatorMap.put(HiveTruncSqlOperator.INSTANCE, new DruidDateTruncOperatorConversion());
druidOperatorMap.put(HiveToDateSqlOperator.INSTANCE, new DruidToDateOperatorConversion());
druidOperatorMap.put(HiveFromUnixTimeSqlOperator.INSTANCE, new DruidFormUnixTimeOperatorConversion());
- druidOperatorMap.put(HiveUnixTimestampSqlOperator.INSTANCE, new DruidUnixTimestampOperatorConversion());
+ druidOperatorMap.put(HiveToUnixTimestampSqlOperator.INSTANCE, new DruidUnixTimestampOperatorConversion());
druidOperatorMap.put(HiveDateAddSqlOperator.INSTANCE,
new DruidDateArithmeticOperatorConversion(1, HiveDateAddSqlOperator.INSTANCE)
);
@@ -251,7 +250,7 @@ public class DruidSqlOperatorConverter {
implements org.apache.calcite.adapter.druid.DruidSqlOperatorConverter {
@Override public SqlOperator calciteOperator() {
- return HiveUnixTimestampSqlOperator.INSTANCE;
+ return HiveToUnixTimestampSqlOperator.INSTANCE;
}
@Nullable @Override public String toDruidExpression(RexNode rexNode, RelDataType rowType, DruidQuery query
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index e13dfe8..0de3730 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -358,7 +358,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
private final GlobalLimitCtx globalLimitCtx;
// prefix for column names auto generated by hive
- private final String autogenColAliasPrfxLbl;
+ protected final String autogenColAliasPrfxLbl;
private final boolean autogenColAliasPrfxIncludeFuncName;
// Keep track of view alias to read entity corresponding to the view
@@ -3601,12 +3601,25 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
return output;
}
+ Integer genExprNodeDescRegex(String colRegex, String tabAlias, ASTNode sel,
+ List<ExprNodeDesc> exprList, Set<ColumnInfo> excludeCols, RowResolver input,
+ RowResolver colSrcRR, Integer pos, RowResolver output, List<String> aliases,
+ boolean ensureUniqueCols) throws SemanticException {
+ List<Pair<ColumnInfo, RowResolver>> colList = new ArrayList<>();
+ Integer i = genColListRegex(colRegex, tabAlias, sel,
+ colList, excludeCols, input, colSrcRR, pos, output, aliases, ensureUniqueCols);
+ for (Pair<ColumnInfo, RowResolver> p : colList) {
+ exprList.add(ExprNodeTypeCheck.toExprNode(p.getLeft(), p.getRight()));
+ }
+ return i;
+ }
+
@SuppressWarnings("nls")
- // TODO: make aliases unique, otherwise needless rewriting takes place
+ // TODO: make aliases unique, otherwise needless rewriting takes place
Integer genColListRegex(String colRegex, String tabAlias, ASTNode sel,
- List<ExprNodeDesc> colList, Set<ColumnInfo> excludeCols, RowResolver input,
- RowResolver colSrcRR, Integer pos, RowResolver output, List<String> aliases,
- boolean ensureUniqueCols) throws SemanticException {
+ List<Pair<ColumnInfo, RowResolver>> colList, Set<ColumnInfo> excludeCols, RowResolver input,
+ RowResolver colSrcRR, Integer pos, RowResolver output, List<String> aliases,
+ boolean ensureUniqueCols) throws SemanticException {
if (colSrcRR == null) {
colSrcRR = input;
@@ -3674,9 +3687,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
}
ColumnInfo oColInfo = inputColsProcessed.get(colInfo);
if (oColInfo == null) {
- ExprNodeColumnDesc expr = new ExprNodeColumnDesc(colInfo.getType(), name,
- colInfo.getTabAlias(), colInfo.getIsVirtualCol(), colInfo.isSkewedCol());
- colList.add(expr);
+ colList.add(Pair.of(colInfo, colSrcRR));
oColInfo = new ColumnInfo(getColumnInternalName(pos), colInfo.getType(),
colInfo.getTabAlias(), colInfo.getIsVirtualCol(), colInfo.isHiddenVirtualCol());
inputColsProcessed.put(colInfo, oColInfo);
@@ -3763,9 +3774,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
ColumnInfo oColInfo = inputColsProcessed.get(colInfo);
if (oColInfo == null) {
- ExprNodeColumnDesc expr = new ExprNodeColumnDesc(colInfo.getType(), name,
- colInfo.getTabAlias(), colInfo.getIsVirtualCol(), colInfo.isSkewedCol());
- colList.add(expr);
+ colList.add(Pair.of(colInfo, input));
oColInfo = new ColumnInfo(getColumnInternalName(pos), colInfo.getType(),
colInfo.getTabAlias(), colInfo.getIsVirtualCol(), colInfo.isHiddenVirtualCol());
inputColsProcessed.put(colInfo, oColInfo);
@@ -4474,7 +4483,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
.getChild(0));
}
if (isUDTF && (selectStar = udtfExprType == HiveParser.TOK_FUNCTIONSTAR)) {
- genColListRegex(".*", null, (ASTNode) udtfExpr.getChild(0),
+ genExprNodeDescRegex(".*", null, (ASTNode) udtfExpr.getChild(0),
colList, null, inputRR, starRR, pos, out_rwsch, qb.getAliases(), false);
}
}
@@ -4582,7 +4591,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
// The real expression
if (expr.getType() == HiveParser.TOK_ALLCOLREF) {
int initPos = pos;
- pos = genColListRegex(".*", expr.getChildCount() == 0 ? null
+ pos = genExprNodeDescRegex(".*", expr.getChildCount() == 0 ? null
: getUnescapedName((ASTNode) expr.getChild(0)).toLowerCase(),
expr, colList, null, inputRR, starRR, pos, out_rwsch, qb.getAliases(), false);
if (unparseTranslator.isEnabled()) {
@@ -4595,7 +4604,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
// In case the expression is a regex COL.
// This can only happen without AS clause
// We don't allow this for ExprResolver - the Group By case
- pos = genColListRegex(unescapeIdentifier(expr.getChild(0).getText()),
+ pos = genExprNodeDescRegex(unescapeIdentifier(expr.getChild(0).getText()),
null, expr, colList, null, inputRR, starRR, pos, out_rwsch, qb.getAliases(), false);
} else if (expr.getType() == HiveParser.DOT
&& expr.getChild(0).getType() == HiveParser.TOK_TABLE_OR_COL
@@ -4606,7 +4615,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
// In case the expression is TABLE.COL (col can be regex).
// This can only happen without AS clause
// We don't allow this for ExprResolver - the Group By case
- pos = genColListRegex(unescapeIdentifier(expr.getChild(1).getText()),
+ pos = genExprNodeDescRegex(unescapeIdentifier(expr.getChild(1).getText()),
unescapeIdentifier(expr.getChild(0).getChild(0).getText().toLowerCase()),
expr, colList, null, inputRR, starRR, pos, out_rwsch, qb.getAliases(), false);
} else {
@@ -4847,15 +4856,22 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
* for each GroupBy aggregation.
*/
public static GenericUDAFEvaluator getGenericUDAFEvaluator(String aggName,
- List<ExprNodeDesc> aggParameters, ASTNode aggTree,
- boolean isDistinct, boolean isAllColumns)
+ List<ExprNodeDesc> aggParameters, ASTNode aggTree,
+ boolean isDistinct, boolean isAllColumns)
+ throws SemanticException {
+ return getGenericUDAFEvaluator2(aggName, getWritableObjectInspector(aggParameters),
+ aggTree, isDistinct, isAllColumns);
+ }
+
+ public static GenericUDAFEvaluator getGenericUDAFEvaluator2(String aggName,
+ List<ObjectInspector> aggParameterOIs, ASTNode aggTree,
+ boolean isDistinct, boolean isAllColumns)
throws SemanticException {
- List<ObjectInspector> originalParameterTypeInfos = getWritableObjectInspector(aggParameters);
GenericUDAFEvaluator result = FunctionRegistry.getGenericUDAFEvaluator(
- aggName, originalParameterTypeInfos, isDistinct, isAllColumns);
+ aggName, aggParameterOIs, isDistinct, isAllColumns);
if (null == result) {
String reason = "Looking for UDAF Evaluator\"" + aggName
- + "\" with parameters " + originalParameterTypeInfos;
+ + "\" with parameters " + aggParameterOIs;
throw new SemanticException(ASTErrorUtils.getMsg(
ErrorMsg.INVALID_FUNCTION_SIGNATURE.getMsg(),
(ASTNode) aggTree.getChild(0), reason));
@@ -4875,7 +4891,16 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
* when the UDAF is not found or has problems.
*/
public static GenericUDAFInfo getGenericUDAFInfo(GenericUDAFEvaluator evaluator,
- GenericUDAFEvaluator.Mode emode, List<ExprNodeDesc> aggParameters)
+ GenericUDAFEvaluator.Mode emode, List<ExprNodeDesc> aggParameters)
+ throws SemanticException {
+ GenericUDAFInfo udafInfo = getGenericUDAFInfo2(
+ evaluator, emode, getWritableObjectInspector(aggParameters));
+ udafInfo.convertedParameters = aggParameters;
+ return udafInfo;
+ }
+
+ public static GenericUDAFInfo getGenericUDAFInfo2(GenericUDAFEvaluator evaluator,
+ GenericUDAFEvaluator.Mode emode, List<ObjectInspector> aggOIs)
throws SemanticException {
GenericUDAFInfo r = new GenericUDAFInfo();
@@ -4886,7 +4911,6 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
// set r.returnType
ObjectInspector returnOI = null;
try {
- List<ObjectInspector> aggOIs = getWritableObjectInspector(aggParameters);
ObjectInspector[] aggOIArray = new ObjectInspector[aggOIs.size()];
for (int ii = 0; ii < aggOIs.size(); ++ii) {
aggOIArray[ii] = aggOIs.get(ii);
@@ -4896,9 +4920,6 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
} catch (HiveException e) {
throw new SemanticException(e);
}
- // set r.convertedParameters
- // TODO: type conversion
- r.convertedParameters = aggParameters;
return r;
}
@@ -7295,7 +7316,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
continue;
}
if (nullConstraintBitSet.indexOf(constraintIdx) != -1) {
- ExprNodeDesc currExpr = ExprNodeTypeCheck.toExprNodeDesc(colInfos.get(colExprIdx));
+ ExprNodeDesc currExpr = ExprNodeTypeCheck.toExprNode(colInfos.get(colExprIdx), null);
ExprNodeDesc isNotNullUDF = ExprNodeTypeCheck.getExprNodeDefaultExprProcessor()
.getFuncExprNodeDesc("isnotnull", currExpr);
if (currUDF != null) {
@@ -13038,16 +13059,6 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
return genExprNodeDesc(expr, input, true, false);
}
- ExprNodeDesc genExprNodeDesc(ASTNode expr, RowResolver input,
- RowResolver outerRR, Map<ASTNode, RelNode> subqueryToRelNode,
- boolean useCaching) throws SemanticException {
-
- TypeCheckCtx tcCtx = new TypeCheckCtx(input, useCaching, false);
- tcCtx.setOuterRR(outerRR);
- tcCtx.setSubqueryToRelNode(subqueryToRelNode);
- return genExprNodeDesc(expr, input, tcCtx);
- }
-
ExprNodeDesc genExprNodeDesc(ASTNode expr, RowResolver input, boolean useCaching,
boolean foldExpr) throws SemanticException {
TypeCheckCtx tcCtx = new TypeCheckCtx(input, useCaching, foldExpr);
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprFactory.java
index afc2bbb..15265f3 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprFactory.java
@@ -21,11 +21,9 @@ import java.math.BigDecimal;
import java.time.ZoneId;
import java.util.List;
import org.apache.hadoop.hive.ql.exec.ColumnInfo;
-import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
-import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException;
import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.RowResolver;
import org.apache.hadoop.hive.ql.parse.SemanticException;
-import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
import org.apache.hadoop.hive.ql.plan.SubqueryType;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
@@ -33,8 +31,7 @@ import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hive.common.util.DateUtils;
/**
- * Generic expressions factory. Currently, the only implementation produces
- * Hive {@link ExprNodeDesc}.
+ * Generic expressions factory.
*/
public abstract class ExprFactory<T> {
@@ -49,8 +46,14 @@ public abstract class ExprFactory<T> {
/**
* Generates an expression from the input column. This may not necessarily
* be a column expression, e.g., if the column is a constant.
+ *
+ * For position based expression factories (e.g., Calcite), an offset that
+ * will be added to the input references position can be provided. For
+ * instance, this is useful to generate expressions for right side of a
+ * join output.
*/
- protected abstract T toExpr(ColumnInfo colInfo);
+ protected abstract T toExpr(ColumnInfo colInfo, RowResolver rowResolver, int offset)
+ throws SemanticException;
/* FIELD REFERENCES */
/**
@@ -60,13 +63,25 @@ public abstract class ExprFactory<T> {
/**
* Creates column expression.
+ *
+ * For position based expression factories (e.g., Calcite), an offset that
+ * will be added to the input references position can be provided. For
+ * instance, this is useful to generate expressions for right side of a
+ * join output.
*/
- protected abstract T createColumnRefExpr(ColumnInfo colInfo);
+ protected abstract T createColumnRefExpr(ColumnInfo colInfo, RowResolver rowResolver, int offset)
+ throws SemanticException;
+
+ /**
+ * Creates column expression.
+ */
+ protected abstract T createColumnRefExpr(ColumnInfo colInfo, List<RowResolver> rowResolverList)
+ throws SemanticException;
/**
* Returns column name referenced by a column expression.
*/
- protected abstract String getColumnName(T expr);
+ protected abstract String getColumnName(T expr, RowResolver rowResolver);
/* CONSTANT EXPRESSIONS */
/**
@@ -130,7 +145,7 @@ public abstract class ExprFactory<T> {
/**
* Creates a double constant expression from input value.
*/
- protected abstract T createDoubleConstantExpr(String value);
+ protected abstract T createDoubleConstantExpr(String value) throws SemanticException;
/**
* Creates a decimal constant expression from input value.
@@ -205,7 +220,7 @@ public abstract class ExprFactory<T> {
* Default generator for constant expression when type cannot be inferred
* from input query.
*/
- protected T createConstantExpr(String value) {
+ protected T createConstantExpr(String value) throws SemanticException {
// The expression can be any one of Double, Long and Integer. We
// try to parse the expression in that order to ensure that the
// most specific type is used for conversion.
@@ -228,9 +243,16 @@ public abstract class ExprFactory<T> {
}
/**
+ * Creates a struct with given type.
+ */
+ protected abstract T createStructExpr(TypeInfo typeInfo, List<T> operands)
+ throws SemanticException;
+
+ /**
* Creates a constant expression from input value with given type.
*/
- protected abstract T createConstantExpr(TypeInfo typeInfo, Object constantValue);
+ protected abstract T createConstantExpr(TypeInfo typeInfo, Object constantValue)
+ throws SemanticException;
/**
* Adjust type of constant value based on input type, e.g., adjust precision and scale
@@ -249,12 +271,18 @@ public abstract class ExprFactory<T> {
*/
protected abstract Object getConstantValue(T expr);
+ /**
+ * Returns value stored in a constant expression as String.
+ */
+ protected abstract String getConstantValueAsString(T expr);
+
/* METHODS FOR NESTED FIELD REFERENCES CREATION */
/**
* Creates a reference to a nested field.
*/
protected abstract T createNestedColumnRefExpr(
- TypeInfo typeInfo, T expr, String fieldName, Boolean isList);
+ TypeInfo typeInfo, T expr, String fieldName, Boolean isList)
+ throws SemanticException;
/* FUNCTIONS */
/**
@@ -266,13 +294,13 @@ public abstract class ExprFactory<T> {
* Creates function call expression.
*/
protected abstract T createFuncCallExpr(TypeInfo typeInfo, GenericUDF genericUDF,
- List<T> inputs);
+ List<T> inputs) throws SemanticException;
/**
* Creates function call expression.
*/
protected abstract T createFuncCallExpr(GenericUDF genericUDF, String funcText,
- List<T> inputs) throws UDFArgumentException;
+ List<T> inputs) throws SemanticException;
/**
* Returns whether the input expression is an OR function call.
@@ -290,27 +318,26 @@ public abstract class ExprFactory<T> {
protected abstract boolean isPOSITIVEFuncCallExpr(T expr);
/**
- * Returns whether the input expression is a STRUCT function call.
+ * Returns whether the input expression is a NEGATIVE function call.
*/
- protected abstract boolean isSTRUCTFuncCallExpr(T expr);
+ protected abstract boolean isNEGATIVEFuncCallExpr(T expr);
/**
- * The method tries to rewrite an IN function call into an OR/AND function call.
- * Returns null if the transformation fails.
+ * Returns whether the input expression is a STRUCT function call.
*/
- protected abstract List<T> rewriteINIntoORFuncCallExpr(List<T> inOperands) throws SemanticException;
+ protected abstract boolean isSTRUCTFuncCallExpr(T expr);
/**
* Returns true if a CASE expression can be converted into a COALESCE function call.
*/
- protected abstract boolean canConvertCASEIntoCOALESCEFuncCallExpr(GenericUDF genericUDF, List<T> inputs);
+ protected abstract boolean convertCASEIntoCOALESCEFuncCallExpr(GenericUDF genericUDF, List<T> inputs);
/* SUBQUERIES */
/**
* Creates subquery expression.
*/
protected abstract T createSubqueryExpr(TypeCheckCtx ctx, ASTNode subqueryOp, SubqueryType subqueryType,
- Object[] inputs) throws CalciteSubquerySemanticException;
+ Object[] inputs) throws SemanticException;
/* LIST OF EXPRESSIONS */
/**
@@ -324,12 +351,10 @@ public abstract class ExprFactory<T> {
protected abstract T createExprsListExpr();
/**
- * Adds expression to list of expressions and returns resulting
- * list.
- * If column list is mutable, it will not create a copy
- * of the input list.
+ * Adds expression to list of expressions (list needs to be
+ * mutable).
*/
- protected abstract T addExprToExprsList(T columnList, T expr);
+ protected abstract void addExprToExprsList(T columnList, T expr);
/* TYPE SYSTEM */
/**
@@ -338,12 +363,17 @@ public abstract class ExprFactory<T> {
protected abstract TypeInfo getTypeInfo(T expr);
/**
+ * Returns the list of types in the input struct expression.
+ */
+ protected abstract List<TypeInfo> getStructTypeInfoList(T expr);
+
+ /**
* Changes the type of the input expression to the input type and
* returns resulting expression.
* If the input expression is mutable, it will not create a copy
* of the expression.
*/
- protected abstract T setTypeInfo(T expr, TypeInfo type);
+ protected abstract T setTypeInfo(T expr, TypeInfo type) throws SemanticException;
/* MISC */
/**
@@ -358,4 +388,9 @@ public abstract class ExprFactory<T> {
*/
protected abstract List<T> getExprChildren(T expr);
+ /**
+ * Returns the list of names in the input struct expression.
+ */
+ protected abstract List<String> getStructNameList(T expr);
+
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprNodeDescExprFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprNodeDescExprFactory.java
index 16d3546..5fd732e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprNodeDescExprFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprNodeDescExprFactory.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.calcite.rel.RelNode;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.hadoop.hive.common.type.Date;
@@ -36,12 +37,14 @@ import org.apache.hadoop.hive.common.type.TimestampTZ;
import org.apache.hadoop.hive.common.type.TimestampTZUtil;
import org.apache.hadoop.hive.ql.ErrorMsg;
import org.apache.hadoop.hive.ql.exec.ColumnInfo;
+import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.FunctionRegistry;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.optimizer.ConstantPropagateProcFactory;
import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException;
import org.apache.hadoop.hive.ql.optimizer.calcite.translator.TypeConverter;
import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.RowResolver;
import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeColumnListDesc;
@@ -53,6 +56,7 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeSubQueryDesc;
import org.apache.hadoop.hive.ql.plan.SubqueryType;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDFStruct;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDFWhen;
import org.apache.hadoop.hive.serde.serdeConstants;
import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector;
@@ -67,6 +71,7 @@ import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectIn
import org.apache.hadoop.hive.serde2.typeinfo.CharTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
@@ -94,7 +99,8 @@ public class ExprNodeDescExprFactory extends ExprFactory<ExprNodeDesc> {
* {@inheritDoc}
*/
@Override
- protected ExprNodeDesc toExpr(ColumnInfo colInfo) {
+ protected ExprNodeDesc toExpr(ColumnInfo colInfo, RowResolver rowResolver, int offset)
+ throws SemanticException {
ObjectInspector inspector = colInfo.getObjectInspector();
if (inspector instanceof ConstantObjectInspector && inspector instanceof PrimitiveObjectInspector) {
return toPrimitiveConstDesc(colInfo, inspector);
@@ -188,7 +194,15 @@ public class ExprNodeDescExprFactory extends ExprFactory<ExprNodeDesc> {
* {@inheritDoc}
*/
@Override
- protected ExprNodeColumnDesc createColumnRefExpr(ColumnInfo colInfo) {
+ protected ExprNodeColumnDesc createColumnRefExpr(ColumnInfo colInfo, RowResolver rowResolver, int offset) {
+ return new ExprNodeColumnDesc(colInfo);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ExprNodeColumnDesc createColumnRefExpr(ColumnInfo colInfo, List<RowResolver> rowResolverList) {
return new ExprNodeColumnDesc(colInfo);
}
@@ -345,7 +359,7 @@ public class ExprNodeDescExprFactory extends ExprFactory<ExprNodeDesc> {
String constTypeInfoName = sourceType.getTypeName();
if (constTypeInfoName.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) {
// because a comparison against a "string" will happen in "string" type.
- // to avoid unintnetional comparisions in "string"
+ // to avoid unintentional comparisons in "string"
// constants which are representing char/varchar values must be converted to the
// appropriate type.
if (targetType instanceof CharTypeInfo) {
@@ -497,6 +511,25 @@ public class ExprNodeDescExprFactory extends ExprFactory<ExprNodeDesc> {
* {@inheritDoc}
*/
@Override
+ protected ExprNodeDesc createStructExpr(TypeInfo typeInfo, List<ExprNodeDesc> operands)
+ throws SemanticException {
+ assert typeInfo instanceof StructTypeInfo;
+ if (isAllConstants(operands)) {
+ return createConstantExpr(typeInfo,
+ operands.stream()
+ .map(this::getConstantValue)
+ .collect(Collectors.toList()));
+ }
+ return ExprNodeGenericFuncDesc.newInstance(
+ new GenericUDFStruct(),
+ GenericUDFStruct.class.getAnnotation(Description.class).name(),
+ operands);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected ExprNodeConstantDesc createConstantExpr(TypeInfo typeInfo, Object constantValue) {
return new ExprNodeConstantDesc(typeInfo, constantValue);
}
@@ -540,10 +573,9 @@ public class ExprNodeDescExprFactory extends ExprFactory<ExprNodeDesc> {
* {@inheritDoc}
*/
@Override
- protected ExprNodeColumnListDesc addExprToExprsList(ExprNodeDesc columnList, ExprNodeDesc expr) {
+ protected void addExprToExprsList(ExprNodeDesc columnList, ExprNodeDesc expr) {
ExprNodeColumnListDesc l = (ExprNodeColumnListDesc) columnList;
l.addColumn(expr);
- return l;
}
/**
@@ -574,6 +606,14 @@ public class ExprNodeDescExprFactory extends ExprFactory<ExprNodeDesc> {
* {@inheritDoc}
*/
@Override
+ protected String getConstantValueAsString(ExprNodeDesc expr) {
+ return ((ExprNodeConstantDesc) expr).getValue().toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected boolean isColumnRefExpr(Object o) {
return o instanceof ExprNodeColumnDesc;
}
@@ -582,7 +622,7 @@ public class ExprNodeDescExprFactory extends ExprFactory<ExprNodeDesc> {
* {@inheritDoc}
*/
@Override
- protected String getColumnName(ExprNodeDesc expr) {
+ protected String getColumnName(ExprNodeDesc expr, RowResolver rowResolver) {
return ((ExprNodeColumnDesc) expr).getColumn();
}
@@ -614,8 +654,18 @@ public class ExprNodeDescExprFactory extends ExprFactory<ExprNodeDesc> {
* {@inheritDoc}
*/
@Override
- protected List<ExprNodeDesc> rewriteINIntoORFuncCallExpr(List<ExprNodeDesc> inOperands) throws SemanticException {
- return TypeCheckProcFactoryUtils.rewriteInToOR(inOperands);
+ protected List<TypeInfo> getStructTypeInfoList(ExprNodeDesc expr) {
+ StructTypeInfo structTypeInfo = (StructTypeInfo) expr.getTypeInfo();
+ return structTypeInfo.getAllStructFieldTypeInfos();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected List<String> getStructNameList(ExprNodeDesc expr) {
+ StructTypeInfo structTypeInfo = (StructTypeInfo) expr.getTypeInfo();
+ return structTypeInfo.getAllStructFieldNames();
}
/**
@@ -646,6 +696,14 @@ public class ExprNodeDescExprFactory extends ExprFactory<ExprNodeDesc> {
* {@inheritDoc}
*/
@Override
+ protected boolean isNEGATIVEFuncCallExpr(ExprNodeDesc expr) {
+ return FunctionRegistry.isOpNegative(expr);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected ExprNodeDesc setTypeInfo(ExprNodeDesc expr, TypeInfo type) {
expr.setTypeInfo(type);
return expr;
@@ -655,7 +713,7 @@ public class ExprNodeDescExprFactory extends ExprFactory<ExprNodeDesc> {
* {@inheritDoc}
*/
@Override
- protected boolean canConvertCASEIntoCOALESCEFuncCallExpr(GenericUDF genericUDF, List<ExprNodeDesc> inputs) {
+ protected boolean convertCASEIntoCOALESCEFuncCallExpr(GenericUDF genericUDF, List<ExprNodeDesc> inputs) {
if (genericUDF instanceof GenericUDFWhen && inputs.size() == 3 &&
inputs.get(1) instanceof ExprNodeConstantDesc &&
inputs.get(2) instanceof ExprNodeConstantDesc) {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprNodeTypeCheck.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprNodeTypeCheck.java
index 623b280..3e3d331 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprNodeTypeCheck.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprNodeTypeCheck.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.hive.ql.parse.type;
import java.util.Map;
import org.apache.hadoop.hive.ql.exec.ColumnInfo;
import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.RowResolver;
import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
@@ -68,8 +69,10 @@ public class ExprNodeTypeCheck {
/**
* Transforms column information into the corresponding Hive ExprNode.
*/
- public static ExprNodeDesc toExprNodeDesc(ColumnInfo columnInfo) {
+ public static ExprNodeDesc toExprNode(ColumnInfo columnInfo, RowResolver rowResolver)
+ throws SemanticException {
ExprNodeDescExprFactory factory = new ExprNodeDescExprFactory();
- return factory.toExpr(columnInfo);
+ return factory.toExpr(columnInfo, rowResolver, 0);
}
+
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/FunctionHelper.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/FunctionHelper.java
new file mode 100644
index 0000000..944be83
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/FunctionHelper.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.parse.type;
+
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rex.RexNode;
+import org.apache.hadoop.hive.ql.exec.FunctionInfo;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
+
+/**
+ * Interface to handle function information while generating
+ * Calcite {@link RexNode}.
+ */
+public interface FunctionHelper {
+
+ /**
+ * Returns function information based on function text.
+ */
+ FunctionInfo getFunctionInfo(String functionText) throws SemanticException;
+
+ /**
+ * Given function information and its inputs, it returns
+ * the type of the output of the function.
+ */
+ RelDataType getReturnType(FunctionInfo functionInfo, List<RexNode> inputs)
+ throws SemanticException;
+
+ /**
+ * Given function information, the inputs to that function, and the
+ * expected return type, it will return the list of inputs with any
+ * necessary adjustments, e.g., casting of expressions.
+ */
+ List<RexNode> convertInputs(FunctionInfo functionInfo, List<RexNode> inputs,
+ RelDataType returnType)
+ throws SemanticException;
+
+ /**
+ * Given function information and text, inputs to a function, and the
+ * expected return type, it will return an expression node containing
+ * the function call.
+ */
+ RexNode getExpression(String functionText, FunctionInfo functionInfo,
+ List<RexNode> inputs, RelDataType returnType)
+ throws SemanticException;
+
+ /**
+ * Returns aggregation information based on given parameters.
+ */
+ AggregateInfo getAggregateFunctionInfo(boolean isDistinct, boolean isAllColumns,
+ String aggregateName, List<RexNode> aggregateParameters)
+ throws SemanticException;
+
+ /**
+ * Returns aggregation information for analytical function based on given parameters.
+ */
+ AggregateInfo getWindowAggregateFunctionInfo(boolean isDistinct, boolean isAllColumns,
+ String aggregateName, List<RexNode> aggregateParameters)
+ throws SemanticException;
+
+ /**
+ * Folds expression according to function semantics.
+ */
+ default RexNode foldExpression(RexNode expr) {
+ return expr;
+ }
+
+ /**
+ * Class to store aggregate function related information.
+ */
+ class AggregateInfo {
+ private final List<RexNode> parameters;
+ private final TypeInfo returnType;
+ private final String aggregateName;
+ private final boolean distinct;
+
+ public AggregateInfo(List<RexNode> parameters, TypeInfo returnType, String aggregateName,
+ boolean distinct) {
+ this.parameters = ImmutableList.copyOf(parameters);
+ this.returnType = returnType;
+ this.aggregateName = aggregateName;
+ this.distinct = distinct;
+ }
+
+ public List<RexNode> getParameters() {
+ return parameters;
+ }
+
+ public TypeInfo getReturnType() {
+ return returnType;
+ }
+
+ public String getAggregateName() {
+ return aggregateName;
+ }
+
+ public boolean isDistinct() {
+ return distinct;
+ }
+ }
+
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/HiveFunctionHelper.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/HiveFunctionHelper.java
new file mode 100644
index 0000000..07813b9
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/HiveFunctionHelper.java
@@ -0,0 +1,549 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.parse.type;
+
+import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexLiteral;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.rex.RexVisitor;
+import org.apache.calcite.rex.RexVisitorImpl;
+import org.apache.calcite.sql.SqlBinaryOperator;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.util.Util;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.exec.FunctionInfo;
+import org.apache.hadoop.hive.ql.exec.FunctionRegistry;
+import org.apache.hadoop.hive.ql.metadata.Hive;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveRexExecutorImpl;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveExtractDate;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFloorDate;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveToDateSqlOperator;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveToUnixTimestampSqlOperator;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveUnixTimestampSqlOperator;
+import org.apache.hadoop.hive.ql.optimizer.calcite.translator.ExprNodeConverter;
+import org.apache.hadoop.hive.ql.optimizer.calcite.translator.SqlFunctionConverter;
+import org.apache.hadoop.hive.ql.optimizer.calcite.translator.RexNodeConverter;
+import org.apache.hadoop.hive.ql.optimizer.calcite.translator.TypeConverter;
+import org.apache.hadoop.hive.ql.parse.SemanticAnalyzer;
+import org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.GenericUDAFInfo;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc;
+import org.apache.hadoop.hive.ql.plan.ExprNodeDescUtils;
+import org.apache.hadoop.hive.ql.plan.GroupByDesc;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.Mode;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBaseBinary;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBaseCompare;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBetween;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDFIn;
+import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils.ObjectInspectorCopyOption;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveGrouping;
+import org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.MapTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Function helper for Hive.
+ */
+public class HiveFunctionHelper implements FunctionHelper {
+
+ private static final Logger LOG = LoggerFactory.getLogger(HiveFunctionHelper.class);
+
+ private final RexBuilder rexBuilder;
+ private final int maxNodesForInToOrTransformation;
+
+ public HiveFunctionHelper(RexBuilder rexBuilder) {
+ this.rexBuilder = rexBuilder;
+ try {
+ this.maxNodesForInToOrTransformation = HiveConf.getIntVar(
+ Hive.get().getConf(), HiveConf.ConfVars.HIVEOPT_TRANSFORM_IN_MAXNODES);
+ } catch (HiveException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public FunctionInfo getFunctionInfo(String functionText)
+ throws SemanticException {
+ return FunctionRegistry.getFunctionInfo(functionText);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public RelDataType getReturnType(FunctionInfo fi, List<RexNode> inputs)
+ throws SemanticException {
+ // 1) Gather inputs
+ ObjectInspector[] inputsOIs = new ObjectInspector[inputs.size()];
+ for (int i = 0; i < inputsOIs.length; i++) {
+ inputsOIs[i] = createObjectInspector(inputs.get(i));
+ }
+ // 2) Initialize and obtain return type
+ ObjectInspector oi = fi.getGenericUDF() != null ?
+ fi.getGenericUDF().initializeAndFoldConstants(inputsOIs) :
+ fi.getGenericUDTF().initialize(inputsOIs);
+ // 3) Convert to RelDataType
+ return TypeConverter.convert(
+ TypeInfoUtils.getTypeInfoFromObjectInspector(oi), rexBuilder.getTypeFactory());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<RexNode> convertInputs(FunctionInfo fi, List<RexNode> inputs,
+ RelDataType returnType)
+ throws SemanticException {
+ // 1) Obtain UDF
+ final GenericUDF genericUDF = fi.getGenericUDF();
+ final TypeInfo typeInfo = TypeConverter.convert(returnType);
+ TypeInfo targetType = null;
+
+ boolean isNumeric = genericUDF instanceof GenericUDFBaseBinary
+ && typeInfo.getCategory() == Category.PRIMITIVE
+ && PrimitiveGrouping.NUMERIC_GROUP == PrimitiveObjectInspectorUtils.getPrimitiveGrouping(((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory());
+ boolean isCompare = !isNumeric && genericUDF instanceof GenericUDFBaseCompare;
+ boolean isBetween = !isNumeric && genericUDF instanceof GenericUDFBetween;
+ boolean isIN = !isNumeric && genericUDF instanceof GenericUDFIn;
+
+ if (isNumeric) {
+ targetType = typeInfo;
+ } else if (genericUDF instanceof GenericUDFBaseCompare) {
+ targetType = FunctionRegistry.getCommonClassForComparison(
+ TypeConverter.convert(inputs.get(0).getType()),
+ TypeConverter.convert(inputs.get(1).getType()));
+ } else if (genericUDF instanceof GenericUDFBetween) {
+ assert inputs.size() == 4;
+ // We skip first child as is not involved (is the revert boolean)
+ // The target type needs to account for all 3 operands
+ targetType = FunctionRegistry.getCommonClassForComparison(
+ TypeConverter.convert(inputs.get(1).getType()),
+ FunctionRegistry.getCommonClassForComparison(
+ TypeConverter.convert(inputs.get(2).getType()),
+ TypeConverter.convert(inputs.get(3).getType())));
+ } else if (genericUDF instanceof GenericUDFIn) {
+ // We're only considering the first element of the IN list for the type
+ assert inputs.size() > 1;
+ targetType = FunctionRegistry.getCommonClassForComparison(
+ TypeConverter.convert(inputs.get(0).getType()),
+ TypeConverter.convert(inputs.get(1).getType()));
+ }
+
+ if (targetType != null) {
+ List<RexNode> newInputs = new ArrayList<>();
+ // Convert inputs if needed
+ for (int i = 0; i < inputs.size(); ++i) {
+ RexNode input = inputs.get(i);
+ TypeInfo inputTypeInfo = TypeConverter.convert(input.getType());
+ RexNode tmpExprNode = input;
+ if (TypeInfoUtils.isConversionRequiredForComparison(targetType, inputTypeInfo)) {
+ if (isIN || isCompare) {
+ // For IN and compare, we will convert requisite children
+ tmpExprNode = convert(targetType, input);
+ } else if (isBetween) {
+ // For BETWEEN skip the first child (the revert boolean)
+ if (i > 0) {
+ tmpExprNode = convert(targetType, input);
+ }
+ } else if (isNumeric) {
+ // For numeric, we'll do minimum necessary cast - if we cast to the type
+ // of expression, bad things will happen.
+ PrimitiveTypeInfo minArgType = ExprNodeDescUtils.deriveMinArgumentCast(inputTypeInfo, targetType);
+ tmpExprNode = convert(minArgType, input);
+ } else {
+ throw new AssertionError("Unexpected " + targetType + " - not a numeric op or compare");
+ }
+ }
+
+ newInputs.add(tmpExprNode);
+ }
+ return newInputs;
+ }
+ return inputs;
+ }
+
+ private RexNode convert(TypeInfo targetType, RexNode input) throws SemanticException {
+ if (targetType.getCategory() == Category.PRIMITIVE) {
+ return RexNodeTypeCheck.getExprNodeDefaultExprProcessor(rexBuilder)
+ .createConversionCast(input, (PrimitiveTypeInfo) targetType);
+ } else {
+ StructTypeInfo structTypeInfo = (StructTypeInfo) targetType; // struct
+ RexCall call = (RexCall) input;
+ List<RexNode> exprNodes = new ArrayList<>();
+ for (int j = 0; j < structTypeInfo.getAllStructFieldTypeInfos().size(); j++) {
+ exprNodes.add(
+ convert(
+ structTypeInfo.getAllStructFieldTypeInfos().get(j), call.getOperands().get(j)));
+ }
+ return rexBuilder.makeCall(SqlStdOperatorTable.ROW, exprNodes);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public RexNode getExpression(String functionText, FunctionInfo fi,
+ List<RexNode> inputs, RelDataType returnType)
+ throws SemanticException {
+ // See if this is an explicit cast.
+ RexNode expr = RexNodeConverter.handleExplicitCast(
+ fi.getGenericUDF(), returnType, inputs, rexBuilder);
+
+ if (expr == null) {
+ // This is not a cast; process the function.
+ ImmutableList.Builder<RelDataType> argsTypes = ImmutableList.builder();
+ for (RexNode input : inputs) {
+ argsTypes.add(input.getType());
+ }
+ SqlOperator calciteOp = SqlFunctionConverter.getCalciteOperator(functionText,
+ fi.getGenericUDF(), argsTypes.build(), returnType);
+ if (calciteOp.getKind() == SqlKind.CASE) {
+ // If it is a case operator, we need to rewrite it
+ inputs = RexNodeConverter.rewriteCaseChildren(functionText, inputs, rexBuilder);
+ // Adjust branch types by inserting explicit casts if the actual is ambigous
+ inputs = RexNodeConverter.adjustCaseBranchTypes(inputs, returnType, rexBuilder);
+ checkForStatefulFunctions(inputs);
+ } else if (HiveExtractDate.ALL_FUNCTIONS.contains(calciteOp)) {
+ // If it is a extract operator, we need to rewrite it
+ inputs = RexNodeConverter.rewriteExtractDateChildren(calciteOp, inputs, rexBuilder);
+ } else if (HiveFloorDate.ALL_FUNCTIONS.contains(calciteOp)) {
+ // If it is a floor <date> operator, we need to rewrite it
+ inputs = RexNodeConverter.rewriteFloorDateChildren(calciteOp, inputs, rexBuilder);
+ } else if (calciteOp.getKind() == SqlKind.IN) {
+ // if it is a single item in an IN clause, transform A IN (B) to A = B
+ // from IN [A,B] => EQUALS [A,B]
+ // if it is more than an single item in an IN clause,
+ // transform from IN [A,B,C] => OR [EQUALS [A,B], EQUALS [A,C]]
+ // Rewrite to OR is done only if number of operands are less than
+ // the threshold configured
+ boolean rewriteToOr = true;
+ if(maxNodesForInToOrTransformation != 0) {
+ if(inputs.size() > maxNodesForInToOrTransformation) {
+ rewriteToOr = false;
+ }
+ }
+ if(rewriteToOr) {
+ // If there are non-deterministic functions, we cannot perform this rewriting
+ List<RexNode> newInputs = RexNodeConverter.transformInToOrOperands(inputs, rexBuilder);
+ if (newInputs != null) {
+ inputs = newInputs;
+ if (inputs.size() == 1) {
+ inputs.add(rexBuilder.makeLiteral(false));
+ }
+ calciteOp = SqlStdOperatorTable.OR;
+ }
+ }
+ } else if (calciteOp.getKind() == SqlKind.COALESCE &&
+ inputs.size() > 1) {
+ // Rewrite COALESCE as a CASE
+ // This allows to be further reduced to OR, if possible
+ calciteOp = SqlStdOperatorTable.CASE;
+ inputs = RexNodeConverter.rewriteCoalesceChildren(inputs, rexBuilder);
+ // Adjust branch types by inserting explicit casts if the actual is ambigous
+ inputs = RexNodeConverter.adjustCaseBranchTypes(inputs, returnType, rexBuilder);
+ checkForStatefulFunctions(inputs);
+ } else if (calciteOp == HiveToDateSqlOperator.INSTANCE) {
+ inputs = RexNodeConverter.rewriteToDateChildren(inputs, rexBuilder);
+ } else if (calciteOp.getKind() == SqlKind.BETWEEN) {
+ assert inputs.get(0).isAlwaysTrue() || inputs.get(0).isAlwaysFalse();
+ boolean invert = inputs.get(0).isAlwaysTrue();
+ SqlBinaryOperator cmpOp;
+ if (invert) {
+ calciteOp = SqlStdOperatorTable.OR;
+ cmpOp = SqlStdOperatorTable.GREATER_THAN;
+ } else {
+ calciteOp = SqlStdOperatorTable.AND;
+ cmpOp = SqlStdOperatorTable.LESS_THAN_OR_EQUAL;
+ }
+ RexNode op = inputs.get(1);
+ RexNode rangeL = inputs.get(2);
+ RexNode rangeH = inputs.get(3);
+ inputs = new ArrayList<>();
+ inputs.add(rexBuilder.makeCall(cmpOp, rangeL, op));
+ inputs.add(rexBuilder.makeCall(cmpOp, op, rangeH));
+ } else if (calciteOp == HiveUnixTimestampSqlOperator.INSTANCE &&
+ inputs.size() > 0) {
+ // unix_timestamp(args) -> to_unix_timestamp(args)
+ calciteOp = HiveToUnixTimestampSqlOperator.INSTANCE;
+ }
+ expr = rexBuilder.makeCall(returnType, calciteOp, inputs);
+ }
+
+ if (expr instanceof RexCall && !expr.isA(SqlKind.CAST)) {
+ RexCall call = (RexCall) expr;
+ expr = rexBuilder.makeCall(returnType, call.getOperator(),
+ RexUtil.flatten(call.getOperands(), call.getOperator()));
+ }
+
+ return expr;
+ }
+
+ private void checkForStatefulFunctions(List<RexNode> exprs)
+ throws SemanticException {
+ RexVisitor<Void> visitor = new RexVisitorImpl<Void>(true) {
+ @Override
+ public Void visitCall(final RexCall call) {
+ // TODO: We should be able to annotate functions in Calcite as stateful
+ // so we do not have to map back and forth to Hive functions when we are
+ // doing this check.
+ GenericUDF nodeUDF = SqlFunctionConverter.getHiveUDF(
+ call.getOperator(), call.getType(), call.getOperands().size());
+ if (nodeUDF == null) {
+ throw new AssertionError("Cannot retrieve function " + call.getOperator().getName()
+ + " within StatefulFunctionsChecker");
+ }
+ // Stateful?
+ if (FunctionRegistry.isStateful(nodeUDF)) {
+ throw new Util.FoundOne(call);
+ }
+ return super.visitCall(call);
+ }
+ };
+
+ try {
+ for (RexNode expr : exprs) {
+ expr.accept(visitor);
+ }
+ } catch (Util.FoundOne e) {
+ throw new SemanticException("Stateful expressions cannot be used inside of CASE");
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AggregateInfo getAggregateFunctionInfo(boolean isDistinct, boolean isAllColumns,
+ String aggregateName, List<RexNode> aggregateParameters)
+ throws SemanticException {
+ Mode udafMode = SemanticAnalyzer.groupByDescModeToUDAFMode(
+ GroupByDesc.Mode.COMPLETE, isDistinct);
+ List<ObjectInspector> aggParameterOIs = new ArrayList<>();
+ for (RexNode aggParameter : aggregateParameters) {
+ aggParameterOIs.add(createObjectInspector(aggParameter));
+ }
+ GenericUDAFEvaluator genericUDAFEvaluator = SemanticAnalyzer.getGenericUDAFEvaluator2(
+ aggregateName, aggParameterOIs, null, isDistinct, isAllColumns);
+ assert (genericUDAFEvaluator != null);
+ GenericUDAFInfo udaf = SemanticAnalyzer.getGenericUDAFInfo2(
+ genericUDAFEvaluator, udafMode, aggParameterOIs);
+ return new AggregateInfo(aggregateParameters, udaf.returnType, aggregateName, isDistinct);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AggregateInfo getWindowAggregateFunctionInfo(boolean isDistinct, boolean isAllColumns,
+ String aggregateName, List<RexNode> aggregateParameters)
+ throws SemanticException {
+ TypeInfo returnType = null;
+
+ if (FunctionRegistry.isRankingFunction(aggregateName)) {
+ // Rank functions type is 'int'/'double'
+ if (aggregateName.equalsIgnoreCase("percent_rank")) {
+ returnType = TypeInfoFactory.doubleTypeInfo;
+ } else {
+ returnType = TypeInfoFactory.intTypeInfo;
+ }
+ } else {
+ // Try obtaining UDAF evaluators to determine the ret type
+ try {
+ Mode udafMode = SemanticAnalyzer.groupByDescModeToUDAFMode(
+ GroupByDesc.Mode.COMPLETE, isDistinct);
+ List<ObjectInspector> aggParameterOIs = new ArrayList<>();
+ for (RexNode aggParameter : aggregateParameters) {
+ aggParameterOIs.add(createObjectInspector(aggParameter));
+ }
+ if (aggregateName.toLowerCase().equals(FunctionRegistry.LEAD_FUNC_NAME)
+ || aggregateName.toLowerCase().equals(FunctionRegistry.LAG_FUNC_NAME)) {
+ GenericUDAFEvaluator genericUDAFEvaluator = FunctionRegistry.getGenericWindowingEvaluator(aggregateName,
+ aggParameterOIs, isDistinct, isAllColumns);
+ GenericUDAFInfo udaf = SemanticAnalyzer.getGenericUDAFInfo2(
+ genericUDAFEvaluator, udafMode, aggParameterOIs);
+ returnType = ((ListTypeInfo) udaf.returnType).getListElementTypeInfo();
+ } else {
+ GenericUDAFEvaluator genericUDAFEvaluator = SemanticAnalyzer.getGenericUDAFEvaluator2(
+ aggregateName, aggParameterOIs, null, isDistinct, isAllColumns);
+ assert (genericUDAFEvaluator != null);
+ GenericUDAFInfo udaf = SemanticAnalyzer.getGenericUDAFInfo2(
+ genericUDAFEvaluator, udafMode, aggParameterOIs);
+ if (FunctionRegistry.pivotResult(aggregateName)) {
+ returnType = ((ListTypeInfo) udaf.returnType).getListElementTypeInfo();
+ } else {
+ returnType = udaf.returnType;
+ }
+ }
+ } catch (Exception e) {
+ LOG.debug("CBO: Couldn't Obtain UDAF evaluators for " + aggregateName
+ + ", trying to translate to GenericUDF");
+ }
+ }
+
+ return returnType != null ?
+ new AggregateInfo(aggregateParameters, returnType, aggregateName, isDistinct) : null;
+ }
+
+ private ObjectInspector createObjectInspector(RexNode expr) {
+ ObjectInspector oi = createConstantObjectInspector(expr);
+ if (oi != null) {
+ return oi;
+ }
+ return TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(
+ TypeConverter.convert(expr.getType()));
+ }
+
+ /**
+ * Returns constant object inspector or null if it could not be generated.
+ */
+ private ConstantObjectInspector createConstantObjectInspector(RexNode expr) {
+ if (RexUtil.isLiteral(expr, true)) { // Literal or cast on literal
+ final ExprNodeConstantDesc constant;
+ if (expr.isA(SqlKind.LITERAL)) {
+ constant = ExprNodeConverter.toExprNodeConstantDesc((RexLiteral) expr);
+ } else {
+ RexNode foldedExpr = foldExpression(expr);
+ if (!foldedExpr.isA(SqlKind.LITERAL)) {
+ // Constant could not be generated
+ return null;
+ }
+ constant = ExprNodeConverter.toExprNodeConstantDesc((RexLiteral) foldedExpr);
+ }
+ PrimitiveTypeInfo typeInfo = (PrimitiveTypeInfo) constant.getTypeInfo();
+ Object value = constant.getValue();
+ Object writableValue = value == null ? null :
+ PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(typeInfo)
+ .getPrimitiveWritableObject(value);
+ return PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
+ typeInfo, writableValue);
+ } else if (expr instanceof RexCall) {
+ RexCall call = (RexCall) expr;
+ if (call.getOperator() == SqlStdOperatorTable.ROW) { // Struct
+ List<String> fieldNames = new ArrayList<>();
+ List<ObjectInspector> fieldObjectInspectors = new ArrayList<>();
+ List<Object> writableValues = new ArrayList<>();
+ for (int i = 0; i < call.getOperands().size(); i++) {
+ RexNode input = call.getOperands().get(i);
+ ConstantObjectInspector objectInspector = createConstantObjectInspector(input);
+ if (objectInspector == null) {
+ // Constant could not be generated
+ return null;
+ }
+ fieldNames.add(expr.getType().getFieldList().get(i).getName());
+ fieldObjectInspectors.add(objectInspector);
+ writableValues.add(objectInspector.getWritableConstantValue());
+ }
+ return ObjectInspectorFactory.getStandardConstantStructObjectInspector(
+ fieldNames,
+ fieldObjectInspectors,
+ writableValues);
+ } else if (call.getOperator() == SqlStdOperatorTable.ARRAY_VALUE_CONSTRUCTOR) { // List
+ ListTypeInfo listTypeInfo = (ListTypeInfo) TypeConverter.convert(expr.getType());
+ TypeInfo typeInfo = listTypeInfo.getListElementTypeInfo();
+ List<Object> writableValues = new ArrayList<>();
+ for (RexNode input : call.getOperands()) {
+ ConstantObjectInspector objectInspector = createConstantObjectInspector(input);
+ if (objectInspector == null) {
+ // Constant could not be generated
+ return null;
+ }
+ writableValues.add(objectInspector.getWritableConstantValue());
+ }
+ return ObjectInspectorFactory.getStandardConstantListObjectInspector(
+ ObjectInspectorUtils.getStandardObjectInspector(
+ TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(typeInfo),
+ ObjectInspectorCopyOption.WRITABLE),
+ writableValues);
+ } else if (call.getOperator() == SqlStdOperatorTable.MAP_VALUE_CONSTRUCTOR) { // Map
+ MapTypeInfo mapTypeInfo = (MapTypeInfo) TypeConverter.convert(expr.getType());
+ Map<Object, Object> writableValues = new HashMap<>();
+ Iterator<RexNode> it = call.getOperands().iterator();
+ while (it.hasNext()) {
+ ConstantObjectInspector keyObjectInspector = createConstantObjectInspector(it.next());
+ if (keyObjectInspector == null) {
+ // Constant could not be generated
+ return null;
+ }
+ ConstantObjectInspector valueObjectInspector = createConstantObjectInspector(it.next());
+ if (valueObjectInspector == null) {
+ // Constant could not be generated
+ return null;
+ }
+ writableValues.put(
+ keyObjectInspector.getWritableConstantValue(),
+ valueObjectInspector.getWritableConstantValue());
+ }
+ return ObjectInspectorFactory.getStandardConstantMapObjectInspector(
+ ObjectInspectorUtils.getStandardObjectInspector(
+ TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(mapTypeInfo.getMapKeyTypeInfo()),
+ ObjectInspectorCopyOption.WRITABLE),
+ ObjectInspectorUtils.getStandardObjectInspector(
+ TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(mapTypeInfo.getMapValueTypeInfo()),
+ ObjectInspectorCopyOption.WRITABLE),
+ writableValues);
+ }
+ }
+ // Constant could not be generated
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public RexNode foldExpression(RexNode expr) {
+ HiveRexExecutorImpl executor = new HiveRexExecutorImpl();
+ List<RexNode> result = new ArrayList<>();
+ executor.reduce(rexBuilder, ImmutableList.of(expr), result);
+ return result.get(0);
+ }
+
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/JoinCondTypeCheckProcFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/JoinCondTypeCheckProcFactory.java
index 319bae6..309a34e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/JoinCondTypeCheckProcFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/JoinCondTypeCheckProcFactory.java
@@ -86,7 +86,7 @@ public class JoinCondTypeCheckProcFactory<T> extends TypeCheckProcFactory<T> {
if (!qualifiedAccess) {
colInfo = getColInfo(ctx, null, tableOrCol, expr);
// It's a column.
- return exprFactory.createColumnRefExpr(colInfo);
+ return exprFactory.createColumnRefExpr(colInfo, ctx.getInputRRList());
} else if (hasTableAlias(ctx, tableOrCol, expr)) {
return null;
} else {
@@ -160,12 +160,13 @@ public class JoinCondTypeCheckProcFactory<T> extends TypeCheckProcFactory<T> {
@Override
protected T processQualifiedColRef(TypeCheckCtx ctx, ASTNode expr,
Object... nodeOutputs) throws SemanticException {
+ JoinTypeCheckCtx jctx = (JoinTypeCheckCtx) ctx;
String tableAlias = BaseSemanticAnalyzer.unescapeIdentifier(expr.getChild(0).getChild(0)
.getText());
// NOTE: tableAlias must be a valid non-ambiguous table alias,
// because we've checked that in TOK_TABLE_OR_COL's process method.
ColumnInfo colInfo = getColInfo((JoinTypeCheckCtx) ctx, tableAlias,
- exprFactory.getConstantValue((T) nodeOutputs[1]).toString(), expr);
+ exprFactory.getConstantValueAsString((T) nodeOutputs[1]), expr);
if (colInfo == null) {
ctx.setError(ASTErrorUtils.getMsg(
@@ -174,7 +175,7 @@ public class JoinCondTypeCheckProcFactory<T> extends TypeCheckProcFactory<T> {
}
ColumnInfo newColumnInfo = new ColumnInfo(colInfo);
newColumnInfo.setTabAlias(tableAlias);
- return exprFactory.createColumnRefExpr(newColumnInfo);
+ return exprFactory.createColumnRefExpr(newColumnInfo, jctx.getInputRRList());
}
private ColumnInfo getColInfo(JoinTypeCheckCtx ctx, String tabName, String colAlias,
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/RexNodeExprFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/RexNodeExprFactory.java
new file mode 100644
index 0000000..0d00713
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/RexNodeExprFactory.java
@@ -0,0 +1,1010 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.parse.type;
+
+import com.google.common.collect.ImmutableList;
+import java.math.BigDecimal;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.calcite.avatica.util.TimeUnit;
+import org.apache.calcite.plan.RelOptCluster;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexLiteral;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexSubQuery;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.sql.SqlCollation;
+import org.apache.calcite.sql.SqlIntervalQualifier;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.fun.SqlQuantifyOperator;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.util.ConversionUtil;
+import org.apache.calcite.util.DateString;
+import org.apache.calcite.util.NlsString;
+import org.apache.calcite.util.TimestampString;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.apache.hadoop.hive.common.type.Date;
+import org.apache.hadoop.hive.common.type.HiveChar;
+import org.apache.hadoop.hive.common.type.HiveDecimal;
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
+import org.apache.hadoop.hive.common.type.HiveVarchar;
+import org.apache.hadoop.hive.common.type.Timestamp;
+import org.apache.hadoop.hive.common.type.TimestampTZ;
+import org.apache.hadoop.hive.common.type.TimestampTZUtil;
+import org.apache.hadoop.hive.ql.ErrorMsg;
+import org.apache.hadoop.hive.ql.exec.ColumnInfo;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.FunctionInfo;
+import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException;
+import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException.UnsupportedFeature;
+import org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException;
+import org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveRexExprList;
+import org.apache.hadoop.hive.ql.optimizer.calcite.translator.TypeConverter;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.RowResolver;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.hive.ql.parse.type.RexNodeExprFactory.HiveNlsString.Interpretation;
+import org.apache.hadoop.hive.ql.plan.SubqueryType;
+import org.apache.hadoop.hive.ql.udf.SettableUDF;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDFWhen;
+import org.apache.hadoop.hive.serde.serdeConstants;
+import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry;
+import org.apache.hadoop.hive.serde2.typeinfo.CharTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
+import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Expression factory for Calcite {@link RexNode}.
+ */
+public class RexNodeExprFactory extends ExprFactory<RexNode> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RexNodeExprFactory.class);
+
+ private final RexBuilder rexBuilder;
+ private final FunctionHelper functionHelper;
+
+ public RexNodeExprFactory(RexBuilder rexBuilder) {
+ this.rexBuilder = rexBuilder;
+ this.functionHelper = new HiveFunctionHelper(rexBuilder);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isExprInstance(Object o) {
+ return o instanceof RexNode;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode toExpr(ColumnInfo colInfo, RowResolver rowResolver, int offset)
+ throws CalciteSemanticException {
+ ObjectInspector inspector = colInfo.getObjectInspector();
+ if (inspector instanceof ConstantObjectInspector && inspector instanceof PrimitiveObjectInspector) {
+ return toPrimitiveConstDesc(colInfo, inspector, rexBuilder);
+ }
+ int index = rowResolver.getPosition(colInfo.getInternalName());
+ if (index < 0) {
+ throw new CalciteSemanticException("Unexpected error: Cannot find column");
+ }
+ return rexBuilder.makeInputRef(
+ TypeConverter.convert(colInfo.getType(), rexBuilder.getTypeFactory()), index + offset);
+ }
+
+ private static RexNode toPrimitiveConstDesc(
+ ColumnInfo colInfo, ObjectInspector inspector, RexBuilder rexBuilder)
+ throws CalciteSemanticException {
+ Object constant = ((ConstantObjectInspector) inspector).getWritableConstantValue();
+ return rexBuilder.makeLiteral(constant,
+ TypeConverter.convert(colInfo.getType(), rexBuilder.getTypeFactory()),
+ false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createColumnRefExpr(ColumnInfo colInfo, RowResolver rowResolver, int offset)
+ throws CalciteSemanticException {
+ int index = rowResolver.getPosition(colInfo.getInternalName());
+ return rexBuilder.makeInputRef(
+ TypeConverter.convert(colInfo.getType(), rexBuilder.getTypeFactory()), index + offset);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createColumnRefExpr(ColumnInfo colInfo, List<RowResolver> rowResolverList)
+ throws SemanticException {
+ int index = getPosition(colInfo, rowResolverList);
+ return rexBuilder.makeInputRef(
+ TypeConverter.convert(colInfo.getType(), rexBuilder.getTypeFactory()), index);
+ }
+
+ private int getPosition(ColumnInfo colInfo, List<RowResolver> rowResolverList)
+ throws SemanticException {
+ ColumnInfo tmp;
+ ColumnInfo cInfoToRet = null;
+ int position = 0;
+ for (RowResolver rr : rowResolverList) {
+ tmp = rr.get(colInfo.getTabAlias(), colInfo.getAlias());
+ if (tmp != null) {
+ if (cInfoToRet != null) {
+ throw new CalciteSemanticException("Could not resolve column name");
+ }
+ cInfoToRet = tmp;
+ position += rr.getPosition(cInfoToRet.getInternalName());
+ } else if (cInfoToRet == null) {
+ position += rr.getColumnInfos().size();
+ }
+ }
+ return position;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createNullConstantExpr() {
+ return rexBuilder.makeNullLiteral(
+ rexBuilder.getTypeFactory().createSqlType(SqlTypeName.NULL));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createBooleanConstantExpr(String value) {
+ Boolean b = value != null ? Boolean.valueOf(value) : null;
+ return rexBuilder.makeLiteral(b,
+ rexBuilder.getTypeFactory().createSqlType(SqlTypeName.BOOLEAN),
+ false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createBigintConstantExpr(String value) {
+ return rexBuilder.makeLiteral(
+ new BigDecimal(Long.valueOf(value)),
+ rexBuilder.getTypeFactory().createSqlType(SqlTypeName.BIGINT),
+ false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createIntConstantExpr(String value) {
+ return rexBuilder.makeLiteral(
+ new BigDecimal(Integer.valueOf(value)),
+ rexBuilder.getTypeFactory().createSqlType(SqlTypeName.INTEGER),
+ false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createSmallintConstantExpr(String value) {
+ return rexBuilder.makeLiteral(
+ new BigDecimal(Short.valueOf(value)),
+ rexBuilder.getTypeFactory().createSqlType(SqlTypeName.SMALLINT),
+ false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createTinyintConstantExpr(String value) {
+ return rexBuilder.makeLiteral(
+ new BigDecimal(Byte.valueOf(value)),
+ rexBuilder.getTypeFactory().createSqlType(SqlTypeName.TINYINT),
+ false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createFloatConstantExpr(String value) {
+ Float f = Float.valueOf(value);
+ return rexBuilder.makeApproxLiteral(
+ new BigDecimal(Float.toString(f)),
+ rexBuilder.getTypeFactory().createSqlType(SqlTypeName.FLOAT));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createDoubleConstantExpr(String value) throws SemanticException {
+ Double d = Double.valueOf(value);
+ // TODO: The best solution is to support NaN in expression reduction.
+ if (Double.isNaN(d)) {
+ throw new CalciteSemanticException("NaN", UnsupportedFeature.Invalid_decimal);
+ }
+ return rexBuilder.makeApproxLiteral(
+ new BigDecimal(Double.toString(d)),
+ rexBuilder.getTypeFactory().createSqlType(SqlTypeName.DOUBLE));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createDecimalConstantExpr(String value, boolean allowNullValueConstantExpr) {
+ HiveDecimal hd = HiveDecimal.create(value);
+ if (!allowNullValueConstantExpr && hd == null) {
+ return null;
+ }
+ DecimalTypeInfo type = adjustType(hd);
+ return rexBuilder.makeExactLiteral(
+ hd != null ? hd.bigDecimalValue() : null,
+ TypeConverter.convert(type, rexBuilder.getTypeFactory()));
+ }
+
+ @Override
+ protected TypeInfo adjustConstantType(PrimitiveTypeInfo targetType, Object constantValue) {
+ if (constantValue instanceof HiveDecimal) {
+ return adjustType((HiveDecimal) constantValue);
+ }
+ return targetType;
+ }
+
+ private DecimalTypeInfo adjustType(HiveDecimal hd) {
+ // Note: the normalize() call with rounding in HiveDecimal will currently reduce the
+ // precision and scale of the value by throwing away trailing zeroes. This may or may
+ // not be desirable for the literals; however, this used to be the default behavior
+ // for explicit decimal literals (e.g. 1.0BD), so we keep this behavior for now.
+ int prec = 1;
+ int scale = 0;
+ if (hd != null) {
+ prec = hd.precision();
+ scale = hd.scale();
+ }
+ DecimalTypeInfo typeInfo = TypeInfoFactory.getDecimalTypeInfo(prec, scale);
+ return typeInfo;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object interpretConstantAsPrimitive(PrimitiveTypeInfo targetType, Object constantValue,
+ PrimitiveTypeInfo sourceType) {
+ // Extract string value if necessary
+ Object constantToInterpret = constantValue;
+ if (constantValue instanceof HiveNlsString) {
+ constantToInterpret = ((HiveNlsString) constantValue).getValue();
+ }
+
+ if (constantToInterpret instanceof Number || constantToInterpret instanceof String) {
+ try {
+ PrimitiveTypeEntry primitiveTypeEntry = targetType.getPrimitiveTypeEntry();
+ if (PrimitiveObjectInspectorUtils.intTypeEntry.equals(primitiveTypeEntry)) {
+ return toBigDecimal(constantToInterpret.toString()).intValueExact();
+ } else if (PrimitiveObjectInspectorUtils.longTypeEntry.equals(primitiveTypeEntry)) {
+ return toBigDecimal(constantToInterpret.toString()).longValueExact();
+ } else if (PrimitiveObjectInspectorUtils.doubleTypeEntry.equals(primitiveTypeEntry)) {
+ return Double.valueOf(constantToInterpret.toString());
+ } else if (PrimitiveObjectInspectorUtils.floatTypeEntry.equals(primitiveTypeEntry)) {
+ return Float.valueOf(constantToInterpret.toString());
+ } else if (PrimitiveObjectInspectorUtils.byteTypeEntry.equals(primitiveTypeEntry)) {
+ return toBigDecimal(constantToInterpret.toString()).byteValueExact();
+ } else if (PrimitiveObjectInspectorUtils.shortTypeEntry.equals(primitiveTypeEntry)) {
+ return toBigDecimal(constantToInterpret.toString()).shortValueExact();
+ } else if (PrimitiveObjectInspectorUtils.decimalTypeEntry.equals(primitiveTypeEntry)) {
+ HiveDecimal decimal = HiveDecimal.create(constantToInterpret.toString());
+ return decimal != null ? decimal.bigDecimalValue() : null;
+ }
+ } catch (NumberFormatException | ArithmeticException nfe) {
+ LOG.trace("Failed to narrow type of constant", nfe);
+ return null;
+ }
+ }
+
+ // Comparision of decimal and float/double happens in float/double.
+ if (constantToInterpret instanceof BigDecimal) {
+ BigDecimal bigDecimal = (BigDecimal) constantToInterpret;
+
+ PrimitiveTypeEntry primitiveTypeEntry = targetType.getPrimitiveTypeEntry();
+ if (PrimitiveObjectInspectorUtils.doubleTypeEntry.equals(primitiveTypeEntry)) {
+ return bigDecimal.doubleValue();
+ } else if (PrimitiveObjectInspectorUtils.floatTypeEntry.equals(primitiveTypeEntry)) {
+ return bigDecimal.floatValue();
+ }
+ return bigDecimal;
+ }
+
+ String constTypeInfoName = sourceType.getTypeName();
+ if (constTypeInfoName.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) {
+ // because a comparison against a "string" will happen in "string" type.
+ // to avoid unintentional comparisons in "string"
+ // constants which are representing char/varchar values must be converted to the
+ // appropriate type.
+ if (targetType instanceof CharTypeInfo) {
+ final String constValue = constantToInterpret.toString();
+ final int length = TypeInfoUtils.getCharacterLengthForType(targetType);
+ HiveChar newValue = new HiveChar(constValue, length);
+ HiveChar maxCharConst = new HiveChar(constValue, HiveChar.MAX_CHAR_LENGTH);
+ if (maxCharConst.equals(newValue)) {
+ return makeHiveUnicodeString(Interpretation.CHAR, newValue.getValue());
+ } else {
+ return null;
+ }
+ }
+ if (targetType instanceof VarcharTypeInfo) {
+ final String constValue = constantToInterpret.toString();
+ final int length = TypeInfoUtils.getCharacterLengthForType(targetType);
+ HiveVarchar newValue = new HiveVarchar(constValue, length);
+ HiveVarchar maxCharConst = new HiveVarchar(constValue, HiveVarchar.MAX_VARCHAR_LENGTH);
+ if (maxCharConst.equals(newValue)) {
+ return makeHiveUnicodeString(Interpretation.VARCHAR, newValue.getValue());
+ } else {
+ return null;
+ }
+ }
+ }
+
+ return constantValue;
+ }
+
+ private BigDecimal toBigDecimal(String val) {
+ if (!NumberUtils.isNumber(val)) {
+ throw new NumberFormatException("The given string is not a valid number: " + val);
+ }
+ return new BigDecimal(val.replaceAll("[dDfFlL]$", ""));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createStringConstantExpr(String value) {
+ return rexBuilder.makeCharLiteral(
+ makeHiveUnicodeString(Interpretation.STRING, value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createDateConstantExpr(String value) {
+ Date d = Date.valueOf(value);
+ return rexBuilder.makeDateLiteral(
+ DateString.fromDaysSinceEpoch(d.toEpochDay()));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createTimestampConstantExpr(String value) {
+ Timestamp t = Timestamp.valueOf(value);
+ return (RexLiteral) rexBuilder.makeLiteral(
+ TimestampString.fromMillisSinceEpoch(t.toEpochMilli()).withNanos(t.getNanos()),
+ rexBuilder.getTypeFactory().createSqlType(
+ SqlTypeName.TIMESTAMP,
+ rexBuilder.getTypeFactory().getTypeSystem().getDefaultPrecision(SqlTypeName.TIMESTAMP)),
+ false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createTimestampLocalTimeZoneConstantExpr(String value, ZoneId zoneId) {
+ TimestampTZ t = TimestampTZUtil.parse(value);
+
+ final TimestampString tsLocalTZString;
+ if (value == null) {
+ tsLocalTZString = null;
+ } else {
+ Instant i = t.getZonedDateTime().toInstant();
+ tsLocalTZString = TimestampString
+ .fromMillisSinceEpoch(i.toEpochMilli())
+ .withNanos(i.getNano());
+ }
+ return rexBuilder.makeTimestampWithLocalTimeZoneLiteral(
+ tsLocalTZString,
+ rexBuilder.getTypeFactory().getTypeSystem().getDefaultPrecision(SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createIntervalYearMonthConstantExpr(String value) {
+ BigDecimal totalMonths = BigDecimal.valueOf(HiveIntervalYearMonth.valueOf(value).getTotalMonths());
+ return rexBuilder.makeIntervalLiteral(totalMonths,
+ new SqlIntervalQualifier(TimeUnit.YEAR, TimeUnit.MONTH, new SqlParserPos(1, 1)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createIntervalDayTimeConstantExpr(String value) {
+ HiveIntervalDayTime v = HiveIntervalDayTime.valueOf(value);
+ BigDecimal secsValueBd = BigDecimal
+ .valueOf(v.getTotalSeconds() * 1000);
+ BigDecimal nanosValueBd = BigDecimal.valueOf((v).getNanos(), 6);
+ return rexBuilder.makeIntervalLiteral(secsValueBd.add(nanosValueBd),
+ new SqlIntervalQualifier(TimeUnit.MILLISECOND, null, new
+ SqlParserPos(1, 1)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createIntervalYearConstantExpr(String value) {
+ HiveIntervalYearMonth v = new HiveIntervalYearMonth(Integer.parseInt(value), 0);
+ BigDecimal totalMonths = BigDecimal.valueOf(v.getTotalMonths());
+ return rexBuilder.makeIntervalLiteral(totalMonths,
+ new SqlIntervalQualifier(TimeUnit.YEAR, TimeUnit.MONTH, new SqlParserPos(1, 1)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createIntervalMonthConstantExpr(String value) {
+ BigDecimal totalMonths = BigDecimal.valueOf(Integer.parseInt(value));
+ return rexBuilder.makeIntervalLiteral(totalMonths,
+ new SqlIntervalQualifier(TimeUnit.YEAR, TimeUnit.MONTH, new SqlParserPos(1, 1)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createIntervalDayConstantExpr(String value) {
+ HiveIntervalDayTime v = new HiveIntervalDayTime(Integer.parseInt(value), 0, 0, 0, 0);
+ BigDecimal secsValueBd = BigDecimal
+ .valueOf(v.getTotalSeconds() * 1000);
+ BigDecimal nanosValueBd = BigDecimal.valueOf((v).getNanos(), 6);
+ return rexBuilder.makeIntervalLiteral(secsValueBd.add(nanosValueBd),
+ new SqlIntervalQualifier(TimeUnit.MILLISECOND, null, new
+ SqlParserPos(1, 1)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createIntervalHourConstantExpr(String value) {
+ HiveIntervalDayTime v = new HiveIntervalDayTime(0, Integer.parseInt(value), 0, 0, 0);
+ BigDecimal secsValueBd = BigDecimal
+ .valueOf(v.getTotalSeconds() * 1000);
+ BigDecimal nanosValueBd = BigDecimal.valueOf((v).getNanos(), 6);
+ return rexBuilder.makeIntervalLiteral(secsValueBd.add(nanosValueBd),
+ new SqlIntervalQualifier(TimeUnit.MILLISECOND, null, new
+ SqlParserPos(1, 1)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createIntervalMinuteConstantExpr(String value) {
+ HiveIntervalDayTime v = new HiveIntervalDayTime(0, 0, Integer.parseInt(value), 0, 0);
+ BigDecimal secsValueBd = BigDecimal
+ .valueOf(v.getTotalSeconds() * 1000);
+ BigDecimal nanosValueBd = BigDecimal.valueOf((v).getNanos(), 6);
+ return rexBuilder.makeIntervalLiteral(secsValueBd.add(nanosValueBd),
+ new SqlIntervalQualifier(TimeUnit.MILLISECOND, null, new
+ SqlParserPos(1, 1)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexLiteral createIntervalSecondConstantExpr(String value) {
+ BigDecimal bd = new BigDecimal(value);
+ BigDecimal bdSeconds = new BigDecimal(bd.toBigInteger());
+ BigDecimal bdNanos = bd.subtract(bdSeconds);
+ HiveIntervalDayTime v = new HiveIntervalDayTime(0, 0, 0, bdSeconds.intValueExact(),
+ bdNanos.multiply(NANOS_PER_SEC_BD).intValue());
+ BigDecimal secsValueBd = BigDecimal
+ .valueOf(v.getTotalSeconds() * 1000);
+ BigDecimal nanosValueBd = BigDecimal.valueOf((v).getNanos(), 6);
+ return rexBuilder.makeIntervalLiteral(secsValueBd.add(nanosValueBd),
+ new SqlIntervalQualifier(TimeUnit.MILLISECOND, null, new
+ SqlParserPos(1, 1)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createStructExpr(TypeInfo typeInfo, List<RexNode> operands)
+ throws CalciteSemanticException {
+ assert typeInfo instanceof StructTypeInfo;
+ return rexBuilder.makeCall(
+ TypeConverter.convert(typeInfo, rexBuilder.getTypeFactory()),
+ SqlStdOperatorTable.ROW,
+ operands);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createConstantExpr(TypeInfo typeInfo, Object constantValue)
+ throws CalciteSemanticException {
+ if (typeInfo instanceof StructTypeInfo) {
+ List<TypeInfo> typeList = ((StructTypeInfo) typeInfo).getAllStructFieldTypeInfos();
+ List<Object> objectList = (List<Object>) constantValue;
+ List<RexNode> operands = new ArrayList<>();
+ for (int i = 0; i < typeList.size(); i++) {
+ operands.add(
+ rexBuilder.makeLiteral(
+ objectList.get(i),
+ TypeConverter.convert(typeList.get(i), rexBuilder.getTypeFactory()),
+ false));
+ }
+ return rexBuilder.makeCall(
+ TypeConverter.convert(typeInfo, rexBuilder.getTypeFactory()),
+ SqlStdOperatorTable.ROW,
+ operands);
+ }
+ return rexBuilder.makeLiteral(constantValue,
+ TypeConverter.convert(typeInfo, rexBuilder.getTypeFactory()), false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createNestedColumnRefExpr(
+ TypeInfo typeInfo, RexNode expr, String fieldName, Boolean isList) throws CalciteSemanticException {
+ if (expr.getType().isStruct()) {
+ // regular case of accessing nested field in a column
+ return rexBuilder.makeFieldAccess(expr, fieldName, true);
+ } else {
+ // This may happen for schema-less tables, where columns are dynamically
+ // supplied by serdes.
+ throw new CalciteSemanticException("Unexpected rexnode : "
+ + expr.getClass().getCanonicalName(), UnsupportedFeature.Schema_less_table);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createFuncCallExpr(TypeInfo returnType, GenericUDF genericUDF,
+ List<RexNode> inputs) throws SemanticException {
+ final String funcText = genericUDF.getClass().getAnnotation(Description.class).name();
+ final FunctionInfo functionInfo = functionHelper.getFunctionInfo(funcText);
+ return functionHelper.getExpression(
+ funcText, functionInfo, inputs,
+ TypeConverter.convert(returnType, rexBuilder.getTypeFactory()));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createFuncCallExpr(GenericUDF genericUDF, String funcText,
+ List<RexNode> inputs) throws SemanticException {
+ // 1) Function resolution
+ final FunctionInfo functionInfo = functionHelper.getFunctionInfo(funcText);
+ // 2) Compute return type
+ RelDataType returnType;
+ if (genericUDF instanceof SettableUDF) {
+ returnType = TypeConverter.convert(
+ ((SettableUDF) genericUDF).getTypeInfo(), rexBuilder.getTypeFactory());
+ } else {
+ returnType = functionHelper.getReturnType(functionInfo, inputs);
+ }
+ // 3) Convert inputs (if necessary)
+ List<RexNode> newInputs = functionHelper.convertInputs(
+ functionInfo, inputs, returnType);
+ // 4) Return Calcite function
+ return functionHelper.getExpression(
+ funcText, functionInfo, newInputs, returnType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createExprsListExpr() {
+ return new HiveRexExprList();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addExprToExprsList(RexNode columnList, RexNode expr) {
+ HiveRexExprList l = (HiveRexExprList) columnList;
+ l.addExpression(expr);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isConstantExpr(Object o) {
+ return o instanceof RexLiteral;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isFuncCallExpr(Object o) {
+ return o instanceof RexCall;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getConstantValue(RexNode expr) {
+ if (expr.getType().getSqlTypeName() == SqlTypeName.ROW) {
+ List<Object> res = new ArrayList<>();
+ for (RexNode node : ((RexCall) expr).getOperands()) {
+ res.add(((RexLiteral) node).getValue4());
+ }
+ return res;
+ }
+ return ((RexLiteral) expr).getValue4();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getConstantValueAsString(RexNode expr) {
+ return ((RexLiteral) expr).getValueAs(String.class);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isColumnRefExpr(Object o) {
+ return o instanceof RexNode && RexUtil.isReferenceOrAccess((RexNode) o, true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getColumnName(RexNode expr, RowResolver rowResolver) {
+ int index = ((RexInputRef) expr).getIndex();
+ return rowResolver.getColumnInfos().get(index).getInternalName();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isExprsListExpr(Object o) {
+ return o instanceof HiveRexExprList;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected List<RexNode> getExprChildren(RexNode expr) {
+ if (expr instanceof RexCall) {
+ return ((RexCall) expr).getOperands();
+ } else if (expr instanceof HiveRexExprList) {
+ return ((HiveRexExprList) expr).getExpressions();
+ }
+ return new ArrayList<>();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected TypeInfo getTypeInfo(RexNode expr) {
+ return expr.isA(SqlKind.LITERAL) ?
+ TypeConverter.convertLiteralType((RexLiteral) expr) :
+ TypeConverter.convert(expr.getType());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected List<TypeInfo> getStructTypeInfoList(RexNode expr) {
+ StructTypeInfo structTypeInfo = (StructTypeInfo) TypeConverter.convert(expr.getType());
+ return structTypeInfo.getAllStructFieldTypeInfos();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected List<String> getStructNameList(RexNode expr) {
+ StructTypeInfo structTypeInfo = (StructTypeInfo) TypeConverter.convert(expr.getType());
+ return structTypeInfo.getAllStructFieldNames();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isORFuncCallExpr(RexNode expr) {
+ return expr.isA(SqlKind.OR);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isANDFuncCallExpr(RexNode expr) {
+ return expr.isA(SqlKind.AND);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isPOSITIVEFuncCallExpr(RexNode expr) {
+ return expr.isA(SqlKind.PLUS_PREFIX);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isNEGATIVEFuncCallExpr(RexNode expr) {
+ return expr.isA(SqlKind.MINUS_PREFIX);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode setTypeInfo(RexNode expr, TypeInfo type) throws CalciteSemanticException {
+ RelDataType t = TypeConverter.convert(type, rexBuilder.getTypeFactory());
+ if (expr instanceof RexCall) {
+ RexCall call = (RexCall) expr;
+ return rexBuilder.makeCall(t,
+ call.getOperator(), call.getOperands());
+ } else if (expr instanceof RexInputRef) {
+ RexInputRef inputRef = (RexInputRef) expr;
+ return rexBuilder.makeInputRef(t, inputRef.getIndex());
+ } else if (expr instanceof RexLiteral) {
+ RexLiteral literal = (RexLiteral) expr;
+ return rexBuilder.makeLiteral(RexLiteral.value(literal), t, false);
+ }
+ throw new RuntimeException("Unsupported expression type: " + expr.getClass().getCanonicalName());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean convertCASEIntoCOALESCEFuncCallExpr(GenericUDF genericUDF, List<RexNode> inputs) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode foldExpr(RexNode expr) {
+ return functionHelper.foldExpression(expr);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isSTRUCTFuncCallExpr(RexNode expr) {
+ return expr instanceof RexCall &&
+ ((RexCall) expr).getOperator() == SqlStdOperatorTable.ROW;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isConstantStruct(RexNode expr) {
+ return expr.getType().getSqlTypeName() == SqlTypeName.ROW &&
+ HiveCalciteUtil.isLiteral(expr);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected RexNode createSubqueryExpr(TypeCheckCtx ctx, ASTNode expr, SubqueryType subqueryType,
+ Object[] inputs) throws SemanticException {
+ // subqueryToRelNode might be null if subquery expression anywhere other than
+ // as expected in filter (where/having). We should throw an appropriate error
+ // message
+ Map<ASTNode, RelNode> subqueryToRelNode = ctx.getSubqueryToRelNode();
+ if (subqueryToRelNode == null) {
+ throw new CalciteSubquerySemanticException(ErrorMsg.UNSUPPORTED_SUBQUERY_EXPRESSION.getMsg(
+ " Currently SubQuery expressions are only allowed as " +
+ "Where and Having Clause predicates"));
+ }
+
+ ASTNode subqueryOp = (ASTNode) expr.getChild(0);
+ RelNode subqueryRel = subqueryToRelNode.get(expr);
+ // For now because subquery is only supported in filter
+ // we will create subquery expression of boolean type
+ switch (subqueryType) {
+ case EXISTS: {
+ return RexSubQuery.exists(subqueryRel);
+ }
+ case IN: {
+ assert (inputs[2] != null);
+ /*
+ * Check.5.h :: For In and Not In the SubQuery must implicitly or
+ * explicitly only contain one select item.
+ */
+ if(subqueryRel.getRowType().getFieldCount() > 1) {
+ throw new CalciteSubquerySemanticException(ErrorMsg.INVALID_SUBQUERY_EXPRESSION.getMsg(
+ "SubQuery can contain only 1 item in Select List."));
+ }
+ //create RexNode for LHS
+ RexNode lhs = (RexNode) inputs[2];
+ //create RexSubQuery node
+ return RexSubQuery.in(subqueryRel, ImmutableList.<RexNode>of(lhs));
+ }
+ case SCALAR: {
+ // only single subquery expr is supported
+ if (subqueryRel.getRowType().getFieldCount() != 1) {
+ throw new CalciteSubquerySemanticException(ErrorMsg.INVALID_SUBQUERY_EXPRESSION.getMsg(
+ "More than one column expression in subquery"));
+ }
+ if(subqueryRel.getRowType().getFieldCount() > 1) {
+ throw new CalciteSubquerySemanticException(ErrorMsg.INVALID_SUBQUERY_EXPRESSION.getMsg(
+ "SubQuery can contain only 1 item in Select List."));
+ }
+ //create RexSubQuery node
+ return RexSubQuery.scalar(subqueryRel);
+ }
+ case SOME:
+ case ALL: {
+ assert (inputs[2] != null);
+ //create RexNode for LHS
+ RexNode lhs = (RexNode) inputs[2];
+ return convertSubquerySomeAll(subqueryRel.getCluster(),
+ (ASTNode) subqueryOp.getChild(1), subqueryType, subqueryRel, lhs);
+ }
+ default:
+ return null;
+ }
+ }
+
+ private static void throwInvalidSubqueryError(final ASTNode comparisonOp) throws SemanticException {
+ throw new CalciteSubquerySemanticException(ErrorMsg.INVALID_SUBQUERY_EXPRESSION.getMsg(
+ "Invalid operator:" + comparisonOp.toString()));
+ }
+
+ public static RexNode convertSubquerySomeAll(final RelOptCluster cluster, final ASTNode comparisonOp,
+ final SubqueryType subqueryType, final RelNode subqueryRel, final RexNode rexNodeLhs)
+ throws SemanticException {
+ SqlQuantifyOperator quantifyOperator = null;
+ switch (comparisonOp.getType()) {
+ case HiveParser.EQUAL:
+ if(subqueryType == SubqueryType.ALL) {
+ throwInvalidSubqueryError(comparisonOp);
+ }
+ quantifyOperator = SqlStdOperatorTable.SOME_EQ;
+ break;
+ case HiveParser.LESSTHAN:
+ quantifyOperator = SqlStdOperatorTable.SOME_LT;
+ break;
+ case HiveParser.LESSTHANOREQUALTO:
+ quantifyOperator = SqlStdOperatorTable.SOME_LE;
+ break;
+ case HiveParser.GREATERTHAN:
+ quantifyOperator = SqlStdOperatorTable.SOME_GT;
+ break;
+ case HiveParser.GREATERTHANOREQUALTO:
+ quantifyOperator = SqlStdOperatorTable.SOME_GE;
+ break;
+ case HiveParser.NOTEQUAL:
+ if(subqueryType == SubqueryType.SOME) {
+ throwInvalidSubqueryError(comparisonOp);
+ }
+ quantifyOperator = SqlStdOperatorTable.SOME_NE;
+ break;
+ default:
+ throw new CalciteSubquerySemanticException(ErrorMsg.INVALID_SUBQUERY_EXPRESSION.getMsg(
+ "Invalid operator:" + comparisonOp.toString()));
+ }
+ if(subqueryType == SubqueryType.ALL) {
+ quantifyOperator = SqlStdOperatorTable.some(quantifyOperator.comparisonKind.negateNullSafe());
+ }
+
+ RexNode someQuery = getSomeSubquery(cluster, subqueryRel, rexNodeLhs, quantifyOperator);
+ if(subqueryType == SubqueryType.ALL) {
+ return cluster.getRexBuilder().makeCall(SqlStdOperatorTable.NOT, someQuery);
+ }
+ return someQuery;
+ }
+
+ private static RexNode getSomeSubquery(final RelOptCluster cluster,
+ final RelNode subqueryRel, final RexNode lhs,
+ final SqlQuantifyOperator quantifyOperator) {
+ if(quantifyOperator == SqlStdOperatorTable.SOME_EQ) {
+ return RexSubQuery.in(subqueryRel, ImmutableList.<RexNode>of(lhs));
+ } else if (quantifyOperator == SqlStdOperatorTable.SOME_NE) {
+ RexSubQuery subQuery = RexSubQuery.in(subqueryRel, ImmutableList.<RexNode>of(lhs));
+ return cluster.getRexBuilder().makeCall(SqlStdOperatorTable.NOT, subQuery);
+ } else {
+ return RexSubQuery.some(subqueryRel, ImmutableList.of(lhs), quantifyOperator);
+ }
+ }
+
+ public static NlsString makeHiveUnicodeString(Interpretation interpretation, String text) {
+ return new HiveNlsString(interpretation, text, ConversionUtil.NATIVE_UTF16_CHARSET_NAME, SqlCollation.IMPLICIT);
+ }
+
+ public static class HiveNlsString extends NlsString {
+
+ public enum Interpretation {
+ CHAR, VARCHAR, STRING;
+ }
+
+ public final Interpretation interpretation;
+
+ public HiveNlsString(Interpretation interpretation, String value, String charsetName, SqlCollation collation) {
+ super(value, charsetName, collation);
+ this.interpretation = interpretation;
+ }
+ }
+
+}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprNodeTypeCheck.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/RexNodeTypeCheck.java
similarity index 52%
copy from ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprNodeTypeCheck.java
copy to ql/src/java/org/apache/hadoop/hive/ql/parse/type/RexNodeTypeCheck.java
index 623b280..c9131ec 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/ExprNodeTypeCheck.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/RexNodeTypeCheck.java
@@ -15,61 +15,56 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.hadoop.hive.ql.parse.type;
import java.util.Map;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexNode;
import org.apache.hadoop.hive.ql.exec.ColumnInfo;
import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.RowResolver;
import org.apache.hadoop.hive.ql.parse.SemanticException;
-import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
-
-/**
- * Class with utility methods to use typecheck processor factory
- * functionality.
- */
-public class ExprNodeTypeCheck {
- private ExprNodeTypeCheck() {
- // Defeat instantiation
- }
+public class RexNodeTypeCheck {
/**
* Given an AST expression and a context, it will produce a map from AST nodes
- * to Hive ExprNode.
+ * to Calcite RexNode.
*/
- public static Map<ASTNode, ExprNodeDesc> genExprNode(ASTNode expr, TypeCheckCtx tcCtx)
+ public static Map<ASTNode, RexNode> genExprNode(ASTNode expr, TypeCheckCtx tcCtx)
throws SemanticException {
- TypeCheckProcFactory<ExprNodeDesc> factory =
- new TypeCheckProcFactory<>(new ExprNodeDescExprFactory());
+ TypeCheckProcFactory<RexNode> factory =
+ new TypeCheckProcFactory<>(new RexNodeExprFactory(tcCtx.getRexBuilder()));
return factory.genExprNode(expr, tcCtx);
}
/**
- * Given an AST join expression and a context, it will produce a map from AST nodes
- * to Hive ExprNode.
+ * Returns the default processor to generate Calcite RexNode from AST nodes.
*/
- public static Map<ASTNode, ExprNodeDesc> genExprNodeJoinCond(ASTNode expr, TypeCheckCtx tcCtx)
- throws SemanticException {
- JoinCondTypeCheckProcFactory<ExprNodeDesc> typeCheckProcFactory =
- new JoinCondTypeCheckProcFactory<>(new ExprNodeDescExprFactory());
- return typeCheckProcFactory.genExprNode(expr, tcCtx);
+ public static TypeCheckProcFactory<RexNode>.DefaultExprProcessor getExprNodeDefaultExprProcessor(RexBuilder rexBuilder) {
+ TypeCheckProcFactory<RexNode> factory =
+ new TypeCheckProcFactory<>(new RexNodeExprFactory(rexBuilder));
+ return factory.getDefaultExprProcessor();
}
/**
- * Returns the default processor to generate Hive ExprNode from AST nodes.
+ * Given an AST join expression and a context, it will produce a map from AST nodes
+ * to Calcite RexNode.
*/
- public static TypeCheckProcFactory<ExprNodeDesc>.DefaultExprProcessor getExprNodeDefaultExprProcessor() {
- TypeCheckProcFactory<ExprNodeDesc> factory =
- new TypeCheckProcFactory<>(new ExprNodeDescExprFactory());
- return factory.getDefaultExprProcessor();
+ public static Map<ASTNode, RexNode> genExprNodeJoinCond(ASTNode expr, TypeCheckCtx tcCtx, RexBuilder rexBuilder)
+ throws SemanticException {
+ JoinCondTypeCheckProcFactory<RexNode> typeCheckProcFactory =
+ new JoinCondTypeCheckProcFactory<>(new RexNodeExprFactory(rexBuilder));
+ return typeCheckProcFactory.genExprNode(expr, tcCtx);
}
/**
- * Transforms column information into the corresponding Hive ExprNode.
+ * Transforms column information into the corresponding Calcite RexNode.
*/
- public static ExprNodeDesc toExprNodeDesc(ColumnInfo columnInfo) {
- ExprNodeDescExprFactory factory = new ExprNodeDescExprFactory();
- return factory.toExpr(columnInfo);
+ public static RexNode toExprNode(ColumnInfo columnInfo, RowResolver rowResolver, int offset, RexBuilder rexBuilder)
+ throws SemanticException {
+ RexNodeExprFactory factory = new RexNodeExprFactory(rexBuilder);
+ return factory.toExpr(columnInfo, rowResolver, offset);
}
+
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckCtx.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckCtx.java
index 67875cc..d4ef3fa 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckCtx.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckCtx.java
@@ -19,6 +19,7 @@
package org.apache.hadoop.hive.ql.parse.type;
import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rex.RexBuilder;
import org.apache.hadoop.hive.ql.lib.NodeProcessorCtx;
import org.apache.hadoop.hive.ql.parse.ASTNode;
import org.apache.hadoop.hive.ql.parse.RowResolver;
@@ -93,6 +94,8 @@ public class TypeCheckCtx implements NodeProcessorCtx {
private final boolean allowSubQueryExpr;
+ private RexBuilder rexBuilder;
+
/**
* Constructor.
*
@@ -103,11 +106,27 @@ public class TypeCheckCtx implements NodeProcessorCtx {
this(inputRR, true, false);
}
+ public TypeCheckCtx(RowResolver inputRR, RexBuilder rexBuilder) {
+ this(inputRR, rexBuilder, true, false);
+ }
+
public TypeCheckCtx(RowResolver inputRR, boolean useCaching, boolean foldExpr) {
this(inputRR, useCaching, foldExpr, false, true, true, true, true, true, true, true);
}
+ public TypeCheckCtx(RowResolver inputRR, RexBuilder rexBuilder, boolean useCaching, boolean foldExpr) {
+ this(inputRR, rexBuilder, useCaching, foldExpr, false, true, true, true, true, true, true, true);
+ }
+
public TypeCheckCtx(RowResolver inputRR, boolean useCaching, boolean foldExpr,
+ boolean allowStatefulFunctions, boolean allowDistinctFunctions, boolean allowGBExprElimination,
+ boolean allowAllColRef, boolean allowFunctionStar, boolean allowWindowing,
+ boolean allowIndexExpr, boolean allowSubQueryExpr) {
+ this(inputRR, null, useCaching, foldExpr, allowStatefulFunctions, allowDistinctFunctions, allowGBExprElimination,
+ allowAllColRef, allowFunctionStar, allowWindowing, allowIndexExpr, allowSubQueryExpr);
+ }
+
+ public TypeCheckCtx(RowResolver inputRR, RexBuilder rexBuilder, boolean useCaching, boolean foldExpr,
boolean allowStatefulFunctions, boolean allowDistinctFunctions, boolean allowGBExprElimination,
boolean allowAllColRef, boolean allowFunctionStar, boolean allowWindowing,
boolean allowIndexExpr, boolean allowSubQueryExpr) {
@@ -125,6 +144,7 @@ public class TypeCheckCtx implements NodeProcessorCtx {
this.allowSubQueryExpr = allowSubQueryExpr;
this.outerRR = null;
this.subqueryToRelNode = null;
+ this.rexBuilder = rexBuilder;
}
/**
@@ -271,4 +291,8 @@ public class TypeCheckCtx implements NodeProcessorCtx {
public boolean isCBOExecuted() {
return foldExpr;
}
+
+ public RexBuilder getRexBuilder() {
+ return rexBuilder;
+ }
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactory.java
index 4615fc5..e16966e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactory.java
@@ -18,8 +18,11 @@
package org.apache.hadoop.hive.ql.parse.type;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ListMultimap;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -28,7 +31,9 @@ import java.util.Map;
import java.util.Stack;
import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.conf.HiveConf.StrictChecks;
import org.apache.hadoop.hive.ql.ErrorMsg;
import org.apache.hadoop.hive.ql.exec.ColumnInfo;
import org.apache.hadoop.hive.ql.exec.FunctionInfo;
@@ -54,9 +59,9 @@ import org.apache.hadoop.hive.ql.parse.ParseUtils;
import org.apache.hadoop.hive.ql.parse.RowResolver;
import org.apache.hadoop.hive.ql.parse.SemanticAnalyzer;
import org.apache.hadoop.hive.ql.parse.SemanticException;
-import org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc;
-import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc;
import org.apache.hadoop.hive.ql.plan.SubqueryType;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hadoop.hive.ql.session.SessionState.LogHelper;
import org.apache.hadoop.hive.ql.udf.SettableUDF;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBaseCompare;
@@ -610,8 +615,11 @@ public class TypeCheckProcFactory<T> {
boolean isTableAlias = input.hasTableAlias(tableOrCol);
ColumnInfo colInfo = null;
+ RowResolver usedRR = null;
+ int offset = 0;
try {
colInfo = input.get(null, tableOrCol);
+ usedRR = input;
} catch (SemanticException semanticException) {
if (!isTableAlias || parent == null || parent.getType() != HiveParser.DOT) {
throw semanticException;
@@ -622,6 +630,8 @@ public class TypeCheckProcFactory<T> {
RowResolver outerRR = ctx.getOuterRR();
isTableAlias = outerRR.hasTableAlias(tableOrCol);
colInfo = outerRR.get(null, tableOrCol);
+ usedRR = outerRR;
+ offset = input.getColumnInfos().size();
}
if (isTableAlias) {
@@ -631,7 +641,7 @@ public class TypeCheckProcFactory<T> {
return null;
}
// It's a column.
- return exprFactory.toExpr(colInfo);
+ return exprFactory.toExpr(colInfo, usedRR, offset);
} else {
// It's a table alias.
// We will process that later in DOT.
@@ -665,7 +675,7 @@ public class TypeCheckProcFactory<T> {
}
} else {
// It's a column.
- return exprFactory.toExpr(colInfo);
+ return exprFactory.toExpr(colInfo, usedRR, offset);
}
}
}
@@ -714,7 +724,7 @@ public class TypeCheckProcFactory<T> {
* @throws UDFArgumentException
*/
public T getFuncExprNodeDescWithUdfData(String udfName, TypeInfo typeInfo,
- T... children) throws UDFArgumentException {
+ T... children) throws SemanticException {
FunctionInfo fi;
try {
@@ -742,10 +752,10 @@ public class TypeCheckProcFactory<T> {
List<T> childrenList = new ArrayList<>(children.length);
childrenList.addAll(Arrays.asList(children));
- return exprFactory.createFuncCallExpr(genericUDF, null, childrenList);
+ return exprFactory.createFuncCallExpr(genericUDF, udfName, childrenList);
}
- public T getFuncExprNodeDesc(String udfName, T... children) throws UDFArgumentException {
+ public T getFuncExprNodeDesc(String udfName, T... children) throws SemanticException {
return getFuncExprNodeDescWithUdfData(udfName, null, children);
}
@@ -768,6 +778,29 @@ public class TypeCheckProcFactory<T> {
protected void validateUDF(ASTNode expr, boolean isFunction, TypeCheckCtx ctx, FunctionInfo fi,
List<T> children, GenericUDF genericUDF) throws SemanticException {
+ // Check if a bigint is implicitely cast to a double as part of a comparison
+ // Perform the check here instead of in GenericUDFBaseCompare to guarantee it is only run once per operator
+ if (genericUDF instanceof GenericUDFBaseCompare && children.size() == 2) {
+ TypeInfo oiTypeInfo0 = exprFactory.getTypeInfo(children.get(0));
+ TypeInfo oiTypeInfo1 = exprFactory.getTypeInfo(children.get(1));
+
+ SessionState ss = SessionState.get();
+ Configuration conf = (ss != null) ? ss.getConf() : new Configuration();
+
+ LogHelper console = new LogHelper(LOG);
+
+ // For now, if a bigint is going to be cast to a double throw an error or warning
+ if ((oiTypeInfo0.equals(TypeInfoFactory.stringTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.longTypeInfo)) ||
+ (oiTypeInfo0.equals(TypeInfoFactory.longTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.stringTypeInfo))) {
+ String error = StrictChecks.checkTypeSafety(conf);
+ if (error != null) throw new UDFArgumentException(error);
+ console.printError("WARNING: Comparing a bigint and a string may result in a loss of precision.");
+ } else if ((oiTypeInfo0.equals(TypeInfoFactory.doubleTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.longTypeInfo)) ||
+ (oiTypeInfo0.equals(TypeInfoFactory.longTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.doubleTypeInfo))) {
+ console.printError("WARNING: Comparing a bigint and a double may result in a loss of precision.");
+ }
+ }
+
// Detect UDTF's in nested SELECT, GROUP BY, etc as they aren't
// supported
if (fi.getGenericUDTF() != null) {
@@ -801,17 +834,17 @@ public class TypeCheckProcFactory<T> {
}
}
- protected T getXpathOrFuncExprNodeDesc(ASTNode expr,
+ protected T getXpathOrFuncExprNodeDesc(ASTNode node,
boolean isFunction, List<T> children, TypeCheckCtx ctx)
- throws SemanticException, UDFArgumentException {
+ throws SemanticException {
// return the child directly if the conversion is redundant.
- if (isRedundantConversionFunction(expr, isFunction, children)) {
+ if (isRedundantConversionFunction(node, isFunction, children)) {
assert (children.size() == 1);
assert (children.get(0) != null);
return children.get(0);
}
- String funcText = getFunctionText(expr, isFunction);
- T desc;
+ String funcText = getFunctionText(node, isFunction);
+ T expr;
if (funcText.equals(".")) {
// "." : FIELD Expression
@@ -821,7 +854,7 @@ public class TypeCheckProcFactory<T> {
T object = children.get(0);
// Calculate result TypeInfo
- String fieldNameString = exprFactory.getConstantValue(children.get(1)).toString();
+ String fieldNameString = exprFactory.getConstantValueAsString(children.get(1));
TypeInfo objectTypeInfo = exprFactory.getTypeInfo(object);
// Allow accessing a field of list element structs directly from a list
@@ -831,19 +864,19 @@ public class TypeCheckProcFactory<T> {
}
if (objectTypeInfo.getCategory() != Category.STRUCT) {
throw new SemanticException(ASTErrorUtils.getMsg(
- ErrorMsg.INVALID_DOT.getMsg(), expr));
+ ErrorMsg.INVALID_DOT.getMsg(), node));
}
TypeInfo t = ((StructTypeInfo) objectTypeInfo).getStructFieldTypeInfo(fieldNameString);
if (isList) {
t = TypeInfoFactory.getListTypeInfo(t);
}
- desc = exprFactory.createNestedColumnRefExpr(t, children.get(0), fieldNameString, isList);
+ expr = exprFactory.createNestedColumnRefExpr(t, children.get(0), fieldNameString, isList);
} else if (funcText.equals("[")) {
// "[]" : LSQUARE/INDEX Expression
if (!ctx.getallowIndexExpr()) {
throw new SemanticException(ASTErrorUtils.getMsg(
- ErrorMsg.INVALID_FUNCTION.getMsg(), expr));
+ ErrorMsg.INVALID_FUNCTION.getMsg(), node));
}
assert (children.size() == 2);
@@ -856,24 +889,24 @@ public class TypeCheckProcFactory<T> {
if (!TypeInfoUtils.implicitConvertible(exprFactory.getTypeInfo(children.get(1)),
TypeInfoFactory.intTypeInfo)) {
throw new SemanticException(SemanticAnalyzer.generateErrorMessage(
- expr, ErrorMsg.INVALID_ARRAYINDEX_TYPE.getMsg()));
+ node, ErrorMsg.INVALID_ARRAYINDEX_TYPE.getMsg()));
}
// Calculate TypeInfo
TypeInfo t = ((ListTypeInfo) myt).getListElementTypeInfo();
- desc = exprFactory.createFuncCallExpr(t, FunctionRegistry.getGenericUDFForIndex(), children);
+ expr = exprFactory.createFuncCallExpr(t, FunctionRegistry.getGenericUDFForIndex(), children);
} else if (myt.getCategory() == Category.MAP) {
if (!TypeInfoUtils.implicitConvertible(exprFactory.getTypeInfo(children.get(1)),
((MapTypeInfo) myt).getMapKeyTypeInfo())) {
throw new SemanticException(ASTErrorUtils.getMsg(
- ErrorMsg.INVALID_MAPINDEX_TYPE.getMsg(), expr));
+ ErrorMsg.INVALID_MAPINDEX_TYPE.getMsg(), node));
}
// Calculate TypeInfo
TypeInfo t = ((MapTypeInfo) myt).getMapValueTypeInfo();
- desc = exprFactory.createFuncCallExpr(t, FunctionRegistry.getGenericUDFForIndex(), children);
+ expr = exprFactory.createFuncCallExpr(t, FunctionRegistry.getGenericUDFForIndex(), children);
} else {
throw new SemanticException(ASTErrorUtils.getMsg(
- ErrorMsg.NON_COLLECTION_TYPE.getMsg(), expr, myt.getTypeName()));
+ ErrorMsg.NON_COLLECTION_TYPE.getMsg(), node, myt.getTypeName()));
}
} else {
// other operators or functions
@@ -882,10 +915,10 @@ public class TypeCheckProcFactory<T> {
if (fi == null) {
if (isFunction) {
throw new SemanticException(ASTErrorUtils.getMsg(
- ErrorMsg.INVALID_FUNCTION.getMsg(), (ASTNode) expr.getChild(0)));
+ ErrorMsg.INVALID_FUNCTION.getMsg(), (ASTNode) node.getChild(0)));
} else {
throw new SemanticException(ASTErrorUtils.getMsg(
- ErrorMsg.INVALID_FUNCTION.getMsg(), expr));
+ ErrorMsg.INVALID_FUNCTION.getMsg(), node));
}
}
@@ -894,12 +927,12 @@ public class TypeCheckProcFactory<T> {
if (!fi.isNative()) {
ctx.getUnparseTranslator().addIdentifierTranslation(
- (ASTNode) expr.getChild(0));
+ (ASTNode) node.getChild(0));
}
// Handle type casts that may contain type parameters
if (isFunction) {
- ASTNode funcNameNode = (ASTNode) expr.getChild(0);
+ ASTNode funcNameNode = (ASTNode) node.getChild(0);
switch (funcNameNode.getType()) {
case HiveParser.TOK_CHAR:
// Add type params
@@ -941,25 +974,25 @@ public class TypeCheckProcFactory<T> {
insertCast(funcText, children);
- validateUDF(expr, isFunction, ctx, fi, children, genericUDF);
+ validateUDF(node, isFunction, ctx, fi, children, genericUDF);
// Try to infer the type of the constant only if there are two
// nodes, one of them is column and the other is numeric const
if (genericUDF instanceof GenericUDFBaseCompare
&& children.size() == 2
- && ((children.get(0) instanceof ExprNodeConstantDesc
- && children.get(1) instanceof ExprNodeColumnDesc)
- || (children.get(0) instanceof ExprNodeColumnDesc
- && children.get(1) instanceof ExprNodeConstantDesc))) {
+ && ((exprFactory.isConstantExpr(children.get(0))
+ && exprFactory.isColumnRefExpr(children.get(1)))
+ || (exprFactory.isColumnRefExpr(children.get(0))
+ && exprFactory.isConstantExpr(children.get(1))))) {
- int constIdx = children.get(0) instanceof ExprNodeConstantDesc ? 0 : 1;
+ int constIdx = exprFactory.isConstantExpr(children.get(0)) ? 0 : 1;
T constChild = children.get(constIdx);
T columnChild = children.get(1 - constIdx);
- final PrimitiveTypeInfo colTypeInfo =
- TypeInfoFactory.getPrimitiveTypeInfo(exprFactory.getTypeInfo(columnChild).getTypeName().toLowerCase());
- T newChild = interpretNodeAs(colTypeInfo, constChild);
+ final PrimitiveTypeInfo colTypeInfo = TypeInfoFactory.getPrimitiveTypeInfo(
+ exprFactory.getTypeInfo(columnChild).getTypeName().toLowerCase());
+ T newChild = interpretNodeAsConstant(colTypeInfo, constChild);
if (newChild == null) {
// non-interpretable as target type...
// TODO: all comparisons with null should result in null
@@ -972,55 +1005,52 @@ public class TypeCheckProcFactory<T> {
}
}
if (genericUDF instanceof GenericUDFIn) {
-
- T columnDesc = children.get(0);
- List<T> outputOpList = children.subList(1, children.size());
- List<T> inOperands = new ArrayList<>(outputOpList);
- outputOpList.clear();
-
+ // We will split the IN clause into different IN clauses, one for each
+ // different value type. The reason is that Hive and Calcite treat
+ // types in IN clauses differently and it is practically impossible
+ // to find some correct implementation unless this is done.
boolean hasNullValue = false;
- for (T oldChild : inOperands) {
- if (oldChild == null) {
- hasNullValue = true;
- continue;
- }
- T newChild = interpretNodeAsStruct(columnDesc, oldChild);
- if (newChild == null) {
+ ListMultimap<TypeInfo, T> expressions = ArrayListMultimap.create();
+ for (int i = 1; i < children.size(); i++) {
+ T columnDesc = children.get(0);
+ T valueDesc = interpretNode(columnDesc, children.get(i));
+ if (valueDesc == null) {
+ if (hasNullValue) {
+ // Skip if null value has already been added
+ continue;
+ }
+ TypeInfo targetType = exprFactory.getTypeInfo(columnDesc);
+ if (!expressions.containsKey(targetType)) {
+ expressions.put(targetType, columnDesc);
+ }
+ T nullConst = exprFactory.createConstantExpr(targetType, null);
+ expressions.put(targetType, nullConst);
hasNullValue = true;
- continue;
- }
- outputOpList.add(newChild);
- }
-
- if (hasNullValue) {
- T nullConst = exprFactory.createConstantExpr(exprFactory.getTypeInfo(columnDesc), null);
- if (outputOpList.size() == 0) {
- // we have found only null values...remove the IN ; it will be null all the time.
- return nullConst;
+ } else {
+ TypeInfo targetType = exprFactory.getTypeInfo(valueDesc);
+ if (!expressions.containsKey(targetType)) {
+ expressions.put(targetType, columnDesc);
+ }
+ expressions.put(targetType, valueDesc);
}
- outputOpList.add(nullConst);
}
- if (!ctx.isCBOExecuted()) {
-
- HiveConf conf;
- try {
- conf = Hive.get().getConf();
- } catch (HiveException e) {
- throw new SemanticException(e);
- }
- if (children.size() <= HiveConf.getIntVar(conf, HiveConf.ConfVars.HIVEOPT_TRANSFORM_IN_MAXNODES)) {
- List<T> orOperands = exprFactory.rewriteINIntoORFuncCallExpr(children);
- if (orOperands != null) {
- if (orOperands.size() == 1) {
- orOperands.add(exprFactory.createBooleanConstantExpr(Boolean.FALSE.toString()));
- }
- funcText = "or";
- genericUDF = new GenericUDFOPOr();
- children.clear();
- children.addAll(orOperands);
- }
+ children.clear();
+ List<T> newExprs = new ArrayList<>();
+ int numEntries = expressions.keySet().size();
+ if (numEntries == 1) {
+ children.addAll(expressions.asMap().values().iterator().next());
+ funcText = "in";
+ genericUDF = new GenericUDFIn();
+ } else {
+ for (Collection<T> c : expressions.asMap().values()) {
+ newExprs.add(
+ exprFactory.createFuncCallExpr(
+ new GenericUDFIn(), "in", (List<T>) c));
}
+ children.addAll(newExprs);
+ funcText = "or";
+ genericUDF = new GenericUDFOPOr();
}
}
if (genericUDF instanceof GenericUDFOPOr) {
@@ -1036,7 +1066,7 @@ public class TypeCheckProcFactory<T> {
childrenList.add(child);
}
}
- desc = exprFactory.createFuncCallExpr(genericUDF, funcText, childrenList);
+ expr = exprFactory.createFuncCallExpr(genericUDF, funcText, childrenList);
} else if (genericUDF instanceof GenericUDFOPAnd) {
// flatten AND
List<T> childrenList = new ArrayList<>(children.size());
@@ -1050,111 +1080,131 @@ public class TypeCheckProcFactory<T> {
childrenList.add(child);
}
}
- desc = exprFactory.createFuncCallExpr(genericUDF, funcText, childrenList);
- } else if (ctx.isFoldExpr() && exprFactory.canConvertCASEIntoCOALESCEFuncCallExpr(genericUDF, children)) {
+ expr = exprFactory.createFuncCallExpr(genericUDF, funcText, childrenList);
+ } else if (ctx.isFoldExpr() && exprFactory.convertCASEIntoCOALESCEFuncCallExpr(genericUDF, children)) {
// Rewrite CASE into COALESCE
- desc = exprFactory.createFuncCallExpr(new GenericUDFCoalesce(), null,
+ expr = exprFactory.createFuncCallExpr(new GenericUDFCoalesce(), "coalesce",
Lists.newArrayList(children.get(0), exprFactory.createBooleanConstantExpr(Boolean.FALSE.toString())));
if (Boolean.FALSE.equals(exprFactory.getConstantValue(children.get(1)))) {
- desc = exprFactory.createFuncCallExpr(new GenericUDFOPNot(), null, Lists.newArrayList(desc));
+ expr = exprFactory.createFuncCallExpr(new GenericUDFOPNot(), "not", Lists.newArrayList(expr));
}
} else {
- desc = exprFactory.createFuncCallExpr(genericUDF, funcText, children);
+ expr = exprFactory.createFuncCallExpr(genericUDF, funcText, children);
}
// If the function is deterministic and the children are constants,
// we try to fold the expression to remove e.g. cast on constant
- if (ctx.isFoldExpr() && exprFactory.isFuncCallExpr(desc) &&
+ if (ctx.isFoldExpr() && exprFactory.isFuncCallExpr(expr) &&
FunctionRegistry.isConsistentWithinQuery(genericUDF) &&
exprFactory.isAllConstants(children)) {
- T constantExpr = exprFactory.foldExpr(desc);
+ T constantExpr = exprFactory.foldExpr(expr);
if (constantExpr != null) {
- desc = constantExpr;
+ expr = constantExpr;
}
}
}
- // UDFOPPositive is a no-op.
- // However, we still create it, and then remove it here, to make sure we
- // only allow
- // "+" for numeric types.
- if (exprFactory.isPOSITIVEFuncCallExpr(desc)) {
- assert (exprFactory.getExprChildren(desc).size() == 1);
- desc = exprFactory.getExprChildren(desc).get(0);
+
+ if (exprFactory.isPOSITIVEFuncCallExpr(expr)) {
+ // UDFOPPositive is a no-op.
+ assert (exprFactory.getExprChildren(expr).size() == 1);
+ expr = exprFactory.getExprChildren(expr).get(0);
+ } else if (exprFactory.isNEGATIVEFuncCallExpr(expr)) {
+ // UDFOPNegative should always be folded.
+ assert (exprFactory.getExprChildren(expr).size() == 1);
+ T input = exprFactory.getExprChildren(expr).get(0);
+ if (exprFactory.isConstantExpr(input)) {
+ T constantExpr = exprFactory.foldExpr(expr);
+ if (constantExpr != null) {
+ expr = constantExpr;
+ }
+ }
}
- assert (desc != null);
- return desc;
+ assert (expr != null);
+ return expr;
}
/**
- * Interprets the given value as columnDesc if possible
+ * Interprets the given value as the input columnDesc if possible.
+ * Otherwise, returns input valueDesc as is.
*/
- private T interpretNodeAsStruct(T columnDesc, T valueDesc)
+ private T interpretNode(T columnDesc, T valueDesc)
throws SemanticException {
if (exprFactory.isColumnRefExpr(columnDesc)) {
- final PrimitiveTypeInfo typeInfo =
- TypeInfoFactory.getPrimitiveTypeInfo(exprFactory.getTypeInfo(columnDesc).getTypeName().toLowerCase());
- return interpretNodeAs(typeInfo, valueDesc);
- }
- if (exprFactory.isSTRUCTFuncCallExpr(columnDesc) && exprFactory.isConstantStruct(valueDesc)) {
- List<T> columnChilds = exprFactory.getExprChildren(columnDesc);
- ExprNodeConstantDesc valueConstDesc = (ExprNodeConstantDesc) valueDesc;
- StructTypeInfo structTypeInfo = (StructTypeInfo) valueConstDesc.getTypeInfo();
- ArrayList<TypeInfo> structFieldInfos = structTypeInfo.getAllStructFieldTypeInfos();
- ArrayList<TypeInfo> newStructFieldInfos = new ArrayList<>();
-
- if (columnChilds.size() != structFieldInfos.size()) {
- throw new SemanticException(ErrorMsg.INCOMPATIBLE_STRUCT.getMsg(columnChilds + " and " + structFieldInfos));
- }
- List<Object> oldValues = (List<Object>) valueConstDesc.getValue();
- List<Object> newValues = new ArrayList<>();
- for (int i = 0; i < columnChilds.size(); i++) {
- newStructFieldInfos.add(exprFactory.getTypeInfo(columnChilds.get(i)));
- Object newValue = exprFactory.interpretConstantAsPrimitive(
- (PrimitiveTypeInfo) exprFactory.getTypeInfo(columnChilds.get(i)),
- oldValues.get(i),
- (PrimitiveTypeInfo) structFieldInfos.get(i));
- newValues.add(newValue);
- }
- StructTypeInfo sti = new StructTypeInfo();
- sti.setAllStructFieldTypeInfos(newStructFieldInfos);
- sti.setAllStructFieldNames(structTypeInfo.getAllStructFieldNames());
- return exprFactory.createConstantExpr(sti, newValues);
+ final PrimitiveTypeInfo typeInfo = TypeInfoFactory.getPrimitiveTypeInfo(
+ exprFactory.getTypeInfo(columnDesc).getTypeName().toLowerCase());
+ return interpretNodeAsConstant(typeInfo, valueDesc);
+ }
+ boolean columnStruct = exprFactory.isSTRUCTFuncCallExpr(columnDesc);
+ if (columnStruct) {
+ boolean constantValuesStruct = exprFactory.isConstantStruct(valueDesc);
+ boolean valuesStruct = exprFactory.isSTRUCTFuncCallExpr(valueDesc);
+ if (constantValuesStruct || valuesStruct) {
+ List<T> columnChilds = exprFactory.getExprChildren(columnDesc);
+ List<TypeInfo> structFieldInfos = exprFactory.getStructTypeInfoList(valueDesc);
+ List<String> structFieldNames = exprFactory.getStructNameList(valueDesc);
+
+ if (columnChilds.size() != structFieldInfos.size()) {
+ throw new SemanticException(ErrorMsg.INCOMPATIBLE_STRUCT.getMsg(columnChilds + " and " + structFieldInfos));
+ }
- }
- if (exprFactory.isSTRUCTFuncCallExpr(columnDesc) && exprFactory.isSTRUCTFuncCallExpr(valueDesc)) {
- List<T> columnChilds = exprFactory.getExprChildren(columnDesc);
- List<T> valueChilds = exprFactory.getExprChildren(valueDesc);
- if (columnChilds.size() != valueChilds.size()) {
- throw new SemanticException(ErrorMsg.INCOMPATIBLE_STRUCT.getMsg(columnChilds + " and " + valueChilds));
- }
- List<T> oldValueChilds = new ArrayList<>(valueChilds);
- valueChilds.clear();
- for (int i = 0; i < oldValueChilds.size(); i++) {
- T newValue = interpretNodeAsStruct(columnChilds.get(i), oldValueChilds.get(i));
- valueChilds.add(newValue);
+ if (constantValuesStruct) {
+ List<Object> literals = (List<Object>) exprFactory.getConstantValue(valueDesc);
+ List<T> constantExpressions = new ArrayList<>();
+ List<TypeInfo> newStructFieldInfos = new ArrayList<>();
+ for (int i = 0; i < columnChilds.size(); i++) {
+ final PrimitiveTypeInfo typeInfo = TypeInfoFactory.getPrimitiveTypeInfo(
+ exprFactory.getTypeInfo(columnChilds.get(i)).getTypeName().toLowerCase());
+ T constantExpression = interpretNodeAsConstant(typeInfo,
+ exprFactory.createConstantExpr(structFieldInfos.get(i), literals.get(i)));
+ if (constantExpression == null) {
+ constantExpression = exprFactory.createConstantExpr(typeInfo, null);
+ }
+ constantExpressions.add(constantExpression);
+ newStructFieldInfos.add(exprFactory.getTypeInfo(constantExpression));
+ }
+ StructTypeInfo structTypeInfo = new StructTypeInfo();
+ structTypeInfo.setAllStructFieldNames(new ArrayList<>(structFieldNames));
+ structTypeInfo.setAllStructFieldTypeInfos(new ArrayList<>(newStructFieldInfos));
+ return exprFactory.createStructExpr(structTypeInfo, constantExpressions);
+ } else { // valuesStruct
+ List<T> valueChilds = exprFactory.getExprChildren(valueDesc);
+ List<T> newValueChilds = new ArrayList<>();
+ List<TypeInfo> newStructFieldInfos = new ArrayList<>();
+ for (int i = 0; i < columnChilds.size(); i++) {
+ T newValue = interpretNode(columnChilds.get(i), valueChilds.get(i));
+ newValueChilds.add(newValue);
+ newStructFieldInfos.add(exprFactory.getTypeInfo(columnChilds.get(i)));
+ }
+ StructTypeInfo structTypeInfo = new StructTypeInfo();
+ structTypeInfo.setAllStructFieldNames(new ArrayList<>(structFieldNames));
+ structTypeInfo.setAllStructFieldTypeInfos(new ArrayList<>(newStructFieldInfos));
+ return exprFactory.createStructExpr(structTypeInfo, newValueChilds);
+ }
}
}
return valueDesc;
}
@VisibleForTesting
- protected T interpretNodeAs(PrimitiveTypeInfo colTypeInfo, T constChild) {
+ protected T interpretNodeAsConstant(PrimitiveTypeInfo targetType, T constChild) throws SemanticException {
if (exprFactory.isConstantExpr(constChild)) {
// Try to narrow type of constant
Object constVal = exprFactory.getConstantValue(constChild);
if (constVal == null) {
// adjust type of null
- return exprFactory.createConstantExpr(colTypeInfo, null);
+ return exprFactory.createConstantExpr(targetType, null);
}
+ PrimitiveTypeInfo sourceType =
+ (PrimitiveTypeInfo) exprFactory.getTypeInfo(constChild);
Object newConst = exprFactory.interpretConstantAsPrimitive(
- colTypeInfo, constVal, (PrimitiveTypeInfo) exprFactory.getTypeInfo(constChild));
+ targetType, constVal, sourceType);
if (newConst == null) {
return null;
}
if (newConst == constVal) {
return constChild;
} else {
- return exprFactory.createConstantExpr(exprFactory.adjustConstantType(colTypeInfo, newConst), newConst);
+ return exprFactory.createConstantExpr(exprFactory.adjustConstantType(targetType, newConst), newConst);
}
}
return constChild;
@@ -1179,7 +1229,7 @@ public class TypeCheckProcFactory<T> {
}
protected T processQualifiedColRef(TypeCheckCtx ctx, ASTNode expr,
- Object... nodeOutputs) throws SemanticException {
+ Object... nodeOutputs) throws SemanticException {
RowResolver input = ctx.getInputRR();
String tableAlias = BaseSemanticAnalyzer.unescapeIdentifier(expr.getChild(0).getChild(0)
.getText());
@@ -1188,18 +1238,23 @@ public class TypeCheckProcFactory<T> {
T desc = (T) nodeOutputs[1];
String colName;
if (exprFactory.isConstantExpr(desc)) {
- colName = exprFactory.getConstantValue(desc).toString();
+ colName = exprFactory.getConstantValueAsString(desc);
} else if (exprFactory.isColumnRefExpr(desc)) {
- colName = exprFactory.getColumnName(desc);
+ colName = exprFactory.getColumnName(desc, input);
} else {
throw new SemanticException("Unexpected ExprNode : " + nodeOutputs[1]);
}
+
ColumnInfo colInfo = input.get(tableAlias, colName);
+ RowResolver usedRR = input;
+ int offset = 0;
// Try outer Row resolver
if (colInfo == null && ctx.getOuterRR() != null) {
RowResolver outerRR = ctx.getOuterRR();
colInfo = outerRR.get(tableAlias, colName);
+ usedRR = outerRR;
+ offset = input.getColumnInfos().size();
}
if (colInfo == null) {
@@ -1207,7 +1262,7 @@ public class TypeCheckProcFactory<T> {
ErrorMsg.INVALID_COLUMN.getMsg(), expr.getChild(1)), expr);
return null;
}
- return exprFactory.toExpr(colInfo);
+ return exprFactory.toExpr(colInfo, usedRR, offset);
}
@Override
@@ -1300,14 +1355,14 @@ public class TypeCheckProcFactory<T> {
for (Map.Entry<String, ColumnInfo> colMap : columns.entrySet()) {
ColumnInfo colInfo = colMap.getValue();
if (!colInfo.getIsVirtualCol()) {
- columnList = exprFactory.addExprToExprsList(columnList, exprFactory.toExpr(colInfo));
+ exprFactory.addExprToExprsList(columnList, exprFactory.toExpr(colInfo, input, 0));
}
}
} else {
// all columns (select *, for example)
for (ColumnInfo colInfo : input.getColumnInfos()) {
if (!colInfo.getIsVirtualCol()) {
- columnList = exprFactory.addExprToExprsList(columnList, exprFactory.toExpr(colInfo));
+ exprFactory.addExprToExprsList(columnList, exprFactory.toExpr(colInfo, input, 0));
}
}
}
@@ -1361,7 +1416,7 @@ public class TypeCheckProcFactory<T> {
RowResolver input = ctx.getInputRR();
for (ColumnInfo colInfo : input.getColumnInfos()) {
if (!colInfo.getIsVirtualCol()) {
- children.add(exprFactory.toExpr(colInfo));
+ children.add(exprFactory.toExpr(colInfo, input, 0));
}
}
}
@@ -1520,14 +1575,18 @@ public class TypeCheckProcFactory<T> {
// If the current subExpression is pre-calculated, as in Group-By etc.
ColumnInfo colInfo = input.getExpression(expr);
+ RowResolver usedRR = input;
+ int offset = 0;
// try outer row resolver
RowResolver outerRR = ctx.getOuterRR();
if (colInfo == null && outerRR != null) {
colInfo = outerRR.getExpression(expr);
+ usedRR = outerRR;
+ offset = input.getColumnInfos().size();
}
if (colInfo != null) {
- desc = exprFactory.createColumnRefExpr(colInfo);
+ desc = exprFactory.createColumnRefExpr(colInfo, usedRR, offset);
ASTNode source = input.getExpressionSource(expr);
if (source != null && ctx.getUnparseTranslator() != null) {
ctx.getUnparseTranslator().addCopyTranslation(expr, source);
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactoryUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactoryUtils.java
deleted file mode 100644
index f1c9850..0000000
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactoryUtils.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hive.ql.parse.type;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.hadoop.hive.ql.ErrorMsg;
-import org.apache.hadoop.hive.ql.exec.FunctionRegistry;
-import org.apache.hadoop.hive.ql.parse.SemanticException;
-import org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc;
-import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc;
-import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
-import org.apache.hadoop.hive.ql.plan.ExprNodeDescUtils;
-import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc;
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPAnd;
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPEqual;
-import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
-import org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo;
-import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
-import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
-
-import com.google.common.collect.Lists;
-
-public class TypeCheckProcFactoryUtils {
-
- static List<ExprNodeDesc> rewriteInToOR(List<ExprNodeDesc> inOperands) throws SemanticException {
- ExprNodeDesc columnDesc = inOperands.get(0);
-
- ArrayList<ExprNodeDesc> orOperands = new ArrayList<>();
- for (int i = 1; i < inOperands.size(); i++) {
- ExprNodeDesc andExpr = buildEqualsArr(columnDesc, inOperands.get(i));
- if (andExpr == null) {
- return null;
- }
- orOperands.add(andExpr);
- }
- return orOperands;
- }
-
- private static ExprNodeDesc buildEqualsArr(ExprNodeDesc columnDesc, ExprNodeDesc exprNodeDesc)
- throws SemanticException {
- List<ExprNodeDesc> lNodes = asListOfNodes(columnDesc);
- List<ExprNodeDesc> rNodes = asListOfNodes(exprNodeDesc);
- if (lNodes == null || rNodes == null) {
- // something went wrong
- return null;
- }
- if (lNodes.size() != rNodes.size()) {
- throw new SemanticException(ErrorMsg.INCOMPATIBLE_STRUCT.getMsg(columnDesc + " and " + exprNodeDesc));
- }
-
- List<ExprNodeDesc> ret = new ArrayList<>();
- for (int i = 0; i < lNodes.size(); i++) {
- ret.add(buildEquals(lNodes.get(i), rNodes.get(i)));
- }
- return buildAnd(ret);
- }
-
- private static ExprNodeGenericFuncDesc buildEquals(ExprNodeDesc columnDesc, ExprNodeDesc valueDesc) {
- return new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo, new GenericUDFOPEqual(), "=",
- Lists.newArrayList(columnDesc, valueDesc));
- }
-
- private static ExprNodeDesc buildAnd(List<ExprNodeDesc> values) {
- if (values.size() == 1) {
- return values.get(0);
- } else {
- return new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo, new GenericUDFOPAnd(), "and", values);
- }
- }
-
- private static List<ExprNodeDesc> asListOfNodes(ExprNodeDesc desc) {
- ExprNodeDesc valueDesc = desc;
- if (ExprNodeDescUtils.isStructUDF(desc)) {
- List<ExprNodeDesc> valueChilds = ((ExprNodeGenericFuncDesc) valueDesc).getChildren();
- for (ExprNodeDesc exprNodeDesc : valueChilds) {
- if (!isSafeExpression(exprNodeDesc)) {
- return null;
- }
- }
- return valueChilds;
- }
- if (ExprNodeDescUtils.isConstantStruct(valueDesc)) {
- ExprNodeConstantDesc valueConstDesc = (ExprNodeConstantDesc) valueDesc;
- List<Object> oldValues = (List<Object>) valueConstDesc.getValue();
- StructTypeInfo structTypeInfo = (StructTypeInfo) valueConstDesc.getTypeInfo();
- ArrayList<TypeInfo> structFieldInfos = structTypeInfo.getAllStructFieldTypeInfos();
-
- List<ExprNodeDesc> ret = new ArrayList<>();
- for (int i = 0; i < oldValues.size(); i++) {
- ret.add(new ExprNodeConstantDesc(structFieldInfos.get(i), oldValues.get(i)));
- }
- return ret;
- }
- if (isSafeExpression(desc)) {
- return Lists.newArrayList(desc);
- }
-
- return null;
- }
-
- private static boolean isSafeExpression(ExprNodeDesc desc) {
- TypeInfo typeInfo = desc.getTypeInfo();
- if (typeInfo.getCategory() != Category.PRIMITIVE) {
- return false;
- }
- if (isConstantOrColumn(desc)) {
- return true;
- }
- if (desc instanceof ExprNodeGenericFuncDesc) {
- ExprNodeGenericFuncDesc exprNodeGenericFuncDesc = (ExprNodeGenericFuncDesc) desc;
- if (FunctionRegistry.isConsistentWithinQuery(exprNodeGenericFuncDesc.getGenericUDF())) {
- for (ExprNodeDesc child : exprNodeGenericFuncDesc.getChildren()) {
- if (!isSafeExpression(child)) {
- return false;
- }
- }
- return true;
- }
- }
- return false;
- }
-
- private static boolean isConstantOrColumn(ExprNodeDesc desc) {
- return desc instanceof ExprNodeColumnDesc || desc instanceof ExprNodeConstantDesc;
- }
-
-}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeDescUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeDescUtils.java
index 26a74c2..bd92730 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeDescUtils.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeDescUtils.java
@@ -664,17 +664,21 @@ public class ExprNodeDescUtils {
public static PrimitiveTypeInfo deriveMinArgumentCast(
ExprNodeDesc childExpr, TypeInfo targetType) {
+ return deriveMinArgumentCast(childExpr.getTypeInfo(), targetType);
+ }
+
+ public static PrimitiveTypeInfo deriveMinArgumentCast(
+ TypeInfo childTi, TypeInfo targetType) {
assert targetType instanceof PrimitiveTypeInfo : "Not a primitive type" + targetType;
PrimitiveTypeInfo pti = (PrimitiveTypeInfo)targetType;
// We only do the minimum cast for decimals. Other types are assumed safe; fix if needed.
// We also don't do anything for non-primitive children (maybe we should assert).
if ((pti.getPrimitiveCategory() != PrimitiveCategory.DECIMAL)
- || (!(childExpr.getTypeInfo() instanceof PrimitiveTypeInfo))) {
+ || (!(childTi instanceof PrimitiveTypeInfo))) {
return pti;
}
- PrimitiveTypeInfo childTi = (PrimitiveTypeInfo)childExpr.getTypeInfo();
// If the child is also decimal, no cast is needed (we hope - can target type be narrower?).
- return HiveDecimalUtils.getDecimalTypeForPrimitiveCategory(childTi);
+ return HiveDecimalUtils.getDecimalTypeForPrimitiveCategory((PrimitiveTypeInfo) childTi);
}
/**
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java
index 1a46cac..35ac545 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java
@@ -232,30 +232,6 @@ public class ExprNodeGenericFuncDesc extends ExprNodeDesc implements
childrenOIs[i] = children.get(i).getWritableObjectInspector();
}
- // Check if a bigint is implicitely cast to a double as part of a comparison
- // Perform the check here instead of in GenericUDFBaseCompare to guarantee it is only run once per operator
- if (genericUDF instanceof GenericUDFBaseCompare && children.size() == 2) {
-
- TypeInfo oiTypeInfo0 = children.get(0).getTypeInfo();
- TypeInfo oiTypeInfo1 = children.get(1).getTypeInfo();
-
- SessionState ss = SessionState.get();
- Configuration conf = (ss != null) ? ss.getConf() : new Configuration();
-
- LogHelper console = new LogHelper(LOG);
-
- // For now, if a bigint is going to be cast to a double throw an error or warning
- if ((oiTypeInfo0.equals(TypeInfoFactory.stringTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.longTypeInfo)) ||
- (oiTypeInfo0.equals(TypeInfoFactory.longTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.stringTypeInfo))) {
- String error = StrictChecks.checkTypeSafety(conf);
- if (error != null) throw new UDFArgumentException(error);
- console.printError("WARNING: Comparing a bigint and a string may result in a loss of precision.");
- } else if ((oiTypeInfo0.equals(TypeInfoFactory.doubleTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.longTypeInfo)) ||
- (oiTypeInfo0.equals(TypeInfoFactory.longTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.doubleTypeInfo))) {
- console.printError("WARNING: Comparing a bigint and a double may result in a loss of precision.");
- }
- }
-
ObjectInspector oi = genericUDF.initializeAndFoldConstants(childrenOIs);
String[] requiredJars = genericUDF.getRequiredJars();
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/parse/type/TestTypeCheckProcFactory.java b/ql/src/test/org/apache/hadoop/hive/ql/parse/type/TestTypeCheckProcFactory.java
index b27dacb..3740d98 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/parse/type/TestTypeCheckProcFactory.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/parse/type/TestTypeCheckProcFactory.java
@@ -78,63 +78,63 @@ public class TestTypeCheckProcFactory {
testSubject = ExprNodeTypeCheck.getExprNodeDefaultExprProcessor();
}
- public void testOneCase(Object constValue) {
+ public void testOneCase(Object constValue) throws Exception {
Mockito.when(nodeDesc.getValue()).thenReturn(constValue);
Mockito.when(typeInfo.getPrimitiveTypeEntry()).thenReturn(constType);
- ExprNodeConstantDesc result = (ExprNodeConstantDesc) testSubject.interpretNodeAs(typeInfo, nodeDesc);
+ ExprNodeConstantDesc result = (ExprNodeConstantDesc) testSubject.interpretNodeAsConstant(typeInfo, nodeDesc);
Assert.assertNotNull(result);
Assert.assertEquals(expectedValue, result.getValue());
}
- public void testNullCase(Object constValue) {
+ public void testNullCase(Object constValue) throws Exception {
Mockito.when(nodeDesc.getValue()).thenReturn(constValue);
Mockito.when(typeInfo.getPrimitiveTypeEntry()).thenReturn(constType);
- ExprNodeConstantDesc result = (ExprNodeConstantDesc) testSubject.interpretNodeAs(typeInfo, nodeDesc);
+ ExprNodeConstantDesc result = (ExprNodeConstantDesc) testSubject.interpretNodeAsConstant(typeInfo, nodeDesc);
Assert.assertNull(result);
}
@Test
- public void testWithSring() {
+ public void testWithSring() throws Exception {
testOneCase(maxValue.toString());
}
@Test
- public void testWithLSuffix() {
+ public void testWithLSuffix() throws Exception {
if (intType) {
testOneCase(maxValue.toString() + "L");
}
}
@Test
- public void testWithZeroFraction() {
+ public void testWithZeroFraction() throws Exception {
if (intType) {
testOneCase(maxValue.toString() + ".0");
}
}
@Test
- public void testWithFSuffix() {
+ public void testWithFSuffix() throws Exception {
testOneCase(maxValue.toString() + "f");
}
@Test
- public void testWithDSuffix() {
+ public void testWithDSuffix() throws Exception {
testOneCase(maxValue.toString() + "D");
}
@Test
- public void testOverflow() {
+ public void testOverflow() throws Exception {
if (intType) {
testNullCase(maxValue.add(BigDecimal.valueOf(1L)).toString());
}
}
@Test
- public void testWithNonZeroFraction() {
+ public void testWithNonZeroFraction() throws Exception {
if (intType) {
testNullCase("100.1");
}
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/plan/mapping/TestCounterMapping.java b/ql/src/test/org/apache/hadoop/hive/ql/plan/mapping/TestCounterMapping.java
index 7de7065..f596324 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/plan/mapping/TestCounterMapping.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/plan/mapping/TestCounterMapping.java
@@ -183,11 +183,11 @@ public class TestCounterMapping {
List<FilterOperator> fos = pm.getAll(FilterOperator.class);
OpTreeSignature filterSig = pm.lookup(OpTreeSignature.class, fos.get(0));
Object pred = filterSig.getSig().getSigMap().get("getPredicateString");
- assertEquals("(u = 2) (type: boolean)", pred);
-
+ // TODO: Missed opportunity due to cast on constant preventing simplification.
+ // Fixed when we upgrade to Calcite 1.22.0
+ assertEquals("((u = 2) and (u) IN (1, 2, 3)) (type: boolean)", pred);
}
-
@Test
@Ignore("needs HiveFilter mapping")
public void testMappingJoinLookup() throws ParseException, CommandProcessorException {
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/testutil/BaseScalarUdfTest.java b/ql/src/test/org/apache/hadoop/hive/ql/testutil/BaseScalarUdfTest.java
index ec0bc89..693fe67 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/testutil/BaseScalarUdfTest.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/testutil/BaseScalarUdfTest.java
@@ -71,7 +71,7 @@ public abstract class BaseScalarUdfTest {
* @return A list of expressions
* @throws UDFArgumentException if the UDF has been formulated incorrectly
*/
- public abstract List<ExprNodeDesc> getExpressionList() throws UDFArgumentException;
+ public abstract List<ExprNodeDesc> getExpressionList() throws Exception;
/**
* This method drives the test. It takes the data from getBaseTable() and
@@ -81,7 +81,7 @@ public abstract class BaseScalarUdfTest {
* @throws HiveException
*/
@Test
- public final void testUdf() throws HiveException {
+ public final void testUdf() throws Exception {
InspectableObject [] data = getBaseTable();
List<ExprNodeDesc> expressionList = getExpressionList();
SelectDesc selectCtx = new SelectDesc(expressionList,
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFConcat.java b/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFConcat.java
index 8519a12..c76a39d 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFConcat.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFConcat.java
@@ -21,9 +21,7 @@ package org.apache.hadoop.hive.ql.udf.generic;
import java.util.ArrayList;
import java.util.List;
-import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.parse.type.ExprNodeTypeCheck;
-import org.apache.hadoop.hive.ql.parse.type.TypeCheckProcFactory;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
import org.apache.hadoop.hive.ql.testutil.BaseScalarUdfTest;
import org.apache.hadoop.hive.ql.testutil.DataBuilder;
@@ -63,7 +61,7 @@ public class TestGenericUDFConcat extends BaseScalarUdfTest {
}
@Override
- public List<ExprNodeDesc> getExpressionList() throws UDFArgumentException {
+ public List<ExprNodeDesc> getExpressionList() throws Exception {
ExprNodeDesc expr1 = OperatorTestUtils.getStringColumn("a");
ExprNodeDesc expr2 = OperatorTestUtils.getStringColumn("b");
ExprNodeDesc exprDesc2 = ExprNodeTypeCheck.getExprNodeDefaultExprProcessor()
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFRound.java b/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFRound.java
index 8c871d5..47606c5 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFRound.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFRound.java
@@ -26,7 +26,6 @@ import org.junit.Assert;
import org.apache.hadoop.hive.common.type.HiveDecimal;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
-import org.apache.hadoop.hive.ql.parse.type.TypeCheckProcFactory;
import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
import org.apache.hadoop.hive.ql.testutil.BaseScalarUdfTest;
@@ -94,7 +93,7 @@ public class TestGenericUDFRound extends BaseScalarUdfTest {
}
@Override
- public List<ExprNodeDesc> getExpressionList() throws UDFArgumentException {
+ public List<ExprNodeDesc> getExpressionList() throws Exception {
List<ExprNodeDesc> exprs = new ArrayList<ExprNodeDesc>(cols.length);
for (int i = 0; i < cols.length; i++) {
exprs.add(OperatorTestUtils.getStringColumn(cols[i]));
diff --git a/ql/src/test/queries/clientpositive/partition_coltype_literals.q b/ql/src/test/queries/clientpositive/partition_coltype_literals.q
index e65371e..9d92278 100644
--- a/ql/src/test/queries/clientpositive/partition_coltype_literals.q
+++ b/ql/src/test/queries/clientpositive/partition_coltype_literals.q
@@ -1,4 +1,5 @@
--! qt:dataset:src
+set hive.strict.checks.type.safety=false;
set hive.stats.column.autogather=false;
set hive.compute.query.using.stats=false;
drop table if exists partcoltypenum;
diff --git a/ql/src/test/results/clientpositive/alter_partition_coltype.q.out b/ql/src/test/results/clientpositive/alter_partition_coltype.q.out
index cd7681c..183cc4f 100644
--- a/ql/src/test/results/clientpositive/alter_partition_coltype.q.out
+++ b/ql/src/test/results/clientpositive/alter_partition_coltype.q.out
@@ -160,7 +160,7 @@ POSTHOOK: Input: default@alter_coltype
#### A masked pattern was here ####
OPTIMIZED SQL: SELECT COUNT(*) AS `$f0`
FROM `default`.`alter_coltype`
-WHERE `ts` = 3.0 AND `dt` = 100
+WHERE `ts` = 3 AND `dt` = 100
STAGE DEPENDENCIES:
Stage-0 is a root stage
diff --git a/ql/src/test/results/clientpositive/avrotblsjoin.q.out b/ql/src/test/results/clientpositive/avrotblsjoin.q.out
index f657955..3e6969a 100644
--- a/ql/src/test/results/clientpositive/avrotblsjoin.q.out
+++ b/ql/src/test/results/clientpositive/avrotblsjoin.q.out
@@ -72,6 +72,7 @@ POSTHOOK: Output: default@table1_1
POSTHOOK: Lineage: table1_1.col1 SCRIPT []
POSTHOOK: Lineage: table1_1.col2 SCRIPT []
WARNING: Comparing a bigint and a string may result in a loss of precision.
+WARNING: Comparing a bigint and a string may result in a loss of precision.
Warning: Shuffle Join JOIN[8][tables = [$hdt$_0, $hdt$_1]] in Stage 'Stage-1:MAPRED' is a cross product
PREHOOK: query: select table1_n1.col1, table1_1.* from table1_n1 join table1_1 on table1_n1.col1=table1_1.col1 where table1_1.col1="1"
PREHOOK: type: QUERY
diff --git a/ql/src/test/results/clientpositive/constprog_cast.q.out b/ql/src/test/results/clientpositive/constprog_cast.q.out
deleted file mode 100644
index 3f76604..0000000
--- a/ql/src/test/results/clientpositive/constprog_cast.q.out
+++ /dev/null
@@ -1,221 +0,0 @@
-PREHOOK: query: CREATE TABLE constcasttest (id string)
-PREHOOK: type: CREATETABLE
-PREHOOK: Output: database:default
-PREHOOK: Output: default@constcasttest
-POSTHOOK: query: CREATE TABLE constcasttest (id string)
-POSTHOOK: type: CREATETABLE
-POSTHOOK: Output: database:default
-POSTHOOK: Output: default@constcasttest
-PREHOOK: query: INSERT INTO constcasttest values('2019-11-05 01:01:11')
-PREHOOK: type: QUERY
-PREHOOK: Input: _dummy_database@_dummy_table
-PREHOOK: Output: default@constcasttest
-POSTHOOK: query: INSERT INTO constcasttest values('2019-11-05 01:01:11')
-POSTHOOK: type: QUERY
-POSTHOOK: Input: _dummy_database@_dummy_table
-POSTHOOK: Output: default@constcasttest
-POSTHOOK: Lineage: constcasttest.id SCRIPT []
-PREHOOK: query: EXPLAIN SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE CAST(id AS VARCHAR(9)) = '2019-11-0'
-PREHOOK: type: QUERY
-PREHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-POSTHOOK: query: EXPLAIN SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE CAST(id AS VARCHAR(9)) = '2019-11-0'
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-STAGE DEPENDENCIES:
- Stage-1 is a root stage
- Stage-0 depends on stages: Stage-1
-
-STAGE PLANS:
- Stage: Stage-1
- Map Reduce
- Map Operator Tree:
- TableScan
- alias: constcasttest
- filterExpr: (CAST( CAST( id AS varchar(9)) AS STRING) = '2019-11-0') (type: boolean)
- Statistics: Num rows: 1 Data size: 103 Basic stats: COMPLETE Column stats: COMPLETE
- Filter Operator
- predicate: (CAST( CAST( id AS varchar(9)) AS STRING) = '2019-11-0') (type: boolean)
- Statistics: Num rows: 1 Data size: 103 Basic stats: COMPLETE Column stats: COMPLETE
- Select Operator
- expressions: id (type: string), CAST( id AS varchar(10)) (type: varchar(10))
- outputColumnNames: _col0, _col1
- Statistics: Num rows: 1 Data size: 197 Basic stats: COMPLETE Column stats: COMPLETE
- File Output Operator
- compressed: false
- Statistics: Num rows: 1 Data size: 197 Basic stats: COMPLETE Column stats: COMPLETE
- table:
- input format: org.apache.hadoop.mapred.SequenceFileInputFormat
- output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
- serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
- Execution mode: vectorized
-
- Stage: Stage-0
- Fetch Operator
- limit: -1
- Processor Tree:
- ListSink
-
-PREHOOK: query: SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE CAST(id AS VARCHAR(9)) = '2019-11-0'
-PREHOOK: type: QUERY
-PREHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-POSTHOOK: query: SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE CAST(id AS VARCHAR(9)) = '2019-11-0'
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-2019-11-05 01:01:11 2019-11-05
-PREHOOK: query: EXPLAIN SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE SUBSTR(id, 0, 9) = '2019-11-0'
-PREHOOK: type: QUERY
-PREHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-POSTHOOK: query: EXPLAIN SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE SUBSTR(id, 0, 9) = '2019-11-0'
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-STAGE DEPENDENCIES:
- Stage-1 is a root stage
- Stage-0 depends on stages: Stage-1
-
-STAGE PLANS:
- Stage: Stage-1
- Map Reduce
- Map Operator Tree:
- TableScan
- alias: constcasttest
- filterExpr: (substr(id, 0, 9) = '2019-11-0') (type: boolean)
- Statistics: Num rows: 1 Data size: 103 Basic stats: COMPLETE Column stats: COMPLETE
- Filter Operator
- predicate: (substr(id, 0, 9) = '2019-11-0') (type: boolean)
- Statistics: Num rows: 1 Data size: 103 Basic stats: COMPLETE Column stats: COMPLETE
- Select Operator
- expressions: id (type: string), CAST( id AS varchar(10)) (type: varchar(10))
- outputColumnNames: _col0, _col1
- Statistics: Num rows: 1 Data size: 197 Basic stats: COMPLETE Column stats: COMPLETE
- File Output Operator
- compressed: false
- Statistics: Num rows: 1 Data size: 197 Basic stats: COMPLETE Column stats: COMPLETE
- table:
- input format: org.apache.hadoop.mapred.SequenceFileInputFormat
- output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
- serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
- Execution mode: vectorized
-
- Stage: Stage-0
- Fetch Operator
- limit: -1
- Processor Tree:
- ListSink
-
-PREHOOK: query: SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE SUBSTR(id, 0, 9) = '2019-11-0'
-PREHOOK: type: QUERY
-PREHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-POSTHOOK: query: SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE SUBSTR(id, 0, 9) = '2019-11-0'
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-2019-11-05 01:01:11 2019-11-05
-PREHOOK: query: EXPLAIN SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE CAST(id AS VARCHAR(9)) = '2019-11-0'
-PREHOOK: type: QUERY
-PREHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-POSTHOOK: query: EXPLAIN SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE CAST(id AS VARCHAR(9)) = '2019-11-0'
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-STAGE DEPENDENCIES:
- Stage-1 is a root stage
- Stage-0 depends on stages: Stage-1
-
-STAGE PLANS:
- Stage: Stage-1
- Map Reduce
- Map Operator Tree:
- TableScan
- alias: constcasttest
- filterExpr: (CAST( id AS varchar(9)) = '2019-11-0') (type: boolean)
- Statistics: Num rows: 1 Data size: 103 Basic stats: COMPLETE Column stats: COMPLETE
- Filter Operator
- predicate: (CAST( id AS varchar(9)) = '2019-11-0') (type: boolean)
- Statistics: Num rows: 1 Data size: 103 Basic stats: COMPLETE Column stats: COMPLETE
- Select Operator
- expressions: id (type: string), CAST( id AS varchar(10)) (type: varchar(10))
- outputColumnNames: _col0, _col1
- Statistics: Num rows: 1 Data size: 197 Basic stats: COMPLETE Column stats: COMPLETE
- File Output Operator
- compressed: false
- Statistics: Num rows: 1 Data size: 197 Basic stats: COMPLETE Column stats: COMPLETE
- table:
- input format: org.apache.hadoop.mapred.SequenceFileInputFormat
- output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
- serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
- Execution mode: vectorized
-
- Stage: Stage-0
- Fetch Operator
- limit: -1
- Processor Tree:
- ListSink
-
-PREHOOK: query: SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE CAST(id AS VARCHAR(9)) = '2019-11-0'
-PREHOOK: type: QUERY
-PREHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-POSTHOOK: query: SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE CAST(id AS VARCHAR(9)) = '2019-11-0'
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-2019-11-05 01:01:11 2019-11-05
-PREHOOK: query: EXPLAIN SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE SUBSTR(id, 0, 9) = '2019-11-0'
-PREHOOK: type: QUERY
-PREHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-POSTHOOK: query: EXPLAIN SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE SUBSTR(id, 0, 9) = '2019-11-0'
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-STAGE DEPENDENCIES:
- Stage-1 is a root stage
- Stage-0 depends on stages: Stage-1
-
-STAGE PLANS:
- Stage: Stage-1
- Map Reduce
- Map Operator Tree:
- TableScan
- alias: constcasttest
- filterExpr: (substr(id, 0, 9) = '2019-11-0') (type: boolean)
- Statistics: Num rows: 1 Data size: 103 Basic stats: COMPLETE Column stats: COMPLETE
- Filter Operator
- predicate: (substr(id, 0, 9) = '2019-11-0') (type: boolean)
- Statistics: Num rows: 1 Data size: 103 Basic stats: COMPLETE Column stats: COMPLETE
- Select Operator
- expressions: id (type: string), CAST( id AS varchar(10)) (type: varchar(10))
- outputColumnNames: _col0, _col1
- Statistics: Num rows: 1 Data size: 197 Basic stats: COMPLETE Column stats: COMPLETE
- File Output Operator
- compressed: false
- Statistics: Num rows: 1 Data size: 197 Basic stats: COMPLETE Column stats: COMPLETE
- table:
- input format: org.apache.hadoop.mapred.SequenceFileInputFormat
- output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
- serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
- Execution mode: vectorized
-
- Stage: Stage-0
- Fetch Operator
- limit: -1
- Processor Tree:
- ListSink
-
-PREHOOK: query: SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE SUBSTR(id, 0, 9) = '2019-11-0'
-PREHOOK: type: QUERY
-PREHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-POSTHOOK: query: SELECT id, CAST(id AS VARCHAR(10)) FROM constcasttest WHERE SUBSTR(id, 0, 9) = '2019-11-0'
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@constcasttest
-#### A masked pattern was here ####
-2019-11-05 01:01:11 2019-11-05
diff --git a/ql/src/test/results/clientpositive/decimal_precision2.q.out b/ql/src/test/results/clientpositive/decimal_precision2.q.out
index 3ec620c..3cba039 100644
--- a/ql/src/test/results/clientpositive/decimal_precision2.q.out
+++ b/ql/src/test/results/clientpositive/decimal_precision2.q.out
@@ -175,7 +175,7 @@ STAGE PLANS:
Row Limit Per Split: 1
Statistics: Num rows: 1 Data size: 10 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
- expressions: 69.0212249755859375 (type: decimal(27,20))
+ expressions: 69.0212249755859375 (type: decimal(29,20))
outputColumnNames: _col0
Statistics: Num rows: 1 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
ListSink
diff --git a/ql/src/test/results/clientpositive/druid/druid_timeseries.q.out b/ql/src/test/results/clientpositive/druid/druid_timeseries.q.out
index beb4618..afbb2a1 100644
--- a/ql/src/test/results/clientpositive/druid/druid_timeseries.q.out
+++ b/ql/src/test/results/clientpositive/druid/druid_timeseries.q.out
@@ -31,7 +31,7 @@ STAGE PLANS:
properties:
druid.fieldNames $f0
druid.fieldTypes bigint
- druid.query.json {"queryType":"timeseries","dataSource":"wikipedia","descending":false,"granularity":"all","filter":{"type":"or","fields":[{"type":"bound","dimension":"added","upper":"0.0","upperStrict":false,"ordering":"numeric"},{"type":"bound","dimension":"__time","lower":"2010-01-01T00:00:00.000Z","lowerStrict":false,"upper":"2012-03-01T00:00:00.000Z","upperStrict":false,"ordering":"lexicographic","extractionFn":{"type":"timeFormat","format":"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" [...]
+ druid.query.json {"queryType":"timeseries","dataSource":"wikipedia","descending":false,"granularity":"all","filter":{"type":"or","fields":[{"type":"bound","dimension":"added","upper":"0","upperStrict":false,"ordering":"numeric"},{"type":"bound","dimension":"__time","lower":"2010-01-01T00:00:00.000Z","lowerStrict":false,"upper":"2012-03-01T00:00:00.000Z","upperStrict":false,"ordering":"lexicographic","extractionFn":{"type":"timeFormat","format":"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"," [...]
druid.query.type timeseries
Select Operator
expressions: $f0 (type: bigint)
diff --git a/ql/src/test/results/clientpositive/druid/druidkafkamini_basic.q.out b/ql/src/test/results/clientpositive/druid/druidkafkamini_basic.q.out
index f57b6b3..7e3c2ca 100644
--- a/ql/src/test/results/clientpositive/druid/druidkafkamini_basic.q.out
+++ b/ql/src/test/results/clientpositive/druid/druidkafkamini_basic.q.out
@@ -542,7 +542,7 @@ STAGE PLANS:
properties:
druid.fieldNames language,c
druid.fieldTypes string,double
- druid.query.json {"queryType":"groupBy","dataSource":"default.druid_kafka_test","granularity":"all","dimensions":[{"type":"default","dimension":"language","outputName":"language","outputType":"STRING"}],"limitSpec":{"type":"default","columns":[{"dimension":"c","direction":"descending","dimensionOrder":"numeric"}]},"aggregations":[{"type":"longSum","name":"$f1","fieldName":"added"},{"type":"longSum","name":"$f2","fieldName":"deleted"},{"type":"count","name":"$f3"}],"postAggreg [...]
+ druid.query.json {"queryType":"groupBy","dataSource":"default.druid_kafka_test","granularity":"all","dimensions":[{"type":"default","dimension":"language","outputName":"language","outputType":"STRING"}],"limitSpec":{"type":"default","columns":[{"dimension":"c","direction":"descending","dimensionOrder":"numeric"}]},"aggregations":[{"type":"longSum","name":"$f1","fieldName":"added"},{"type":"longSum","name":"$f2","fieldName":"deleted"},{"type":"count","name":"$f3"}],"postAggreg [...]
druid.query.type groupBy
Select Operator
expressions: language (type: string), c (type: double)
diff --git a/ql/src/test/results/clientpositive/groupby_multi_single_reducer3.q.out b/ql/src/test/results/clientpositive/groupby_multi_single_reducer3.q.out
index f7683c6..4b4d57f 100644
--- a/ql/src/test/results/clientpositive/groupby_multi_single_reducer3.q.out
+++ b/ql/src/test/results/clientpositive/groupby_multi_single_reducer3.q.out
@@ -57,10 +57,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: src
- filterExpr: ((((value = 'val_400') or (value = 'val_500')) and ((key = 400) or (key = 450))) or (((value = 'val_100') or (value = 'val_200') or (value = 'val_300')) and ((key = 100) or (key = 150) or (key = 200)))) (type: boolean)
+ filterExpr: (((value) IN ('val_400', 'val_500') and (key) IN (400, 450)) or ((value) IN ('val_100', 'val_200', 'val_300') and (key) IN (100, 150, 200))) (type: boolean)
Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((((value = 'val_400') or (value = 'val_500')) and ((key = 400) or (key = 450))) or (((value = 'val_100') or (value = 'val_200') or (value = 'val_300')) and ((key = 100) or (key = 150) or (key = 200)))) (type: boolean)
+ predicate: (((value) IN ('val_400', 'val_500') and (key) IN (400, 450)) or ((value) IN ('val_100', 'val_200', 'val_300') and (key) IN (100, 150, 200))) (type: boolean)
Statistics: Num rows: 5 Data size: 890 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: key (type: string)
@@ -69,12 +69,11 @@ STAGE PLANS:
Map-reduce partition columns: key (type: string)
Statistics: Num rows: 5 Data size: 890 Basic stats: COMPLETE Column stats: COMPLETE
value expressions: value (type: string)
- Execution mode: vectorized
Reduce Operator Tree:
Forward
Statistics: Num rows: 5 Data size: 890 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: (((VALUE._col0 = 'val_100') or (VALUE._col0 = 'val_200') or (VALUE._col0 = 'val_300')) and ((KEY._col0 = 100) or (KEY._col0 = 150) or (KEY._col0 = 200))) (type: boolean)
+ predicate: ((VALUE._col0) IN ('val_100', 'val_200', 'val_300') and (KEY._col0) IN (100, 150, 200)) (type: boolean)
Statistics: Num rows: 3 Data size: 534 Basic stats: COMPLETE Column stats: COMPLETE
Group By Operator
aggregations: count()
@@ -111,7 +110,7 @@ STAGE PLANS:
output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
Filter Operator
- predicate: (((VALUE._col0 = 'val_400') or (VALUE._col0 = 'val_500')) and ((KEY._col0 = 400) or (KEY._col0 = 450))) (type: boolean)
+ predicate: ((VALUE._col0) IN ('val_400', 'val_500') and (KEY._col0) IN (400, 450)) (type: boolean)
Statistics: Num rows: 2 Data size: 356 Basic stats: COMPLETE Column stats: COMPLETE
Group By Operator
aggregations: count()
@@ -593,7 +592,7 @@ STAGE PLANS:
alias: src
Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((((value = 'val_400') or (value = 'val_500')) and ((key = 400) or (key = 450))) or (((value = 'val_100') or (value = 'val_200') or (value = 'val_300')) and ((key = 100) or (key = 150) or (key = 200)))) (type: boolean)
+ predicate: (((value) IN ('val_400', 'val_500') and (key) IN (400, 450)) or ((value) IN ('val_100', 'val_200', 'val_300') and (key) IN (100, 150, 200))) (type: boolean)
Statistics: Num rows: 5 Data size: 890 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: key (type: string)
@@ -602,12 +601,11 @@ STAGE PLANS:
Map-reduce partition columns: key (type: string)
Statistics: Num rows: 5 Data size: 890 Basic stats: COMPLETE Column stats: COMPLETE
value expressions: value (type: string)
- Execution mode: vectorized
Reduce Operator Tree:
Forward
Statistics: Num rows: 5 Data size: 890 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: (((VALUE._col0 = 'val_100') or (VALUE._col0 = 'val_200') or (VALUE._col0 = 'val_300')) and ((KEY._col0 = 100) or (KEY._col0 = 150) or (KEY._col0 = 200))) (type: boolean)
+ predicate: ((VALUE._col0) IN ('val_100', 'val_200', 'val_300') and (KEY._col0) IN (100, 150, 200)) (type: boolean)
Statistics: Num rows: 3 Data size: 534 Basic stats: COMPLETE Column stats: COMPLETE
Group By Operator
aggregations: count()
@@ -644,7 +642,7 @@ STAGE PLANS:
output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
Filter Operator
- predicate: (((VALUE._col0 = 'val_400') or (VALUE._col0 = 'val_500')) and ((KEY._col0 = 400) or (KEY._col0 = 450))) (type: boolean)
+ predicate: ((VALUE._col0) IN ('val_400', 'val_500') and (KEY._col0) IN (400, 450)) (type: boolean)
Statistics: Num rows: 2 Data size: 356 Basic stats: COMPLETE Column stats: COMPLETE
Group By Operator
aggregations: count()
diff --git a/ql/src/test/results/clientpositive/in_typecheck_char.q.out b/ql/src/test/results/clientpositive/in_typecheck_char.q.out
index cded6d3..d2fcdf4 100644
--- a/ql/src/test/results/clientpositive/in_typecheck_char.q.out
+++ b/ql/src/test/results/clientpositive/in_typecheck_char.q.out
@@ -108,13 +108,13 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: ax
- filterExpr: (struct(s,t)) IN (const struct('a','a '), const struct('b','bb ')) (type: boolean)
+ filterExpr: (struct(CAST( s AS STRING),CAST( t AS STRING))) IN (const struct('a','a'), const struct('b','bb')) (type: boolean)
Statistics: Num rows: 3 Data size: 510 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: (struct(s,t)) IN (const struct('a','a '), const struct('b','bb ')) (type: boolean)
- Statistics: Num rows: 2 Data size: 340 Basic stats: COMPLETE Column stats: COMPLETE
+ predicate: (struct(CAST( s AS STRING),CAST( t AS STRING))) IN (const struct('a','a'), const struct('b','bb')) (type: boolean)
+ Statistics: Num rows: 1 Data size: 170 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
- Statistics: Num rows: 2 Data size: 340 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 1 Data size: 170 Basic stats: COMPLETE Column stats: COMPLETE
Group By Operator
aggregations: count()
minReductionHashAggr: 0.99
@@ -126,6 +126,7 @@ STAGE PLANS:
sort order:
Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
value expressions: _col0 (type: bigint)
+ Execution mode: vectorized
Reduce Operator Tree:
Group By Operator
aggregations: count(VALUE._col0)
@@ -213,10 +214,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: ax
- filterExpr: (((s = 'a') and (t = 'a ')) or (null and (t = 'bb '))) is null (type: boolean)
+ filterExpr: (((CAST( s AS STRING) = 'a') and (CAST( t AS STRING) = 'a')) or (null and (CAST( t AS STRING) = 'bb'))) is null (type: boolean)
Statistics: Num rows: 3 Data size: 510 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: (((s = 'a') and (t = 'a ')) or (null and (t = 'bb '))) is null (type: boolean)
+ predicate: (((CAST( s AS STRING) = 'a') and (CAST( t AS STRING) = 'a')) or (null and (CAST( t AS STRING) = 'bb'))) is null (type: boolean)
Statistics: Num rows: 1 Data size: 170 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
Statistics: Num rows: 1 Data size: 170 Basic stats: COMPLETE Column stats: COMPLETE
diff --git a/ql/src/test/results/clientpositive/in_typecheck_varchar.q.out b/ql/src/test/results/clientpositive/in_typecheck_varchar.q.out
index 689f50a..2c73d02 100644
--- a/ql/src/test/results/clientpositive/in_typecheck_varchar.q.out
+++ b/ql/src/test/results/clientpositive/in_typecheck_varchar.q.out
@@ -108,10 +108,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: ax
- filterExpr: (struct(s,t)) IN (const struct('a','a'), const struct('b','bb')) (type: boolean)
+ filterExpr: (struct(CAST( s AS STRING),CAST( t AS STRING))) IN (const struct('a','a'), const struct('b','bb')) (type: boolean)
Statistics: Num rows: 3 Data size: 513 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: (struct(s,t)) IN (const struct('a','a'), const struct('b','bb')) (type: boolean)
+ predicate: (struct(CAST( s AS STRING),CAST( t AS STRING))) IN (const struct('a','a'), const struct('b','bb')) (type: boolean)
Statistics: Num rows: 1 Data size: 171 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
Statistics: Num rows: 1 Data size: 171 Basic stats: COMPLETE Column stats: COMPLETE
@@ -126,6 +126,7 @@ STAGE PLANS:
sort order:
Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
value expressions: _col0 (type: bigint)
+ Execution mode: vectorized
Reduce Operator Tree:
Group By Operator
aggregations: count(VALUE._col0)
diff --git a/ql/src/test/results/clientpositive/infer_const_type.q.out b/ql/src/test/results/clientpositive/infer_const_type.q.out
index aacc329..b636090 100644
--- a/ql/src/test/results/clientpositive/infer_const_type.q.out
+++ b/ql/src/test/results/clientpositive/infer_const_type.q.out
@@ -29,6 +29,7 @@ POSTHOOK: Input: default@infertypes
127 32767 12345 -12345 906.0 -307.0 1234
126 32767 12345 -12345 906.0 -307.0 1234
126 32767 12345 -12345 906.0 -307.0 1.57
+WARNING: Comparing a bigint and a string may result in a loss of precision.
PREHOOK: query: EXPLAIN SELECT * FROM infertypes WHERE
ti = '127' AND
si = 32767 AND
@@ -85,6 +86,7 @@ STAGE PLANS:
Processor Tree:
ListSink
+WARNING: Comparing a bigint and a string may result in a loss of precision.
PREHOOK: query: SELECT * FROM infertypes WHERE
ti = '127' AND
si = 32767 AND
@@ -108,6 +110,7 @@ POSTHOOK: type: QUERY
POSTHOOK: Input: default@infertypes
#### A masked pattern was here ####
127 32767 12345 -12345 906.0 -307.0 1234
+WARNING: Comparing a bigint and a string may result in a loss of precision.
PREHOOK: query: EXPLAIN SELECT * FROM infertypes WHERE
ti = '128' OR
si = 32768 OR
@@ -138,6 +141,7 @@ STAGE PLANS:
Processor Tree:
ListSink
+WARNING: Comparing a bigint and a string may result in a loss of precision.
PREHOOK: query: SELECT * FROM infertypes WHERE
ti = '128' OR
si = 32768 OR
@@ -182,10 +186,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: infertypes
- filterExpr: ((ti = 127Y) or (i = -100) or (CAST( si AS decimal(5,0)) = 327)) (type: boolean)
+ filterExpr: ((ti = 127Y) or (si = 327S) or (i = -100)) (type: boolean)
Statistics: Num rows: 1 Data size: 216 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: ((ti = 127Y) or (i = -100) or (CAST( si AS decimal(5,0)) = 327)) (type: boolean)
+ predicate: ((ti = 127Y) or (si = 327S) or (i = -100)) (type: boolean)
Statistics: Num rows: 1 Data size: 216 Basic stats: COMPLETE Column stats: NONE
Select Operator
expressions: ti (type: tinyint), si (type: smallint), i (type: int), bi (type: bigint), fl (type: float), db (type: double), str (type: string)
diff --git a/ql/src/test/results/clientpositive/llap/cbo_limit.q.out b/ql/src/test/results/clientpositive/llap/cbo_limit.q.out
index 4ff88b7..2fb1ba1 100644
--- a/ql/src/test/results/clientpositive/llap/cbo_limit.q.out
+++ b/ql/src/test/results/clientpositive/llap/cbo_limit.q.out
@@ -179,7 +179,7 @@ HiveFilter(condition=[>($0, 1)])
HiveProject(c_int=[$0])
HiveSortLimit(fetch=[1])
HiveProject(c_int=[$2])
- HiveFilter(condition=[>($3, 1.0E0)])
+ HiveFilter(condition=[>($3, 1E0)])
HiveTableScan(table=[[default, cbo_t1]], table:alias=[cbo_t1])
PREHOOK: query: select c_int from (select c_int from cbo_t1 where c_float > 1.0 limit 1) subq where c_int > 1 order by c_int
@@ -205,7 +205,7 @@ HiveSortLimit(fetch=[0])
HiveProject(_o__c0=[$1])
HiveAggregate(group=[{0}], agg#0=[count()])
HiveProject($f0=[true])
- HiveFilter(condition=[>($3, 1.0E0)])
+ HiveFilter(condition=[>($3, 1E0)])
HiveTableScan(table=[[default, cbo_t1]], table:alias=[cbo_t1])
PREHOOK: query: select count(*) from cbo_t1 where c_float > 1.0 group by true limit 0
diff --git a/ql/src/test/results/clientpositive/llap/check_constraint.q.out b/ql/src/test/results/clientpositive/llap/check_constraint.q.out
index 3ef0744..bc5d361 100644
--- a/ql/src/test/results/clientpositive/llap/check_constraint.q.out
+++ b/ql/src/test/results/clientpositive/llap/check_constraint.q.out
@@ -116,7 +116,7 @@ STAGE PLANS:
outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: enforce_constraint((((((((- _col0) > (- 10)) is not false and (_col1 > 10) is not false) and _col2 is not null is not false) and _col3 BETWEEN _col0 AND _col1 is not false) and ((_col4 = 23.4) or (_col4 = 56) or (_col4 = 4)) is not false) and ((_col5 > round(567.6)) and (_col5 < round(1000.4))) is not false)) (type: boolean)
+ predicate: enforce_constraint((((((((- _col0) > -10) is not false and (_col1 > 10) is not false) and _col2 is not null is not false) and _col3 BETWEEN _col0 AND _col1 is not false) and ((_col4) IN (23.4) or (_col4) IN (56) or (_col4) IN (4)) is not false) and ((_col5 > round(567.6)) and (_col5 < round(1000.4))) is not false)) (type: boolean)
Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: _col0 (type: int), _col1 (type: int), _col2 (type: boolean), _col3 (type: int), UDFToFloat(_col4) (type: float), UDFToLong(_col5) (type: bigint)
@@ -3382,7 +3382,7 @@ STAGE PLANS:
outputColumnNames: _col0, _col1
Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: enforce_constraint(((null = 4) or (null = 5)) is not false) (type: boolean)
+ predicate: enforce_constraint((null) IN (4, 5) is not false) (type: boolean)
Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: UDFToByte(_col0) (type: tinyint), _col1 (type: bigint)
@@ -3467,7 +3467,7 @@ STAGE PLANS:
outputColumnNames: _col0, _col1
Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: enforce_constraint(((_col1 = 4) or (_col1 = 5)) is not false) (type: boolean)
+ predicate: enforce_constraint((_col1) IN (4, 5) is not false) (type: boolean)
Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: _col0 (type: tinyint), UDFToLong(_col1) (type: bigint)
diff --git a/ql/src/test/results/clientpositive/llap/collision.q.out b/ql/src/test/results/clientpositive/llap/collision.q.out
index 4b889df..712acc2 100644
--- a/ql/src/test/results/clientpositive/llap/collision.q.out
+++ b/ql/src/test/results/clientpositive/llap/collision.q.out
@@ -477,7 +477,7 @@ POSTHOOK: Input: cpn@mytable_1000_n
POSTHOOK: Output: cpn_view@myview_1000_n
POSTHOOK: Output: database:cpn_view
CBO PLAN:
-HiveProject(col0=[$0], col1=[$1], col2=[$2], col3=[$118], col4=[$3], col5=[$4], col6=[$5], col7=[$6], col8=[CASE(IS NOT NULL($7), $7, 0:DECIMAL(1, 0))], col9=[CASE(IS NOT NULL($8), $8, 0:DECIMAL(28, 0))], col10=[$9], alt_col11=[CASE(CASE(IS NOT NULL($20), =(CAST($20):VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'X'), false), _UTF-16LE'Y':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", CAST($20):VARCHAR(2147483647) CHARACTER SET "UTF-16LE")], alt_col12=[CASE(CASE(IS NOT NULL($91), [...]
+HiveProject(col0=[$0], col1=[$1], col2=[$2], col3=[$118], col4=[$3], col5=[$4], col6=[$5], col7=[$6], col8=[CASE(IS NOT NULL($7), $7, 0:DECIMAL(1, 0))], col9=[CASE(IS NOT NULL($8), $8, 0:DECIMAL(28, 0))], col10=[$9], alt_col11=[CASE(CASE(IS NOT NULL($20), =(CAST($20):VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'X'), false), _UTF-16LE'Y':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", CAST($20):VARCHAR(2147483647) CHARACTER SET "UTF-16LE")], alt_col12=[CASE(CASE(IS NOT NULL($91), [...]
HiveTableScan(table=[[cpn, mytable_1000_n]], table:alias=[mytable_1000_n])
PREHOOK: query: CREATE OR REPLACE VIEW cpn_view.myview_1000_n AS
diff --git a/ql/src/test/results/clientpositive/llap/constraints_optimization.q.out b/ql/src/test/results/clientpositive/llap/constraints_optimization.q.out
index 19238bc..4e4f087 100644
--- a/ql/src/test/results/clientpositive/llap/constraints_optimization.q.out
+++ b/ql/src/test/results/clientpositive/llap/constraints_optimization.q.out
@@ -2581,7 +2581,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject($f0=[$0])
- HiveFilter(condition=[>($1, 0:DECIMAL(1, 0))])
+ HiveFilter(condition=[>($1, 0)])
HiveAggregate(group=[{1}], agg#0=[sum($10)])
HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
diff --git a/ql/src/test/results/clientpositive/llap/identity_project_remove_skip.q.out b/ql/src/test/results/clientpositive/llap/identity_project_remove_skip.q.out
index 082b244..1200e30 100644
--- a/ql/src/test/results/clientpositive/llap/identity_project_remove_skip.q.out
+++ b/ql/src/test/results/clientpositive/llap/identity_project_remove_skip.q.out
@@ -37,10 +37,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: src
- filterExpr: ((value = 'val_105') and (key = '105')) (type: boolean)
+ filterExpr: ((key = '105') and (value = 'val_105')) (type: boolean)
Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((value = 'val_105') and (key = '105')) (type: boolean)
+ predicate: ((key = '105') and (value = 'val_105')) (type: boolean)
Statistics: Num rows: 1 Data size: 178 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
diff --git a/ql/src/test/results/clientpositive/llap/lineage3.q.out b/ql/src/test/results/clientpositive/llap/lineage3.q.out
index b694bf1..a4f6e61 100644
--- a/ql/src/test/results/clientpositive/llap/lineage3.q.out
+++ b/ql/src/test/results/clientpositive/llap/lineage3.q.out
@@ -135,7 +135,7 @@ and x.ctinyint + length(c.cstring2) < 1000
PREHOOK: type: QUERY
PREHOOK: Input: default@alltypesorc
#### A masked pattern was here ####
-{"version":"1.0","engine":"tez","database":"default","hash":"15e00f9e88c1ad6b2f53a33a0c147f0e","queryText":"select x.ctinyint, x.cint, c.cbigint-100, c.cstring1\nfrom alltypesorc c\njoin (\n select a.ctinyint ctinyint, b.cint cint\n from (select * from alltypesorc a where cboolean1=false) a\n join alltypesorc b on (a.cint = b.cbigint - 224870380)\n ) x on (x.cint = c.cint)\nwhere x.ctinyint > 10\nand x.cint < 4.5\nand x.ctinyint + length(c.cstring2) < 1000","edges":[{"sources":[4], [...]
+{"version":"1.0","engine":"tez","database":"default","hash":"15e00f9e88c1ad6b2f53a33a0c147f0e","queryText":"select x.ctinyint, x.cint, c.cbigint-100, c.cstring1\nfrom alltypesorc c\njoin (\n select a.ctinyint ctinyint, b.cint cint\n from (select * from alltypesorc a where cboolean1=false) a\n join alltypesorc b on (a.cint = b.cbigint - 224870380)\n ) x on (x.cint = c.cint)\nwhere x.ctinyint > 10\nand x.cint < 4.5\nand x.ctinyint + length(c.cstring2) < 1000","edges":[{"sources":[4], [...]
11 -654374827 857266369 OEfPnHnIYueoup
PREHOOK: query: select c1, x2, x3
from (
diff --git a/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_3.q.out b/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_3.q.out
index 4fc442c..2d11b3f 100644
--- a/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_3.q.out
+++ b/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_3.q.out
@@ -533,10 +533,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: cmv_basetable_2
- filterExpr: ((c > 10) and (ROW__ID.writeid > 1L) and a is not null) (type: boolean)
+ filterExpr: ((ROW__ID.writeid > 1L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 3 Data size: 348 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((c > 10) and (ROW__ID.writeid > 1L) and a is not null) (type: boolean)
+ predicate: ((ROW__ID.writeid > 1L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 1 Data size: 116 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: a (type: int), c (type: decimal(10,2))
diff --git a/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_4.q.out b/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_4.q.out
index 41adbfa..13d7f5a 100644
--- a/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_4.q.out
+++ b/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_4.q.out
@@ -782,10 +782,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: cmv_basetable_2_n2
- filterExpr: ((c > 10) and (ROW__ID.writeid > 1L) and a is not null) (type: boolean)
+ filterExpr: ((ROW__ID.writeid > 1L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 3 Data size: 360 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((c > 10) and (ROW__ID.writeid > 1L) and a is not null) (type: boolean)
+ predicate: ((ROW__ID.writeid > 1L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 1 Data size: 120 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: a (type: int), c (type: decimal(10,2)), d (type: int)
@@ -1794,10 +1794,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: cmv_basetable_2_n2
- filterExpr: ((c > 10) and (ROW__ID.writeid > 4L) and a is not null) (type: boolean)
+ filterExpr: ((ROW__ID.writeid > 4L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 3 Data size: 360 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((c > 10) and (ROW__ID.writeid > 4L) and a is not null) (type: boolean)
+ predicate: ((ROW__ID.writeid > 4L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 1 Data size: 120 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: a (type: int), c (type: decimal(10,2)), d (type: int)
diff --git a/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_5.q.out b/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_5.q.out
index 68e9039..e2fff71 100644
--- a/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_5.q.out
+++ b/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_5.q.out
@@ -253,10 +253,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: cmv_basetable_2_n3
- filterExpr: ((c > 10) and (ROW__ID.writeid > 1L) and a is not null) (type: boolean)
+ filterExpr: ((ROW__ID.writeid > 1L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 3 Data size: 348 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((c > 10) and (ROW__ID.writeid > 1L) and a is not null) (type: boolean)
+ predicate: ((ROW__ID.writeid > 1L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 1 Data size: 116 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: a (type: int), c (type: decimal(10,2))
@@ -994,10 +994,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: cmv_basetable_2_n3
- filterExpr: ((c > 10) and (ROW__ID.writeid > 4L) and a is not null) (type: boolean)
+ filterExpr: ((ROW__ID.writeid > 4L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 3 Data size: 348 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((c > 10) and (ROW__ID.writeid > 4L) and a is not null) (type: boolean)
+ predicate: ((ROW__ID.writeid > 4L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 1 Data size: 116 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: a (type: int), c (type: decimal(10,2))
diff --git a/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_rebuild_dummy.q.out b/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_rebuild_dummy.q.out
index 0a62a60..0a106ba 100644
--- a/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_rebuild_dummy.q.out
+++ b/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_rebuild_dummy.q.out
@@ -533,10 +533,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: cmv_basetable_2_n0
- filterExpr: ((c > 10) and (ROW__ID.writeid > 1L) and a is not null) (type: boolean)
+ filterExpr: ((ROW__ID.writeid > 1L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 3 Data size: 348 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((c > 10) and (ROW__ID.writeid > 1L) and a is not null) (type: boolean)
+ predicate: ((ROW__ID.writeid > 1L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 1 Data size: 116 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: a (type: int), c (type: decimal(10,2))
diff --git a/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_time_window.q.out b/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_time_window.q.out
index 421088f..6cce2a4 100644
--- a/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_time_window.q.out
+++ b/ql/src/test/results/clientpositive/llap/materialized_view_create_rewrite_time_window.q.out
@@ -657,10 +657,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: cmv_basetable_2_n1
- filterExpr: ((c > 10) and (ROW__ID.writeid > 1L) and a is not null) (type: boolean)
+ filterExpr: ((ROW__ID.writeid > 1L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 3 Data size: 348 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((c > 10) and (ROW__ID.writeid > 1L) and a is not null) (type: boolean)
+ predicate: ((ROW__ID.writeid > 1L) and (c > 10) and a is not null) (type: boolean)
Statistics: Num rows: 1 Data size: 116 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: a (type: int), c (type: decimal(10,2))
diff --git a/ql/src/test/results/clientpositive/llap/orc_llap_counters.q.out b/ql/src/test/results/clientpositive/llap/orc_llap_counters.q.out
index a6aca8f..f8190af 100644
--- a/ql/src/test/results/clientpositive/llap/orc_llap_counters.q.out
+++ b/ql/src/test/results/clientpositive/llap/orc_llap_counters.q.out
@@ -111,15 +111,15 @@ POSTHOOK: query: insert into orc_ppd_staging_n0 select -10,-321,-65680,-42949674
POSTHOOK: type: QUERY
POSTHOOK: Input: default@staging_n6
POSTHOOK: Output: default@orc_ppd_staging_n0
-POSTHOOK: Lineage: orc_ppd_staging_n0.b EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging_n0.b SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n0.bin EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n0.bo SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n0.c EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n0.d EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n0.da EXPRESSION []
-POSTHOOK: Lineage: orc_ppd_staging_n0.dec EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging_n0.dec SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n0.f EXPRESSION []
-POSTHOOK: Lineage: orc_ppd_staging_n0.i EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging_n0.i SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n0.s SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n0.si EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n0.t EXPRESSION []
@@ -920,16 +920,16 @@ Stage-1 HIVE COUNTERS:
RECORDS_OUT_0: 1
RECORDS_OUT_INTERMEDIATE_Map_1: 0
RECORDS_OUT_INTERMEDIATE_Reducer_2: 0
- RECORDS_OUT_OPERATOR_FIL_8: 0
- RECORDS_OUT_OPERATOR_FS_12: 1
- RECORDS_OUT_OPERATOR_GBY_11: 1
+ RECORDS_OUT_OPERATOR_FIL_7: 0
+ RECORDS_OUT_OPERATOR_FS_9: 1
+ RECORDS_OUT_OPERATOR_GBY_8: 1
RECORDS_OUT_OPERATOR_MAP_0: 0
- RECORDS_OUT_OPERATOR_RS_10: 0
- RECORDS_OUT_OPERATOR_SEL_9: 0
+ RECORDS_OUT_OPERATOR_RS_3: 0
+ RECORDS_OUT_OPERATOR_SEL_2: 0
RECORDS_OUT_OPERATOR_TS_0: 2100
TOTAL_TABLE_ROWS_WRITTEN: 0
Stage-1 LLAP IO COUNTERS:
- CACHE_HIT_BYTES: 354
+ CACHE_HIT_BYTES: 1071
CACHE_MISS_BYTES: 0
METADATA_CACHE_HIT: 2
NUM_DECODED_BATCHES: 3
diff --git a/ql/src/test/results/clientpositive/llap/orc_llap_counters1.q.out b/ql/src/test/results/clientpositive/llap/orc_llap_counters1.q.out
index 53e18a5..d37aa3c 100644
--- a/ql/src/test/results/clientpositive/llap/orc_llap_counters1.q.out
+++ b/ql/src/test/results/clientpositive/llap/orc_llap_counters1.q.out
@@ -111,15 +111,15 @@ POSTHOOK: query: insert into orc_ppd_staging select -10,-321,-65680,-4294967430,
POSTHOOK: type: QUERY
POSTHOOK: Input: default@staging
POSTHOOK: Output: default@orc_ppd_staging
-POSTHOOK: Lineage: orc_ppd_staging.b EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging.b SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging.bin EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging.bo SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging.c EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging.d EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging.da EXPRESSION []
-POSTHOOK: Lineage: orc_ppd_staging.dec EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging.dec SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging.f EXPRESSION []
-POSTHOOK: Lineage: orc_ppd_staging.i EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging.i SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging.s SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging.si EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging.t EXPRESSION []
diff --git a/ql/src/test/results/clientpositive/llap/orc_ppd_basic.q.out b/ql/src/test/results/clientpositive/llap/orc_ppd_basic.q.out
index 1aa1203..adb1617 100644
--- a/ql/src/test/results/clientpositive/llap/orc_ppd_basic.q.out
+++ b/ql/src/test/results/clientpositive/llap/orc_ppd_basic.q.out
@@ -111,15 +111,15 @@ POSTHOOK: query: insert into orc_ppd_staging_n1 select -10,-321,-65680,-42949674
POSTHOOK: type: QUERY
POSTHOOK: Input: default@staging_n7
POSTHOOK: Output: default@orc_ppd_staging_n1
-POSTHOOK: Lineage: orc_ppd_staging_n1.b EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging_n1.b SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n1.bin EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n1.bo SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n1.c EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n1.d EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n1.da EXPRESSION []
-POSTHOOK: Lineage: orc_ppd_staging_n1.dec EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging_n1.dec SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n1.f EXPRESSION []
-POSTHOOK: Lineage: orc_ppd_staging_n1.i EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging_n1.i SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n1.s SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n1.si EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n1.t EXPRESSION []
@@ -881,7 +881,7 @@ Stage-1 HIVE COUNTERS:
RECORDS_OUT_OPERATOR_TS_0: 2100
TOTAL_TABLE_ROWS_WRITTEN: 0
Stage-1 LLAP IO COUNTERS:
- CACHE_HIT_BYTES: 354
+ CACHE_HIT_BYTES: 1071
CACHE_MISS_BYTES: 0
METADATA_CACHE_HIT: 2
NUM_DECODED_BATCHES: 3
diff --git a/ql/src/test/results/clientpositive/llap/orc_ppd_schema_evol_3a.q.out b/ql/src/test/results/clientpositive/llap/orc_ppd_schema_evol_3a.q.out
index b1679de..59ae15c 100644
--- a/ql/src/test/results/clientpositive/llap/orc_ppd_schema_evol_3a.q.out
+++ b/ql/src/test/results/clientpositive/llap/orc_ppd_schema_evol_3a.q.out
@@ -111,15 +111,15 @@ POSTHOOK: query: insert into orc_ppd_staging_n2 select -10,-321,-65680,-42949674
POSTHOOK: type: QUERY
POSTHOOK: Input: default@staging_n8
POSTHOOK: Output: default@orc_ppd_staging_n2
-POSTHOOK: Lineage: orc_ppd_staging_n2.b EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging_n2.b SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n2.bin EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n2.bo SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n2.c EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n2.d EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n2.da EXPRESSION []
-POSTHOOK: Lineage: orc_ppd_staging_n2.dec EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging_n2.dec SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n2.f EXPRESSION []
-POSTHOOK: Lineage: orc_ppd_staging_n2.i EXPRESSION []
+POSTHOOK: Lineage: orc_ppd_staging_n2.i SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n2.s SIMPLE []
POSTHOOK: Lineage: orc_ppd_staging_n2.si EXPRESSION []
POSTHOOK: Lineage: orc_ppd_staging_n2.t EXPRESSION []
diff --git a/ql/src/test/results/clientpositive/llap/orc_predicate_pushdown.q.out b/ql/src/test/results/clientpositive/llap/orc_predicate_pushdown.q.out
index 18f7092..7bfe64c 100644
--- a/ql/src/test/results/clientpositive/llap/orc_predicate_pushdown.q.out
+++ b/ql/src/test/results/clientpositive/llap/orc_predicate_pushdown.q.out
@@ -339,15 +339,15 @@ STAGE PLANS:
alias: orc_pred
Statistics: Num rows: 1049 Data size: 4188 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((t < 0Y) and (UDFToInteger(t) > -2)) (type: boolean)
- Statistics: Num rows: 8 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+ predicate: ((t < 0Y) and (t > -2Y)) (type: boolean)
+ Statistics: Num rows: 25 Data size: 100 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: hash(t) (type: int)
outputColumnNames: _col0
- Statistics: Num rows: 8 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 25 Data size: 100 Basic stats: COMPLETE Column stats: COMPLETE
Group By Operator
aggregations: sum(_col0)
- minReductionHashAggr: 0.875
+ minReductionHashAggr: 0.96
mode: hash
outputColumnNames: _col0
Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
@@ -410,18 +410,18 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: orc_pred
- filterExpr: ((t < 0Y) and (UDFToInteger(t) > -2)) (type: boolean)
+ filterExpr: ((t < 0Y) and (t > -2Y)) (type: boolean)
Statistics: Num rows: 1049 Data size: 4188 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: ((t < 0Y) and (UDFToInteger(t) > -2)) (type: boolean)
- Statistics: Num rows: 8 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+ predicate: ((t < 0Y) and (t > -2Y)) (type: boolean)
+ Statistics: Num rows: 25 Data size: 100 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: hash(t) (type: int)
outputColumnNames: _col0
- Statistics: Num rows: 8 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 25 Data size: 100 Basic stats: COMPLETE Column stats: COMPLETE
Group By Operator
aggregations: sum(_col0)
- minReductionHashAggr: 0.875
+ minReductionHashAggr: 0.96
mode: hash
outputColumnNames: _col0
Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
@@ -511,7 +511,7 @@ STAGE PLANS:
TableScan
alias: orc_pred
Filter Operator
- predicate: ((t IS NOT DISTINCT FROM -1) and s is not null and (s like 'bob%')) (type: boolean)
+ predicate: ((t IS NOT DISTINCT FROM -1Y) and s is not null and (s like 'bob%')) (type: boolean)
Select Operator
expressions: -1Y (type: tinyint), s (type: string)
outputColumnNames: _col0, _col1
@@ -541,9 +541,9 @@ STAGE PLANS:
Processor Tree:
TableScan
alias: orc_pred
- filterExpr: ((t IS NOT DISTINCT FROM -1) and s is not null and (s like 'bob%')) (type: boolean)
+ filterExpr: ((t IS NOT DISTINCT FROM -1Y) and s is not null and (s like 'bob%')) (type: boolean)
Filter Operator
- predicate: ((t IS NOT DISTINCT FROM -1) and s is not null and (s like 'bob%')) (type: boolean)
+ predicate: ((t IS NOT DISTINCT FROM -1Y) and s is not null and (s like 'bob%')) (type: boolean)
Select Operator
expressions: -1Y (type: tinyint), s (type: string)
outputColumnNames: _col0, _col1
@@ -627,7 +627,7 @@ STAGE PLANS:
alias: orc_pred
Statistics: Num rows: 1049 Data size: 105941 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (UDFToInteger(t) <> -1) and (UDFToInteger(t) <> -2) and (UDFToInteger(t) <> -3) and s is not null) (type: boolean)
+ predicate: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (t <> -1Y) and (t <> -2Y) and (t <> -3Y) and s is not null) (type: boolean)
Statistics: Num rows: 262 Data size: 26462 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: t (type: tinyint), s (type: string)
@@ -695,10 +695,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: orc_pred
- filterExpr: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (UDFToInteger(t) <> -1) and (UDFToInteger(t) <> -2) and (UDFToInteger(t) <> -3) and s is not null) (type: boolean)
+ filterExpr: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (t <> -1Y) and (t <> -2Y) and (t <> -3Y) and s is not null) (type: boolean)
Statistics: Num rows: 1049 Data size: 105941 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (UDFToInteger(t) <> -1) and (UDFToInteger(t) <> -2) and (UDFToInteger(t) <> -3) and s is not null) (type: boolean)
+ predicate: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (t <> -1Y) and (t <> -2Y) and (t <> -3Y) and s is not null) (type: boolean)
Statistics: Num rows: 262 Data size: 26462 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: t (type: tinyint), s (type: string)
diff --git a/ql/src/test/results/clientpositive/llap/parquet_predicate_pushdown.q.out b/ql/src/test/results/clientpositive/llap/parquet_predicate_pushdown.q.out
index da94fef..83da325 100644
--- a/ql/src/test/results/clientpositive/llap/parquet_predicate_pushdown.q.out
+++ b/ql/src/test/results/clientpositive/llap/parquet_predicate_pushdown.q.out
@@ -344,7 +344,7 @@ STAGE PLANS:
TableScan
alias: tbl_pred
Filter Operator
- predicate: ((t < 0Y) and (UDFToInteger(t) > -2)) (type: boolean)
+ predicate: ((t < 0Y) and (t > -2Y)) (type: boolean)
Select Operator
expressions: t (type: tinyint), si (type: smallint), i (type: int), b (type: bigint), f (type: float), d (type: double), bo (type: boolean), s (type: string), ts (type: timestamp), dec (type: decimal(4,2)), bin (type: binary)
outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10
@@ -378,9 +378,9 @@ STAGE PLANS:
Processor Tree:
TableScan
alias: tbl_pred
- filterExpr: ((t < 0Y) and (UDFToInteger(t) > -2)) (type: boolean)
+ filterExpr: ((t < 0Y) and (t > -2Y)) (type: boolean)
Filter Operator
- predicate: ((t < 0Y) and (UDFToInteger(t) > -2)) (type: boolean)
+ predicate: ((t < 0Y) and (t > -2Y)) (type: boolean)
Select Operator
expressions: t (type: tinyint), si (type: smallint), i (type: int), b (type: bigint), f (type: float), d (type: double), bo (type: boolean), s (type: string), ts (type: timestamp), dec (type: decimal(4,2)), bin (type: binary)
outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10
@@ -445,7 +445,7 @@ STAGE PLANS:
TableScan
alias: tbl_pred
Filter Operator
- predicate: ((t IS NOT DISTINCT FROM -1) and s is not null and (s like 'bob%')) (type: boolean)
+ predicate: ((t IS NOT DISTINCT FROM -1Y) and s is not null and (s like 'bob%')) (type: boolean)
Select Operator
expressions: -1Y (type: tinyint), s (type: string)
outputColumnNames: _col0, _col1
@@ -475,9 +475,9 @@ STAGE PLANS:
Processor Tree:
TableScan
alias: tbl_pred
- filterExpr: ((t IS NOT DISTINCT FROM -1) and s is not null and (s like 'bob%')) (type: boolean)
+ filterExpr: ((t IS NOT DISTINCT FROM -1Y) and s is not null and (s like 'bob%')) (type: boolean)
Filter Operator
- predicate: ((t IS NOT DISTINCT FROM -1) and s is not null and (s like 'bob%')) (type: boolean)
+ predicate: ((t IS NOT DISTINCT FROM -1Y) and s is not null and (s like 'bob%')) (type: boolean)
Select Operator
expressions: -1Y (type: tinyint), s (type: string)
outputColumnNames: _col0, _col1
@@ -561,7 +561,7 @@ STAGE PLANS:
alias: tbl_pred
Statistics: Num rows: 1049 Data size: 105941 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (UDFToInteger(t) <> -1) and (UDFToInteger(t) <> -2) and (UDFToInteger(t) <> -3) and s is not null) (type: boolean)
+ predicate: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (t <> -1Y) and (t <> -2Y) and (t <> -3Y) and s is not null) (type: boolean)
Statistics: Num rows: 262 Data size: 26462 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: t (type: tinyint), s (type: string)
@@ -629,10 +629,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: tbl_pred
- filterExpr: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (UDFToInteger(t) <> -1) and (UDFToInteger(t) <> -2) and (UDFToInteger(t) <> -3) and s is not null) (type: boolean)
+ filterExpr: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (t <> -1Y) and (t <> -2Y) and (t <> -3Y) and s is not null) (type: boolean)
Statistics: Num rows: 1049 Data size: 105941 Basic stats: COMPLETE Column stats: COMPLETE
Filter Operator
- predicate: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (UDFToInteger(t) <> -1) and (UDFToInteger(t) <> -2) and (UDFToInteger(t) <> -3) and s is not null) (type: boolean)
+ predicate: (UDFToInteger(t) BETWEEN 25 AND 30 and (s like 'bob%') and (t <> -1Y) and (t <> -2Y) and (t <> -3Y) and s is not null) (type: boolean)
Statistics: Num rows: 262 Data size: 26462 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: t (type: tinyint), s (type: string)
diff --git a/ql/src/test/results/clientpositive/llap/partition_coltype_literals.q.out b/ql/src/test/results/clientpositive/llap/partition_coltype_literals.q.out
index 13f4e78..5023927 100644
--- a/ql/src/test/results/clientpositive/llap/partition_coltype_literals.q.out
+++ b/ql/src/test/results/clientpositive/llap/partition_coltype_literals.q.out
@@ -235,6 +235,7 @@ POSTHOOK: Input: default@partcoltypenum
POSTHOOK: Input: default@partcoltypenum@tint=110/sint=22000/bint=330000000000
#### A masked pattern was here ####
30
+WARNING: Comparing a bigint and a string may result in a loss of precision.
PREHOOK: query: select count(1) from partcoltypenum where tint=110Y and sint=22000 and bint='330000000000'
PREHOOK: type: QUERY
PREHOOK: Input: default@partcoltypenum
diff --git a/ql/src/test/results/clientpositive/llap/subquery_ALL.q.out b/ql/src/test/results/clientpositive/llap/subquery_ALL.q.out
index 773ed80..d05e7c7 100644
--- a/ql/src/test/results/clientpositive/llap/subquery_ALL.q.out
+++ b/ql/src/test/results/clientpositive/llap/subquery_ALL.q.out
@@ -367,7 +367,7 @@ POSTHOOK: type: QUERY
POSTHOOK: Input: default@part
#### A masked pattern was here ####
0
-Warning: Shuffle Join MERGEJOIN[23][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 2' is a cross product
+Warning: Shuffle Join MERGEJOIN[22][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 2' is a cross product
PREHOOK: query: select count(*) from part where p_size < ALL (select max(null) from part group by p_partkey)
PREHOOK: type: QUERY
PREHOOK: Input: default@part
diff --git a/ql/src/test/results/clientpositive/llap/subquery_ANY.q.out b/ql/src/test/results/clientpositive/llap/subquery_ANY.q.out
index 96ca2d9..8fa69c5 100644
--- a/ql/src/test/results/clientpositive/llap/subquery_ANY.q.out
+++ b/ql/src/test/results/clientpositive/llap/subquery_ANY.q.out
@@ -276,7 +276,7 @@ POSTHOOK: type: QUERY
POSTHOOK: Input: default@part
#### A masked pattern was here ####
25
-Warning: Shuffle Join MERGEJOIN[23][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 2' is a cross product
+Warning: Shuffle Join MERGEJOIN[22][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 2' is a cross product
PREHOOK: query: select count(*) from part where p_size < ANY (select max(null) from part group by p_partkey)
PREHOOK: type: QUERY
PREHOOK: Input: default@part
diff --git a/ql/src/test/results/clientpositive/llap/union_assertion_type.q.out b/ql/src/test/results/clientpositive/llap/union_assertion_type.q.out
index 4c9e94e..b1b5ddc 100644
--- a/ql/src/test/results/clientpositive/llap/union_assertion_type.q.out
+++ b/ql/src/test/results/clientpositive/llap/union_assertion_type.q.out
@@ -142,10 +142,10 @@ STAGE PLANS:
Select Operator
expressions: _col0 (type: string), _col1 (type: string), '5' (type: string)
outputColumnNames: _col0, _col1, _col2
- Statistics: Num rows: 1 Data size: 255 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 2 Data size: 510 Basic stats: COMPLETE Column stats: COMPLETE
File Output Operator
compressed: false
- Statistics: Num rows: 1 Data size: 255 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 2 Data size: 510 Basic stats: COMPLETE Column stats: COMPLETE
table:
input format: org.apache.hadoop.mapred.SequenceFileInputFormat
output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
@@ -167,10 +167,10 @@ STAGE PLANS:
Select Operator
expressions: _col0 (type: string), _col1 (type: string), '5' (type: string)
outputColumnNames: _col0, _col1, _col2
- Statistics: Num rows: 1 Data size: 255 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 2 Data size: 510 Basic stats: COMPLETE Column stats: COMPLETE
File Output Operator
compressed: false
- Statistics: Num rows: 1 Data size: 255 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 2 Data size: 510 Basic stats: COMPLETE Column stats: COMPLETE
table:
input format: org.apache.hadoop.mapred.SequenceFileInputFormat
output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
diff --git a/ql/src/test/results/clientpositive/llap/vector_between_in.q.out b/ql/src/test/results/clientpositive/llap/vector_between_in.q.out
index b8d480a..406096a 100644
--- a/ql/src/test/results/clientpositive/llap/vector_between_in.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_between_in.q.out
@@ -269,7 +269,7 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: decimal_date_test
- filterExpr: (cdecimal1) IN (2365.8945945946, 881.0135135135, -3367.6517567568) (type: boolean)
+ filterExpr: ((cdecimal1) IN (2365.8945945946, -3367.6517567568) or (cdecimal1) IN (881.0135135135)) (type: boolean)
Statistics: Num rows: 12289 Data size: 1027600 Basic stats: COMPLETE Column stats: COMPLETE
TableScan Vectorization:
native: true
@@ -277,8 +277,8 @@ STAGE PLANS:
Filter Vectorization:
className: VectorFilterOperator
native: true
- predicateExpression: FilterDecimalColumnInList(col 1:decimal(20,10), values [2365.8945945946, 881.0135135135, -3367.6517567568])
- predicate: (cdecimal1) IN (2365.8945945946, 881.0135135135, -3367.6517567568) (type: boolean)
+ predicateExpression: FilterExprOrExpr(children: FilterDecimalColumnInList(col 1:decimal(20,10), values [2365.8945945946, -3367.6517567568]), FilterDecimalColumnInList(col 1:decimal(20,10), values [881.0135135135]))
+ predicate: ((cdecimal1) IN (2365.8945945946, -3367.6517567568) or (cdecimal1) IN (881.0135135135)) (type: boolean)
Statistics: Num rows: 6 Data size: 560 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: cdecimal1 (type: decimal(20,10))
@@ -1300,13 +1300,13 @@ STAGE PLANS:
TableScan Vectorization:
native: true
Select Operator
- expressions: (cdecimal1) IN (2365.8945945946, 881.0135135135, -3367.6517567568) (type: boolean)
+ expressions: ((cdecimal1) IN (2365.8945945946, -3367.6517567568) or (cdecimal1) IN (881.0135135135)) (type: boolean)
outputColumnNames: _col0
Select Vectorization:
className: VectorSelectOperator
native: true
- projectedOutputColumnNums: [5]
- selectExpressions: DecimalColumnInList(col 1:decimal(20,10), values [2365.8945945946, 881.0135135135, -3367.6517567568]) -> 5:boolean
+ projectedOutputColumnNums: [7]
+ selectExpressions: ColOrCol(col 5:boolean, col 6:boolean)(children: DecimalColumnInList(col 1:decimal(20,10), values [2365.8945945946, -3367.6517567568]) -> 5:boolean, DecimalColumnInList(col 1:decimal(20,10), values [881.0135135135]) -> 6:boolean) -> 7:boolean
Statistics: Num rows: 12289 Data size: 1027600 Basic stats: COMPLETE Column stats: COMPLETE
Group By Operator
aggregations: count()
@@ -1314,15 +1314,15 @@ STAGE PLANS:
aggregators: VectorUDAFCountStar(*) -> bigint
className: VectorGroupByOperator
groupByMode: HASH
- keyExpressions: col 5:boolean
+ keyExpressions: col 7:boolean
native: false
vectorProcessingMode: HASH
projectedOutputColumnNums: [0]
keys: _col0 (type: boolean)
- minReductionHashAggr: 0.52225566
+ minReductionHashAggr: 0.99
mode: hash
outputColumnNames: _col0, _col1
- Statistics: Num rows: 5871 Data size: 70452 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 2 Data size: 24 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: _col0 (type: boolean)
null sort order: z
@@ -1332,7 +1332,7 @@ STAGE PLANS:
className: VectorReduceSinkLongOperator
native: true
nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
- Statistics: Num rows: 5871 Data size: 70452 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 2 Data size: 24 Basic stats: COMPLETE Column stats: COMPLETE
value expressions: _col1 (type: bigint)
Execution mode: vectorized, llap
LLAP IO: all inputs
@@ -1367,7 +1367,7 @@ STAGE PLANS:
keys: KEY._col0 (type: boolean)
mode: mergepartial
outputColumnNames: _col0, _col1
- Statistics: Num rows: 5871 Data size: 70452 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 2 Data size: 24 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: _col0 (type: boolean)
null sort order: z
@@ -1376,7 +1376,7 @@ STAGE PLANS:
className: VectorReduceSinkObjectHashOperator
native: true
nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
- Statistics: Num rows: 5871 Data size: 70452 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 2 Data size: 24 Basic stats: COMPLETE Column stats: COMPLETE
value expressions: _col1 (type: bigint)
Reducer 3
Execution mode: vectorized, llap
@@ -1394,13 +1394,13 @@ STAGE PLANS:
className: VectorSelectOperator
native: true
projectedOutputColumnNums: [0, 1]
- Statistics: Num rows: 5871 Data size: 70452 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 2 Data size: 24 Basic stats: COMPLETE Column stats: COMPLETE
File Output Operator
compressed: false
File Sink Vectorization:
className: VectorFileSinkOperator
native: false
- Statistics: Num rows: 5871 Data size: 70452 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 2 Data size: 24 Basic stats: COMPLETE Column stats: COMPLETE
table:
input format: org.apache.hadoop.mapred.SequenceFileInputFormat
output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
diff --git a/ql/src/test/results/clientpositive/llap/vector_case_when_2.q.out b/ql/src/test/results/clientpositive/llap/vector_case_when_2.q.out
index 9b91278..7980a30 100644
--- a/ql/src/test/results/clientpositive/llap/vector_case_when_2.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_case_when_2.q.out
@@ -1131,13 +1131,13 @@ STAGE PLANS:
keyExpressions: col 0:int
native: true
Select Operator
- expressions: q548284 (type: int), CASE WHEN ((q548284 = 4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (8) END (type: decimal(2,1))
+ expressions: q548284 (type: int), CAST( CASE WHEN ((q548284 = 4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (8) END AS decimal(11,1)) (type: decimal(11,1))
outputColumnNames: _col0, _col1
Select Vectorization:
className: VectorSelectOperator
native: true
- projectedOutputColumnNums: [0, 8]
- selectExpressions: IfExprCondExprCondExpr(col 2:boolean, col 3:decimal(2,1)col 7:decimal(2,1))(children: LongColEqualLongScalar(col 0:int, val 4) -> 2:boolean, ConstantVectorExpression(val 0.8) -> 3:decimal(2,1), IfExprCondExprCondExpr(col 4:boolean, col 5:decimal(2,1)col 6:decimal(2,1))(children: LongColEqualLongScalar(col 0:int, val 5) -> 4:boolean, ConstantVectorExpression(val 1) -> 5:decimal(2,1), ConstantVectorExpression(val 8) -> 6:decimal(2,1)) -> 7:decim [...]
+ projectedOutputColumnNums: [0, 9]
+ selectExpressions: CastDecimalToDecimal(col 8:decimal(2,1))(children: IfExprCondExprCondExpr(col 2:boolean, col 3:decimal(2,1)col 7:decimal(2,1))(children: LongColEqualLongScalar(col 0:int, val 4) -> 2:boolean, ConstantVectorExpression(val 0.8) -> 3:decimal(2,1), IfExprCondExprCondExpr(col 4:boolean, col 5:decimal(2,1)col 6:decimal(2,1))(children: LongColEqualLongScalar(col 0:int, val 5) -> 4:boolean, ConstantVectorExpression(val 1) -> 5:decimal(2,1), ConstantVe [...]
Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
Reduce Output Operator
key expressions: _col0 (type: int)
@@ -1148,10 +1148,10 @@ STAGE PLANS:
keyColumns: 0:int
native: true
nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
- valueColumns: 8:decimal(2,1)
+ valueColumns: 9:decimal(11,1)
Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
TopN Hash Memory Usage: 0.1
- value expressions: _col1 (type: decimal(2,1))
+ value expressions: _col1 (type: decimal(11,1))
Execution mode: vectorized, llap
LLAP IO: no inputs
Map Vectorization:
@@ -1168,7 +1168,7 @@ STAGE PLANS:
includeColumns: [0]
dataColumns: q548284:int
partitionColumnCount: 0
- scratchColumnTypeNames: [bigint, decimal(2,1), bigint, decimal(2,1), decimal(2,1), decimal(2,1), decimal(2,1)]
+ scratchColumnTypeNames: [bigint, decimal(2,1), bigint, decimal(2,1), decimal(2,1), decimal(2,1), decimal(2,1), decimal(11,1)]
Reducer 2
Execution mode: vectorized, llap
Reduce Vectorization:
@@ -1181,12 +1181,12 @@ STAGE PLANS:
vectorized: true
rowBatchContext:
dataColumnCount: 2
- dataColumns: KEY.reducesinkkey0:int, VALUE._col0:decimal(2,1)/DECIMAL_64
+ dataColumns: KEY.reducesinkkey0:int, VALUE._col0:decimal(11,1)/DECIMAL_64
partitionColumnCount: 0
scratchColumnTypeNames: []
Reduce Operator Tree:
Select Operator
- expressions: KEY.reducesinkkey0 (type: int), VALUE._col0 (type: decimal(2,1))
+ expressions: KEY.reducesinkkey0 (type: int), VALUE._col0 (type: decimal(11,1))
outputColumnNames: _col0, _col1
Select Vectorization:
className: VectorSelectOperator
diff --git a/ql/src/test/results/clientpositive/llap/vectorization_10.q.out b/ql/src/test/results/clientpositive/llap/vectorization_10.q.out
index 03e277a..c1c79c2 100644
--- a/ql/src/test/results/clientpositive/llap/vectorization_10.q.out
+++ b/ql/src/test/results/clientpositive/llap/vectorization_10.q.out
@@ -67,7 +67,7 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: alltypesorc
- filterExpr: ((cstring2 <= '10') or ((UDFToDouble(ctinyint) > cdouble) and (CAST( ctinyint AS decimal(6,2)) <= -5638.15)) or ((cdouble > 6981.0D) and ((CAST( csmallint AS decimal(11,4)) = 9763215.5639) or (cstring1 like '%a')))) (type: boolean)
+ filterExpr: ((cstring2 <= '10') or ((UDFToDouble(ctinyint) > cdouble) and (CAST( ctinyint AS decimal(6,2)) <= -5638.15)) or ((cdouble > 6981.0D) and (cstring1 like '%a'))) (type: boolean)
Statistics: Num rows: 12288 Data size: 2367002 Basic stats: COMPLETE Column stats: COMPLETE
TableScan Vectorization:
native: true
@@ -76,24 +76,24 @@ STAGE PLANS:
Filter Vectorization:
className: VectorFilterOperator
native: true
- predicateExpression: FilterExprOrExpr(children: FilterStringGroupColLessEqualStringScalar(col 7:string, val 10), FilterExprAndExpr(children: FilterDoubleColGreaterDoubleColumn(col 13:double, col 5:double)(children: CastLongToDouble(col 0:tinyint) -> 13:double), FilterDecimal64ColLessEqualDecimal64Scalar(col 14:decimal(6,2)/DECIMAL_64, val -563815)(children: CastLongToDecimal64(col 0:tinyint) -> 14:decimal(6,2)/DECIMAL_64)), FilterExprAndExpr(children: FilterDouble [...]
- predicate: ((cstring2 <= '10') or ((UDFToDouble(ctinyint) > cdouble) and (CAST( ctinyint AS decimal(6,2)) <= -5638.15)) or ((cdouble > 6981.0D) and ((CAST( csmallint AS decimal(11,4)) = 9763215.5639) or (cstring1 like '%a')))) (type: boolean)
- Statistics: Num rows: 12288 Data size: 2367002 Basic stats: COMPLETE Column stats: COMPLETE
+ predicateExpression: FilterExprOrExpr(children: FilterStringGroupColLessEqualStringScalar(col 7:string, val 10), FilterExprAndExpr(children: FilterDoubleColGreaterDoubleColumn(col 13:double, col 5:double)(children: CastLongToDouble(col 0:tinyint) -> 13:double), FilterDecimal64ColLessEqualDecimal64Scalar(col 14:decimal(6,2)/DECIMAL_64, val -563815)(children: CastLongToDecimal64(col 0:tinyint) -> 14:decimal(6,2)/DECIMAL_64)), FilterExprAndExpr(children: FilterDouble [...]
+ predicate: ((cstring2 <= '10') or ((UDFToDouble(ctinyint) > cdouble) and (CAST( ctinyint AS decimal(6,2)) <= -5638.15)) or ((cdouble > 6981.0D) and (cstring1 like '%a'))) (type: boolean)
+ Statistics: Num rows: 11590 Data size: 2232584 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: cdouble (type: double), ctimestamp1 (type: timestamp), ctinyint (type: tinyint), cboolean1 (type: boolean), cstring1 (type: string), (- cdouble) (type: double), (cdouble + UDFToDouble(csmallint)) (type: double), ((cdouble + UDFToDouble(csmallint)) % 33.0D) (type: double), (- cdouble) (type: double), (UDFToDouble(ctinyint) % cdouble) (type: double), (UDFToShort(ctinyint) % csmallint) (type: smallint), (- cdouble) (type: double), (cbigint * UDFToLong((UDF [...]
outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14
Select Vectorization:
className: VectorSelectOperator
native: true
- projectedOutputColumnNums: [5, 8, 0, 10, 6, 16, 18, 21, 22, 24, 25, 26, 28, 31, 33]
- selectExpressions: DoubleColUnaryMinus(col 5:double) -> 16:double, DoubleColAddDoubleColumn(col 5:double, col 17:double)(children: CastLongToDouble(col 1:smallint) -> 17:double) -> 18:double, DoubleColModuloDoubleScalar(col 20:double, val 33.0)(children: DoubleColAddDoubleColumn(col 5:double, col 19:double)(children: CastLongToDouble(col 1:smallint) -> 19:double) -> 20:double) -> 21:double, DoubleColUnaryMinus(col 5:double) -> 22:double, DoubleColModuloDoubleCol [...]
- Statistics: Num rows: 12288 Data size: 2310094 Basic stats: COMPLETE Column stats: COMPLETE
+ projectedOutputColumnNums: [5, 8, 0, 10, 6, 15, 17, 20, 21, 23, 24, 25, 27, 30, 32]
+ selectExpressions: DoubleColUnaryMinus(col 5:double) -> 15:double, DoubleColAddDoubleColumn(col 5:double, col 16:double)(children: CastLongToDouble(col 1:smallint) -> 16:double) -> 17:double, DoubleColModuloDoubleScalar(col 19:double, val 33.0)(children: DoubleColAddDoubleColumn(col 5:double, col 18:double)(children: CastLongToDouble(col 1:smallint) -> 18:double) -> 19:double) -> 20:double, DoubleColUnaryMinus(col 5:double) -> 21:double, DoubleColModuloDoubleCol [...]
+ Statistics: Num rows: 11590 Data size: 2178896 Basic stats: COMPLETE Column stats: COMPLETE
File Output Operator
compressed: false
File Sink Vectorization:
className: VectorFileSinkOperator
native: false
- Statistics: Num rows: 12288 Data size: 2310094 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 11590 Data size: 2178896 Basic stats: COMPLETE Column stats: COMPLETE
table:
input format: org.apache.hadoop.mapred.SequenceFileInputFormat
output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
@@ -114,7 +114,7 @@ STAGE PLANS:
includeColumns: [0, 1, 3, 5, 6, 7, 8, 10]
dataColumns: ctinyint:tinyint, csmallint:smallint, cint:int, cbigint:bigint, cfloat:float, cdouble:double, cstring1:string, cstring2:string, ctimestamp1:timestamp, ctimestamp2:timestamp, cboolean1:boolean, cboolean2:boolean
partitionColumnCount: 0
- scratchColumnTypeNames: [double, decimal(6,2)/DECIMAL_64, decimal(11,4)/DECIMAL_64, double, double, double, double, double, double, double, double, double, bigint, double, bigint, bigint, double, double, double, double, double]
+ scratchColumnTypeNames: [double, decimal(6,2)/DECIMAL_64, double, double, double, double, double, double, double, double, double, bigint, double, bigint, bigint, double, double, double, double, double]
Stage: Stage-0
Fetch Operator
diff --git a/ql/src/test/results/clientpositive/llap/vectorization_short_regress.q.out b/ql/src/test/results/clientpositive/llap/vectorization_short_regress.q.out
index 02c9d66..74d209d 100644
--- a/ql/src/test/results/clientpositive/llap/vectorization_short_regress.q.out
+++ b/ql/src/test/results/clientpositive/llap/vectorization_short_regress.q.out
@@ -1114,7 +1114,7 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: alltypesorc
- filterExpr: (((cboolean2 <> 1) and (CAST( csmallint AS decimal(8,3)) < 79.553) and (UDFToInteger(ctinyint) <> -257)) or ((cdouble > UDFToDouble(ctinyint)) and (cfloat >= UDFToFloat(cint))) or ((UDFToLong(cint) < cbigint) and (UDFToLong(ctinyint) > cbigint)) or (cstring1 regexp 'a.*' and (cstring2 like '%ss%'))) (type: boolean)
+ filterExpr: (((cdouble > UDFToDouble(ctinyint)) and (cfloat >= UDFToFloat(cint))) or ((cboolean2 <> 1) and (CAST( csmallint AS decimal(8,3)) < 79.553) and (UDFToInteger(ctinyint) <> -257)) or ((UDFToLong(cint) < cbigint) and (UDFToLong(ctinyint) > cbigint)) or (cstring1 regexp 'a.*' and (cstring2 like '%ss%'))) (type: boolean)
Statistics: Num rows: 12288 Data size: 2807390 Basic stats: COMPLETE Column stats: COMPLETE
TableScan Vectorization:
native: true
@@ -1122,8 +1122,8 @@ STAGE PLANS:
Filter Vectorization:
className: VectorFilterOperator
native: true
- predicateExpression: FilterExprOrExpr(children: FilterExprAndExpr(children: FilterLongColNotEqualLongScalar(col 11:boolean, val 1), FilterDecimal64ColLessDecimal64Scalar(col 13:decimal(8,3)/DECIMAL_64, val 79553)(children: CastLongToDecimal64(col 1:smallint) -> 13:decimal(8,3)/DECIMAL_64), FilterLongColNotEqualLongScalar(col 0:int, val -257)(children: col 0:tinyint)), FilterExprAndExpr(children: FilterDoubleColGreaterDoubleColumn(col 5:double, col 14:double)(child [...]
- predicate: (((cboolean2 <> 1) and (CAST( csmallint AS decimal(8,3)) < 79.553) and (UDFToInteger(ctinyint) <> -257)) or ((cdouble > UDFToDouble(ctinyint)) and (cfloat >= UDFToFloat(cint))) or ((UDFToLong(cint) < cbigint) and (UDFToLong(ctinyint) > cbigint)) or (cstring1 regexp 'a.*' and (cstring2 like '%ss%'))) (type: boolean)
+ predicateExpression: FilterExprOrExpr(children: FilterExprAndExpr(children: FilterDoubleColGreaterDoubleColumn(col 5:double, col 13:double)(children: CastLongToDouble(col 0:tinyint) -> 13:double), FilterDoubleColGreaterEqualDoubleColumn(col 4:float, col 14:float)(children: CastLongToFloatViaLongToDouble(col 2:int) -> 14:float)), FilterExprAndExpr(children: FilterLongColNotEqualLongScalar(col 11:boolean, val 1), FilterDecimal64ColLessDecimal64Scalar(col 15:decimal( [...]
+ predicate: (((cdouble > UDFToDouble(ctinyint)) and (cfloat >= UDFToFloat(cint))) or ((cboolean2 <> 1) and (CAST( csmallint AS decimal(8,3)) < 79.553) and (UDFToInteger(ctinyint) <> -257)) or ((UDFToLong(cint) < cbigint) and (UDFToLong(ctinyint) > cbigint)) or (cstring1 regexp 'a.*' and (cstring2 like '%ss%'))) (type: boolean)
Statistics: Num rows: 9898 Data size: 2261486 Basic stats: COMPLETE Column stats: COMPLETE
Top N Key Operator
sort order: +++++++++++++++++++++++
@@ -1141,8 +1141,8 @@ STAGE PLANS:
Select Vectorization:
className: VectorSelectOperator
native: true
- projectedOutputColumnNums: [2, 5, 9, 6, 11, 0, 4, 8, 1, 3, 21, 23, 33, 24, 42, 44, 27, 47, 14, 15, 37, 25, 48]
- selectExpressions: LongScalarMultiplyLongColumn(val -3728, col 3:bigint) -> 21:bigint, LongColUnaryMinus(col 2:int) -> 23:int, DecimalScalarSubtractDecimalColumn(val -863.257, col 18:decimal(10,0))(children: CastLongToDecimal(col 2:int) -> 18:decimal(10,0)) -> 33:decimal(14,3), LongColUnaryMinus(col 1:smallint) -> 24:smallint, LongColSubtractLongColumn(col 1:smallint, col 25:smallint)(children: LongColUnaryMinus(col 1:smallint) -> 25:smallint) -> 42:smallint, [...]
+ projectedOutputColumnNums: [2, 5, 9, 6, 11, 0, 4, 8, 1, 3, 21, 23, 33, 24, 42, 44, 27, 47, 13, 14, 37, 25, 48]
+ selectExpressions: LongScalarMultiplyLongColumn(val -3728, col 3:bigint) -> 21:bigint, LongColUnaryMinus(col 2:int) -> 23:int, DecimalScalarSubtractDecimalColumn(val -863.257, col 18:decimal(10,0))(children: CastLongToDecimal(col 2:int) -> 18:decimal(10,0)) -> 33:decimal(14,3), LongColUnaryMinus(col 1:smallint) -> 24:smallint, LongColSubtractLongColumn(col 1:smallint, col 25:smallint)(children: LongColUnaryMinus(col 1:smallint) -> 25:smallint) -> 42:smallint, [...]
Statistics: Num rows: 9898 Data size: 4905318 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: _col0 (type: int), _col1 (type: double), _col2 (type: timestamp), _col3 (type: string), _col4 (type: boolean), _col5 (type: tinyint), _col6 (type: float), _col7 (type: timestamp), _col8 (type: smallint), _col9 (type: bigint), _col10 (type: bigint), _col11 (type: int), _col12 (type: decimal(14,3)), _col13 (type: smallint), _col14 (type: smallint), _col15 (type: smallint), _col16 (type: double), _col17 (type: decimal(15,3)), _col18 (type: float), [...]
@@ -1689,7 +1689,7 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: alltypesorc
- filterExpr: (((UDFToFloat(cbigint) <= cfloat) and (CAST( csmallint AS decimal(7,2)) >= -26.28)) or ((cdouble <= UDFToDouble(cbigint)) and (cstring1 >= 'ss') and (UDFToDouble(cint) <> cdouble)) or (UDFToInteger(ctinyint) = -89010) or ((CAST( csmallint AS decimal(7,2)) > -26.28) and (cstring2 like 'ss'))) (type: boolean)
+ filterExpr: (((UDFToFloat(cbigint) <= cfloat) and (CAST( csmallint AS decimal(7,2)) >= -26.28)) or ((cdouble <= UDFToDouble(cbigint)) and (cstring1 >= 'ss') and (UDFToDouble(cint) <> cdouble)) or ((CAST( csmallint AS decimal(7,2)) > -26.28) and (cstring2 like 'ss'))) (type: boolean)
Statistics: Num rows: 12288 Data size: 2477130 Basic stats: COMPLETE Column stats: COMPLETE
TableScan Vectorization:
native: true
@@ -1697,14 +1697,14 @@ STAGE PLANS:
Filter Vectorization:
className: VectorFilterOperator
native: true
- predicateExpression: FilterExprOrExpr(children: FilterExprAndExpr(children: FilterDoubleColLessEqualDoubleColumn(col 13:float, col 4:float)(children: CastLongToFloatViaLongToDouble(col 3:bigint) -> 13:float), FilterDecimal64ColGreaterEqualDecimal64Scalar(col 14:decimal(7,2)/DECIMAL_64, val -2628)(children: CastLongToDecimal64(col 1:smallint) -> 14:decimal(7,2)/DECIMAL_64)), FilterExprAndExpr(children: FilterDoubleColLessEqualDoubleColumn(col 5:double, col 15:doubl [...]
- predicate: (((UDFToFloat(cbigint) <= cfloat) and (CAST( csmallint AS decimal(7,2)) >= -26.28)) or ((cdouble <= UDFToDouble(cbigint)) and (cstring1 >= 'ss') and (UDFToDouble(cint) <> cdouble)) or (UDFToInteger(ctinyint) = -89010) or ((CAST( csmallint AS decimal(7,2)) > -26.28) and (cstring2 like 'ss'))) (type: boolean)
- Statistics: Num rows: 10922 Data size: 2201730 Basic stats: COMPLETE Column stats: COMPLETE
+ predicateExpression: FilterExprOrExpr(children: FilterExprAndExpr(children: FilterDoubleColLessEqualDoubleColumn(col 13:float, col 4:float)(children: CastLongToFloatViaLongToDouble(col 3:bigint) -> 13:float), FilterDecimal64ColGreaterEqualDecimal64Scalar(col 14:decimal(7,2)/DECIMAL_64, val -2628)(children: CastLongToDecimal64(col 1:smallint) -> 14:decimal(7,2)/DECIMAL_64)), FilterExprAndExpr(children: FilterDoubleColLessEqualDoubleColumn(col 5:double, col 15:doubl [...]
+ predicate: (((UDFToFloat(cbigint) <= cfloat) and (CAST( csmallint AS decimal(7,2)) >= -26.28)) or ((cdouble <= UDFToDouble(cbigint)) and (cstring1 >= 'ss') and (UDFToDouble(cint) <> cdouble)) or ((CAST( csmallint AS decimal(7,2)) > -26.28) and (cstring2 like 'ss'))) (type: boolean)
+ Statistics: Num rows: 4778 Data size: 963360 Basic stats: COMPLETE Column stats: COMPLETE
Top N Key Operator
sort order: +++++++++++++++++++++
keys: cboolean1 (type: boolean), cstring1 (type: string), ctimestamp2 (type: timestamp), cfloat (type: float), cbigint (type: bigint), cdouble (type: double), cint (type: int), csmallint (type: smallint), (cint + UDFToInteger(csmallint)) (type: int), (cbigint - UDFToLong(ctinyint)) (type: bigint), (- cbigint) (type: bigint), (- cfloat) (type: float), ((cbigint - UDFToLong(ctinyint)) + cbigint) (type: bigint), (cdouble / cdouble) (type: double), (- cdouble) (type: do [...]
null sort order: zzzzzzzzzzzzzzzzzzzzz
- Statistics: Num rows: 10922 Data size: 2201730 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 4778 Data size: 963360 Basic stats: COMPLETE Column stats: COMPLETE
top n: 75
Top N Key Vectorization:
className: VectorTopNKeyOperator
@@ -1718,7 +1718,7 @@ STAGE PLANS:
native: true
projectedOutputColumnNums: [2, 6, 11, 9, 5, 4, 3, 1, 10, 22, 26, 27, 13, 39, 15, 16, 41, 34, 42, 30, 37, 44]
selectExpressions: LongColAddLongColumn(col 2:int, col 1:int)(children: col 1:smallint) -> 22:int, LongColSubtractLongColumn(col 3:bigint, col 0:bigint)(children: col 0:tinyint) -> 26:bigint, LongColUnaryMinus(col 3:bigint) -> 27:bigint, DoubleColUnaryMinus(col 4:float) -> 13:float, LongColAddLongColumn(col 37:bigint, col 3:bigint)(children: LongColSubtractLongColumn(col 3:bigint, col 0:bigint)(children: col 0:tinyint) -> 37:bigint) -> 39:bigint, DoubleColDivi [...]
- Statistics: Num rows: 10922 Data size: 3012774 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 4778 Data size: 1318066 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: _col8 (type: boolean), _col1 (type: string), _col3 (type: timestamp), _col5 (type: float), _col6 (type: bigint), _col4 (type: double), _col0 (type: int), _col7 (type: smallint), _col9 (type: int), _col10 (type: bigint), _col11 (type: bigint), _col12 (type: float), _col13 (type: bigint), _col14 (type: double), _col15 (type: double), _col16 (type: bigint), _col17 (type: double), _col18 (type: decimal(8,7)), _col19 (type: double), _col20 (type: sma [...]
null sort order: zzzzzzzzzzzzzzzzzzzzz
@@ -1727,7 +1727,7 @@ STAGE PLANS:
className: VectorReduceSinkObjectHashOperator
native: true
nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
- Statistics: Num rows: 10922 Data size: 3012774 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 4778 Data size: 1318066 Basic stats: COMPLETE Column stats: COMPLETE
TopN Hash Memory Usage: 0.1
value expressions: _col2 (type: boolean)
Execution mode: vectorized, llap
@@ -1757,7 +1757,7 @@ STAGE PLANS:
className: VectorSelectOperator
native: true
projectedOutputColumnNums: [6, 1, 21, 2, 5, 3, 4, 7, 0, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
- Statistics: Num rows: 10922 Data size: 3012774 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 4778 Data size: 1318066 Basic stats: COMPLETE Column stats: COMPLETE
Limit
Number of rows: 75
Limit Vectorization:
@@ -2009,7 +2009,7 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: alltypesorc
- filterExpr: (((cdouble >= UDFToDouble(cfloat)) and (cstring2 <= 'a')) or ((CAST( cint AS decimal(13,3)) <= -1.389) and (csmallint < UDFToShort(ctinyint)) and (UDFToInteger(csmallint) < -6432)) or ((cstring1 like 'ss%') and (CAST( cbigint AS decimal(22,3)) < 10.175))) (type: boolean)
+ filterExpr: (((cdouble >= UDFToDouble(cfloat)) and (cstring2 <= 'a')) or ((CAST( cint AS decimal(13,3)) <= -1.389) and (csmallint < UDFToShort(ctinyint)) and (csmallint < -6432S)) or ((cstring1 like 'ss%') and (CAST( cbigint AS decimal(22,3)) < 10.175))) (type: boolean)
Statistics: Num rows: 12288 Data size: 2403694 Basic stats: COMPLETE Column stats: COMPLETE
TableScan Vectorization:
native: true
@@ -2017,14 +2017,14 @@ STAGE PLANS:
Filter Vectorization:
className: VectorFilterOperator
native: true
- predicateExpression: FilterExprOrExpr(children: FilterExprAndExpr(children: FilterDoubleColGreaterEqualDoubleColumn(col 5:double, col 4:double)(children: col 4:float), FilterStringGroupColLessEqualStringScalar(col 7:string, val a)), FilterExprAndExpr(children: FilterDecimal64ColLessEqualDecimal64Scalar(col 13:decimal(13,3)/DECIMAL_64, val -1389)(children: CastLongToDecimal64(col 2:int) -> 13:decimal(13,3)/DECIMAL_64), FilterLongColLessLongColumn(col 1:smallint, co [...]
- predicate: (((cdouble >= UDFToDouble(cfloat)) and (cstring2 <= 'a')) or ((CAST( cint AS decimal(13,3)) <= -1.389) and (csmallint < UDFToShort(ctinyint)) and (UDFToInteger(csmallint) < -6432)) or ((cstring1 like 'ss%') and (CAST( cbigint AS decimal(22,3)) < 10.175))) (type: boolean)
- Statistics: Num rows: 3868 Data size: 756762 Basic stats: COMPLETE Column stats: COMPLETE
+ predicateExpression: FilterExprOrExpr(children: FilterExprAndExpr(children: FilterDoubleColGreaterEqualDoubleColumn(col 5:double, col 4:double)(children: col 4:float), FilterStringGroupColLessEqualStringScalar(col 7:string, val a)), FilterExprAndExpr(children: FilterDecimal64ColLessEqualDecimal64Scalar(col 13:decimal(13,3)/DECIMAL_64, val -1389)(children: CastLongToDecimal64(col 2:int) -> 13:decimal(13,3)/DECIMAL_64), FilterLongColLessLongColumn(col 1:smallint, co [...]
+ predicate: (((cdouble >= UDFToDouble(cfloat)) and (cstring2 <= 'a')) or ((CAST( cint AS decimal(13,3)) <= -1.389) and (csmallint < UDFToShort(ctinyint)) and (csmallint < -6432S)) or ((cstring1 like 'ss%') and (CAST( cbigint AS decimal(22,3)) < 10.175))) (type: boolean)
+ Statistics: Num rows: 3828 Data size: 749058 Basic stats: COMPLETE Column stats: COMPLETE
Top N Key Operator
sort order: +++++++++++++++
keys: csmallint (type: smallint), cstring2 (type: string), cdouble (type: double), cfloat (type: float), cbigint (type: bigint), (UDFToDouble(cbigint) / 3569.0D) (type: double), (-257 - UDFToInteger(csmallint)) (type: int), (-6432.0 * cfloat) (type: float), (- cdouble) (type: double), (cdouble * 10.175D) (type: double), (UDFToDouble((-6432.0 * cfloat)) / UDFToDouble(cfloat)) (type: double), (- cfloat) (type: float), (cint % UDFToInteger(csmallint)) (type: int), (- c [...]
null sort order: zzzzzzzzzzzzzzz
- Statistics: Num rows: 3868 Data size: 756762 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 3828 Data size: 749058 Basic stats: COMPLETE Column stats: COMPLETE
top n: 45
Top N Key Vectorization:
className: VectorTopNKeyOperator
@@ -2038,7 +2038,7 @@ STAGE PLANS:
native: true
projectedOutputColumnNums: [8, 7, 5, 4, 3, 1, 21, 28, 15, 26, 29, 31, 32, 33, 34, 36]
selectExpressions: DoubleColDivideDoubleScalar(col 15:double, val 3569.0)(children: CastLongToDouble(col 3:bigint) -> 15:double) -> 21:double, LongScalarSubtractLongColumn(val -257, col 1:int)(children: col 1:smallint) -> 28:int, DoubleScalarMultiplyDoubleColumn(val -6432.0, col 4:float) -> 15:float, DoubleColUnaryMinus(col 5:double) -> 26:double, DoubleColMultiplyDoubleScalar(col 5:double, val 10.175) -> 29:double, DoubleColDivideDoubleColumn(col 30:double, c [...]
- Statistics: Num rows: 3868 Data size: 552696 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 3828 Data size: 547232 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: _col5 (type: smallint), _col1 (type: string), _col2 (type: double), _col3 (type: float), _col4 (type: bigint), _col6 (type: double), _col7 (type: int), _col8 (type: float), _col9 (type: double), _col10 (type: double), _col11 (type: double), _col12 (type: float), _col13 (type: int), _col14 (type: double), _col15 (type: double)
null sort order: zzzzzzzzzzzzzzz
@@ -2047,7 +2047,7 @@ STAGE PLANS:
className: VectorReduceSinkObjectHashOperator
native: true
nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
- Statistics: Num rows: 3868 Data size: 552696 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 3828 Data size: 547232 Basic stats: COMPLETE Column stats: COMPLETE
TopN Hash Memory Usage: 0.1
value expressions: _col0 (type: timestamp)
Execution mode: vectorized, llap
@@ -2077,7 +2077,7 @@ STAGE PLANS:
className: VectorSelectOperator
native: true
projectedOutputColumnNums: [15, 1, 2, 3, 4, 0, 5, 6, 7, 8, 9, 10, 11, 12, 8, 14]
- Statistics: Num rows: 3868 Data size: 552696 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 3828 Data size: 547232 Basic stats: COMPLETE Column stats: COMPLETE
Limit
Number of rows: 45
Limit Vectorization:
@@ -2271,7 +2271,7 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: alltypesorc
- filterExpr: ((UDFToInteger(ctinyint) <= cint) and (UDFToInteger(csmallint) >= -257) and (UDFToDouble(cint) >= cdouble)) (type: boolean)
+ filterExpr: ((csmallint >= -257S) and (UDFToInteger(ctinyint) <= cint) and (UDFToDouble(cint) >= cdouble)) (type: boolean)
Statistics: Num rows: 12288 Data size: 256884 Basic stats: COMPLETE Column stats: COMPLETE
TableScan Vectorization:
native: true
@@ -2279,14 +2279,14 @@ STAGE PLANS:
Filter Vectorization:
className: VectorFilterOperator
native: true
- predicateExpression: FilterExprAndExpr(children: FilterLongColLessEqualLongColumn(col 0:int, col 2:int)(children: col 0:tinyint), FilterLongColGreaterEqualLongScalar(col 1:int, val -257)(children: col 1:smallint), FilterDoubleColGreaterEqualDoubleColumn(col 13:double, col 5:double)(children: CastLongToDouble(col 2:int) -> 13:double))
- predicate: ((UDFToInteger(ctinyint) <= cint) and (UDFToInteger(csmallint) >= -257) and (UDFToDouble(cint) >= cdouble)) (type: boolean)
- Statistics: Num rows: 455 Data size: 9548 Basic stats: COMPLETE Column stats: COMPLETE
+ predicateExpression: FilterExprAndExpr(children: FilterLongColGreaterEqualLongScalar(col 1:smallint, val -257), FilterLongColLessEqualLongColumn(col 0:int, col 2:int)(children: col 0:tinyint), FilterDoubleColGreaterEqualDoubleColumn(col 13:double, col 5:double)(children: CastLongToDouble(col 2:int) -> 13:double))
+ predicate: ((csmallint >= -257S) and (UDFToInteger(ctinyint) <= cint) and (UDFToDouble(cint) >= cdouble)) (type: boolean)
+ Statistics: Num rows: 693 Data size: 14504 Basic stats: COMPLETE Column stats: COMPLETE
Top N Key Operator
sort order: +
keys: csmallint (type: smallint)
null sort order: z
- Statistics: Num rows: 455 Data size: 9548 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 693 Data size: 14504 Basic stats: COMPLETE Column stats: COMPLETE
top n: 20
Top N Key Vectorization:
className: VectorTopNKeyOperator
@@ -2300,7 +2300,7 @@ STAGE PLANS:
native: true
projectedOutputColumnNums: [1, 3, 0, 13, 16, 17, 20]
selectExpressions: CastLongToDouble(col 1:smallint) -> 13:double, DoubleColMultiplyDoubleColumn(col 14:double, col 15:double)(children: CastLongToDouble(col 1:smallint) -> 14:double, CastLongToDouble(col 1:smallint) -> 15:double) -> 16:double, CastLongToDouble(col 0:tinyint) -> 17:double, DoubleColMultiplyDoubleColumn(col 18:double, col 19:double)(children: CastLongToDouble(col 0:tinyint) -> 18:double, CastLongToDouble(col 0:tinyint) -> 19:double) -> 20:double
- Statistics: Num rows: 455 Data size: 9548 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 693 Data size: 14504 Basic stats: COMPLETE Column stats: COMPLETE
Group By Operator
aggregations: sum(_col4), sum(_col3), count(_col0), sum(_col1), sum(_col6), sum(_col5), count(_col2), count()
Group By Vectorization:
@@ -2312,10 +2312,10 @@ STAGE PLANS:
vectorProcessingMode: HASH
projectedOutputColumnNums: [0, 1, 2, 3, 4, 5, 6, 7]
keys: _col0 (type: smallint)
- minReductionHashAggr: 0.49890107
+ minReductionHashAggr: 0.53679657
mode: hash
outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8
- Statistics: Num rows: 227 Data size: 14980 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 321 Data size: 21180 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: _col0 (type: smallint)
null sort order: z
@@ -2325,7 +2325,7 @@ STAGE PLANS:
className: VectorReduceSinkLongOperator
native: true
nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
- Statistics: Num rows: 227 Data size: 14980 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 321 Data size: 21180 Basic stats: COMPLETE Column stats: COMPLETE
value expressions: _col1 (type: double), _col2 (type: double), _col3 (type: bigint), _col4 (type: bigint), _col5 (type: double), _col6 (type: double), _col7 (type: bigint), _col8 (type: bigint)
Execution mode: vectorized, llap
LLAP IO: all inputs
@@ -2360,12 +2360,12 @@ STAGE PLANS:
keys: KEY._col0 (type: smallint)
mode: mergepartial
outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8
- Statistics: Num rows: 227 Data size: 14980 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 321 Data size: 21180 Basic stats: COMPLETE Column stats: COMPLETE
Top N Key Operator
sort order: +++++++++++
keys: _col0 (type: smallint), (UDFToInteger(_col0) % -75) (type: int), power(((_col1 - ((_col2 * _col2) / _col3)) / CASE WHEN ((_col3 = 1L)) THEN (null) ELSE ((_col3 - 1)) END), 0.5) (type: double), (-1.389 / CAST( _col0 AS decimal(5,0))) (type: decimal(10,9)), _col4 (type: bigint), (UDFToDouble((UDFToInteger(_col0) % -75)) / UDFToDouble(_col4)) (type: double), (- (UDFToInteger(_col0) % -75)) (type: int), ((_col5 - ((_col6 * _col6) / _col7)) / _col7) (type: double), (- [...]
null sort order: zzzzzzzzzzz
- Statistics: Num rows: 227 Data size: 14980 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 321 Data size: 21180 Basic stats: COMPLETE Column stats: COMPLETE
top n: 20
Top N Key Vectorization:
className: VectorTopNKeyOperator
@@ -2379,7 +2379,7 @@ STAGE PLANS:
native: true
projectedOutputColumnNums: [0, 15, 10, 34, 4, 16, 31, 12, 30, 8, 36]
selectExpressions: LongColModuloLongScalar(col 0:int, val -75)(children: col 0:smallint) -> 15:int, FuncPowerDoubleToDouble(col 11:double)(children: DoubleColDivideLongColumn(col 10:double, col 30:bigint)(children: DoubleColSubtractDoubleColumn(col 1:double, col 11:double)(children: DoubleColDivideLongColumn(col 10:double, col 3:bigint)(children: DoubleColMultiplyDoubleColumn(col 2:double, col 2:double) -> 10:double) -> 11:double) -> 10:double, IfExprNullCondExpr( [...]
- Statistics: Num rows: 227 Data size: 39036 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 321 Data size: 55196 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: _col0 (type: smallint), _col1 (type: int), _col2 (type: double), _col3 (type: decimal(10,9)), _col4 (type: bigint), _col5 (type: double), _col6 (type: int), _col7 (type: double), _col8 (type: int), _col9 (type: bigint), _col10 (type: bigint)
null sort order: zzzzzzzzzzz
@@ -2388,7 +2388,7 @@ STAGE PLANS:
className: VectorReduceSinkObjectHashOperator
native: true
nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
- Statistics: Num rows: 227 Data size: 39036 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 321 Data size: 55196 Basic stats: COMPLETE Column stats: COMPLETE
TopN Hash Memory Usage: 0.1
Reducer 3
Execution mode: vectorized, llap
@@ -2406,7 +2406,7 @@ STAGE PLANS:
className: VectorSelectOperator
native: true
projectedOutputColumnNums: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
- Statistics: Num rows: 227 Data size: 39036 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 321 Data size: 55196 Basic stats: COMPLETE Column stats: COMPLETE
Limit
Number of rows: 20
Limit Vectorization:
@@ -2576,30 +2576,30 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: alltypesorc
- filterExpr: ((cdouble > 2563.58D) and (((cbigint >= UDFToLong(cint)) and (UDFToInteger(csmallint) < cint) and (cfloat < -5638.15)) or (CAST( ctinyint AS decimal(6,2)) = 2563.58) or ((cdouble <= UDFToDouble(cbigint)) and (CAST( cbigint AS decimal(21,2)) < -5638.15)))) (type: boolean)
- Statistics: Num rows: 12288 Data size: 293580 Basic stats: COMPLETE Column stats: COMPLETE
+ filterExpr: ((cdouble > 2563.58D) and (((cbigint >= UDFToLong(cint)) and (UDFToInteger(csmallint) < cint) and (cfloat < -5638.15)) or ((cdouble <= UDFToDouble(cbigint)) and (CAST( cbigint AS decimal(21,2)) < -5638.15)))) (type: boolean)
+ Statistics: Num rows: 12288 Data size: 256884 Basic stats: COMPLETE Column stats: COMPLETE
TableScan Vectorization:
native: true
Filter Operator
Filter Vectorization:
className: VectorFilterOperator
native: true
- predicateExpression: FilterExprAndExpr(children: FilterDoubleColGreaterDoubleScalar(col 5:double, val 2563.58), FilterExprOrExpr(children: FilterExprAndExpr(children: FilterLongColGreaterEqualLongColumn(col 3:bigint, col 2:bigint)(children: col 2:int), FilterLongColLessLongColumn(col 1:int, col 2:int)(children: col 1:smallint), FilterDoubleColLessDoubleScalar(col 4:float, val -5638.14990234375)), FilterDecimal64ColEqualDecimal64Scalar(col 13:decimal(6,2)/DECIMAL_6 [...]
- predicate: ((cdouble > 2563.58D) and (((cbigint >= UDFToLong(cint)) and (UDFToInteger(csmallint) < cint) and (cfloat < -5638.15)) or (CAST( ctinyint AS decimal(6,2)) = 2563.58) or ((cdouble <= UDFToDouble(cbigint)) and (CAST( cbigint AS decimal(21,2)) < -5638.15)))) (type: boolean)
- Statistics: Num rows: 7494 Data size: 179052 Basic stats: COMPLETE Column stats: COMPLETE
+ predicateExpression: FilterExprAndExpr(children: FilterDoubleColGreaterDoubleScalar(col 5:double, val 2563.58), FilterExprOrExpr(children: FilterExprAndExpr(children: FilterLongColGreaterEqualLongColumn(col 3:bigint, col 2:bigint)(children: col 2:int), FilterLongColLessLongColumn(col 1:int, col 2:int)(children: col 1:smallint), FilterDoubleColLessDoubleScalar(col 4:float, val -5638.14990234375)), FilterExprAndExpr(children: FilterDoubleColLessEqualDoubleColumn(col [...]
+ predicate: ((cdouble > 2563.58D) and (((cbigint >= UDFToLong(cint)) and (UDFToInteger(csmallint) < cint) and (cfloat < -5638.15)) or ((cdouble <= UDFToDouble(cbigint)) and (CAST( cbigint AS decimal(21,2)) < -5638.15)))) (type: boolean)
+ Statistics: Num rows: 1362 Data size: 28504 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: cdouble (type: double), cfloat (type: float), (cdouble * cdouble) (type: double)
outputColumnNames: _col0, _col1, _col2
Select Vectorization:
className: VectorSelectOperator
native: true
- projectedOutputColumnNums: [5, 4, 16]
- selectExpressions: DoubleColMultiplyDoubleColumn(col 5:double, col 5:double) -> 16:double
- Statistics: Num rows: 7494 Data size: 179052 Basic stats: COMPLETE Column stats: COMPLETE
+ projectedOutputColumnNums: [5, 4, 15]
+ selectExpressions: DoubleColMultiplyDoubleColumn(col 5:double, col 5:double) -> 15:double
+ Statistics: Num rows: 1362 Data size: 28504 Basic stats: COMPLETE Column stats: COMPLETE
Group By Operator
aggregations: sum(_col2), sum(_col0), count(_col0), count(_col1), sum(_col1)
Group By Vectorization:
- aggregators: VectorUDAFSumDouble(col 16:double) -> double, VectorUDAFSumDouble(col 5:double) -> double, VectorUDAFCount(col 5:double) -> bigint, VectorUDAFCount(col 4:float) -> bigint, VectorUDAFSumDouble(col 4:float) -> double
+ aggregators: VectorUDAFSumDouble(col 15:double) -> double, VectorUDAFSumDouble(col 5:double) -> double, VectorUDAFCount(col 5:double) -> bigint, VectorUDAFCount(col 4:float) -> bigint, VectorUDAFSumDouble(col 4:float) -> double
className: VectorGroupByOperator
groupByMode: HASH
keyExpressions: col 5:double
@@ -2607,10 +2607,10 @@ STAGE PLANS:
vectorProcessingMode: HASH
projectedOutputColumnNums: [0, 1, 2, 3, 4]
keys: _col0 (type: double)
- minReductionHashAggr: 0.55004
+ minReductionHashAggr: 0.54919237
mode: hash
outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
- Statistics: Num rows: 3372 Data size: 155032 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 614 Data size: 28232 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: _col0 (type: double)
null sort order: z
@@ -2620,7 +2620,7 @@ STAGE PLANS:
className: VectorReduceSinkMultiKeyOperator
native: true
nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
- Statistics: Num rows: 3372 Data size: 155032 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 614 Data size: 28232 Basic stats: COMPLETE Column stats: COMPLETE
value expressions: _col1 (type: double), _col2 (type: double), _col3 (type: bigint), _col4 (type: bigint), _col5 (type: double)
Execution mode: vectorized, llap
LLAP IO: all inputs
@@ -2655,7 +2655,7 @@ STAGE PLANS:
keys: KEY._col0 (type: double)
mode: mergepartial
outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
- Statistics: Num rows: 3372 Data size: 155032 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 614 Data size: 28232 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: _col0 (type: double), ((_col1 - ((_col2 * _col2) / _col3)) / CASE WHEN ((_col3 = 1L)) THEN (null) ELSE ((_col3 - 1)) END) (type: double), (2563.58D * ((_col1 - ((_col2 * _col2) / _col3)) / CASE WHEN ((_col3 = 1L)) THEN (null) ELSE ((_col3 - 1)) END)) (type: double), (- ((_col1 - ((_col2 * _col2) / _col3)) / CASE WHEN ((_col3 = 1L)) THEN (null) ELSE ((_col3 - 1)) END)) (type: double), _col4 (type: bigint), ((2563.58D * ((_col1 - ((_col2 * _col2) / _col3)) / [...]
outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14
@@ -2664,7 +2664,7 @@ STAGE PLANS:
native: true
projectedOutputColumnNums: [0, 12, 20, 28, 4, 37, 55, 5, 59, 68, 73, 81, 82, 2, 84]
selectExpressions: DoubleColDivideLongColumn(col 8:double, col 11:bigint)(children: DoubleColSubtractDoubleColumn(col 1:double, col 7:double)(children: DoubleColDivideLongColumn(col 6:double, col 3:bigint)(children: DoubleColMultiplyDoubleColumn(col 2:double, col 2:double) -> 6:double) -> 7:double) -> 8:double, IfExprNullCondExpr(col 9:boolean, null, col 10:bigint)(children: LongColEqualLongScalar(col 3:bigint, val 1) -> 9:boolean, LongColSubtractLongScalar(col 3:bi [...]
- Statistics: Num rows: 3372 Data size: 424792 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 614 Data size: 77352 Basic stats: COMPLETE Column stats: COMPLETE
Reduce Output Operator
key expressions: _col0 (type: double)
null sort order: z
@@ -2673,7 +2673,7 @@ STAGE PLANS:
className: VectorReduceSinkObjectHashOperator
native: true
nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
- Statistics: Num rows: 3372 Data size: 424792 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 614 Data size: 77352 Basic stats: COMPLETE Column stats: COMPLETE
value expressions: _col1 (type: double), _col2 (type: double), _col3 (type: double), _col4 (type: bigint), _col5 (type: double), _col6 (type: double), _col7 (type: double), _col8 (type: double), _col9 (type: double), _col10 (type: double), _col11 (type: double), _col12 (type: double), _col13 (type: double), _col14 (type: double)
Reducer 3
Execution mode: vectorized, llap
@@ -2691,13 +2691,13 @@ STAGE PLANS:
className: VectorSelectOperator
native: true
projectedOutputColumnNums: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13]
- Statistics: Num rows: 3372 Data size: 424792 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 614 Data size: 77352 Basic stats: COMPLETE Column stats: COMPLETE
File Output Operator
compressed: false
File Sink Vectorization:
className: VectorFileSinkOperator
native: false
- Statistics: Num rows: 3372 Data size: 424792 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 614 Data size: 77352 Basic stats: COMPLETE Column stats: COMPLETE
table:
input format: org.apache.hadoop.mapred.SequenceFileInputFormat
output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
diff --git a/ql/src/test/results/clientpositive/parquet_vectorization_10.q.out b/ql/src/test/results/clientpositive/parquet_vectorization_10.q.out
index d59f9f3..aef4ad2 100644
--- a/ql/src/test/results/clientpositive/parquet_vectorization_10.q.out
+++ b/ql/src/test/results/clientpositive/parquet_vectorization_10.q.out
@@ -64,7 +64,7 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: alltypesparquet
- filterExpr: ((cstring2 <= '10') or ((UDFToDouble(ctinyint) > cdouble) and (CAST( ctinyint AS decimal(6,2)) <= -5638.15)) or ((cdouble > 6981.0D) and ((CAST( csmallint AS decimal(11,4)) = 9763215.5639) or (cstring1 like '%a')))) (type: boolean)
+ filterExpr: ((cstring2 <= '10') or ((UDFToDouble(ctinyint) > cdouble) and (CAST( ctinyint AS decimal(6,2)) <= -5638.15)) or ((cdouble > 6981.0D) and (cstring1 like '%a'))) (type: boolean)
Statistics: Num rows: 12288 Data size: 2367002 Basic stats: COMPLETE Column stats: COMPLETE
TableScan Vectorization:
native: true
@@ -72,24 +72,24 @@ STAGE PLANS:
Filter Vectorization:
className: VectorFilterOperator
native: true
- predicateExpression: FilterExprOrExpr(children: FilterStringGroupColLessEqualStringScalar(col 7:string, val 10), FilterExprAndExpr(children: FilterDoubleColGreaterDoubleColumn(col 13:double, col 5:double)(children: CastLongToDouble(col 0:tinyint) -> 13:double), FilterDecimal64ColLessEqualDecimal64Scalar(col 14:decimal(6,2)/DECIMAL_64, val -563815)(children: CastLongToDecimal64(col 0:tinyint) -> 14:decimal(6,2)/DECIMAL_64)), FilterExprAndExpr(children: FilterDoubleColGre [...]
- predicate: ((cstring2 <= '10') or ((UDFToDouble(ctinyint) > cdouble) and (CAST( ctinyint AS decimal(6,2)) <= -5638.15)) or ((cdouble > 6981.0D) and ((CAST( csmallint AS decimal(11,4)) = 9763215.5639) or (cstring1 like '%a')))) (type: boolean)
- Statistics: Num rows: 12288 Data size: 2367002 Basic stats: COMPLETE Column stats: COMPLETE
+ predicateExpression: FilterExprOrExpr(children: FilterStringGroupColLessEqualStringScalar(col 7:string, val 10), FilterExprAndExpr(children: FilterDoubleColGreaterDoubleColumn(col 13:double, col 5:double)(children: CastLongToDouble(col 0:tinyint) -> 13:double), FilterDecimal64ColLessEqualDecimal64Scalar(col 14:decimal(6,2)/DECIMAL_64, val -563815)(children: CastLongToDecimal64(col 0:tinyint) -> 14:decimal(6,2)/DECIMAL_64)), FilterExprAndExpr(children: FilterDoubleColGre [...]
+ predicate: ((cstring2 <= '10') or ((UDFToDouble(ctinyint) > cdouble) and (CAST( ctinyint AS decimal(6,2)) <= -5638.15)) or ((cdouble > 6981.0D) and (cstring1 like '%a'))) (type: boolean)
+ Statistics: Num rows: 11590 Data size: 2232584 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: cdouble (type: double), ctimestamp1 (type: timestamp), ctinyint (type: tinyint), cboolean1 (type: boolean), cstring1 (type: string), (- cdouble) (type: double), (cdouble + UDFToDouble(csmallint)) (type: double), ((cdouble + UDFToDouble(csmallint)) % 33.0D) (type: double), (- cdouble) (type: double), (UDFToDouble(ctinyint) % cdouble) (type: double), (UDFToShort(ctinyint) % csmallint) (type: smallint), (- cdouble) (type: double), (cbigint * UDFToLong((UDFToShor [...]
outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14
Select Vectorization:
className: VectorSelectOperator
native: true
- projectedOutputColumnNums: [5, 8, 0, 10, 6, 16, 18, 21, 22, 24, 25, 26, 28, 31, 33]
- selectExpressions: DoubleColUnaryMinus(col 5:double) -> 16:double, DoubleColAddDoubleColumn(col 5:double, col 17:double)(children: CastLongToDouble(col 1:smallint) -> 17:double) -> 18:double, DoubleColModuloDoubleScalar(col 20:double, val 33.0)(children: DoubleColAddDoubleColumn(col 5:double, col 19:double)(children: CastLongToDouble(col 1:smallint) -> 19:double) -> 20:double) -> 21:double, DoubleColUnaryMinus(col 5:double) -> 22:double, DoubleColModuloDoubleColumn(co [...]
- Statistics: Num rows: 12288 Data size: 2310094 Basic stats: COMPLETE Column stats: COMPLETE
+ projectedOutputColumnNums: [5, 8, 0, 10, 6, 15, 17, 20, 21, 23, 24, 25, 27, 30, 32]
+ selectExpressions: DoubleColUnaryMinus(col 5:double) -> 15:double, DoubleColAddDoubleColumn(col 5:double, col 16:double)(children: CastLongToDouble(col 1:smallint) -> 16:double) -> 17:double, DoubleColModuloDoubleScalar(col 19:double, val 33.0)(children: DoubleColAddDoubleColumn(col 5:double, col 18:double)(children: CastLongToDouble(col 1:smallint) -> 18:double) -> 19:double) -> 20:double, DoubleColUnaryMinus(col 5:double) -> 21:double, DoubleColModuloDoubleColumn(co [...]
+ Statistics: Num rows: 11590 Data size: 2178896 Basic stats: COMPLETE Column stats: COMPLETE
File Output Operator
compressed: false
File Sink Vectorization:
className: VectorFileSinkOperator
native: false
- Statistics: Num rows: 12288 Data size: 2310094 Basic stats: COMPLETE Column stats: COMPLETE
+ Statistics: Num rows: 11590 Data size: 2178896 Basic stats: COMPLETE Column stats: COMPLETE
table:
input format: org.apache.hadoop.mapred.SequenceFileInputFormat
output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
diff --git a/ql/src/test/results/clientpositive/pcs.q.out b/ql/src/test/results/clientpositive/pcs.q.out
index d10a070..3f561cc 100644
--- a/ql/src/test/results/clientpositive/pcs.q.out
+++ b/ql/src/test/results/clientpositive/pcs.q.out
@@ -1560,7 +1560,7 @@ POSTHOOK: Input: default@pcs_t1@ds=2000-04-10
#### A masked pattern was here ####
OPTIMIZED SQL: SELECT `ds`
FROM `default`.`pcs_t1`
-WHERE `ds` <> '2000-04-08' AND `key` = 3 OR (`ds` = '2000-04-08' OR `key` IS NOT NULL) AND `key` = 2
+WHERE `ds` <> '2000-04-08' AND `key` <> 2 AND `key` = 3 OR (`ds` = '2000-04-08' OR `key` IS NOT NULL) AND `key` = 2
STAGE DEPENDENCIES:
Stage-1 is a root stage
Stage-0 depends on stages: Stage-1
@@ -1571,12 +1571,12 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: pcs_t1
- filterExpr: (((ds <> '2000-04-08') and (key = 3)) or (((ds = '2000-04-08') or key is not null) and (key = 2))) (type: boolean)
+ filterExpr: (((ds <> '2000-04-08') and (key <> 2) and (key = 3)) or (((ds = '2000-04-08') or key is not null) and (key = 2))) (type: boolean)
Statistics: Num rows: 60 Data size: 11280 Basic stats: COMPLETE Column stats: COMPLETE
GatherStats: false
Filter Operator
isSamplingPred: false
- predicate: (((ds <> '2000-04-08') and (key = 3)) or (((ds = '2000-04-08') or key is not null) and (key = 2))) (type: boolean)
+ predicate: (((ds <> '2000-04-08') and (key <> 2) and (key = 3)) or (((ds = '2000-04-08') or key is not null) and (key = 2))) (type: boolean)
Statistics: Num rows: 10 Data size: 1880 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: ds (type: string)
@@ -1796,7 +1796,7 @@ POSTHOOK: Input: default@pcs_t1@ds=2000-04-10
#### A masked pattern was here ####
OPTIMIZED SQL: SELECT `ds`
FROM `default`.`pcs_t1`
-WHERE `key` = 3 OR ((`ds` = '2000-04-08' OR `key` IS NOT NULL) AND `key` = 2 OR `ds` <> '2000-04-08' AND `key` = 3) AND `key` + 5 > 0
+WHERE `key` = 3 OR ((`ds` = '2000-04-08' OR `key` IS NOT NULL) AND `key` = 2 OR `ds` <> '2000-04-08' AND `key` <> 2 AND `key` = 3) AND `key` + 5 > 0
STAGE DEPENDENCIES:
Stage-1 is a root stage
Stage-0 depends on stages: Stage-1
@@ -1807,12 +1807,12 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: pcs_t1
- filterExpr: ((key = 3) or (((((ds = '2000-04-08') or key is not null) and (key = 2)) or ((ds <> '2000-04-08') and (key = 3))) and ((key + 5) > 0))) (type: boolean)
+ filterExpr: ((key = 3) or (((((ds = '2000-04-08') or key is not null) and (key = 2)) or ((ds <> '2000-04-08') and (key <> 2) and (key = 3))) and ((key + 5) > 0))) (type: boolean)
Statistics: Num rows: 60 Data size: 11280 Basic stats: COMPLETE Column stats: COMPLETE
GatherStats: false
Filter Operator
isSamplingPred: false
- predicate: ((key = 3) or (((((ds = '2000-04-08') or key is not null) and (key = 2)) or ((ds <> '2000-04-08') and (key = 3))) and ((key + 5) > 0))) (type: boolean)
+ predicate: ((key = 3) or (((((ds = '2000-04-08') or key is not null) and (key = 2)) or ((ds <> '2000-04-08') and (key <> 2) and (key = 3))) and ((key + 5) > 0))) (type: boolean)
Statistics: Num rows: 8 Data size: 1504 Basic stats: COMPLETE Column stats: COMPLETE
Select Operator
expressions: ds (type: string)
diff --git a/ql/src/test/results/clientpositive/perf/spark/query37.q.out b/ql/src/test/results/clientpositive/perf/spark/query37.q.out
index cf94e79..62500bd 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query37.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query37.q.out
@@ -103,10 +103,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: item
- filterExpr: (i_current_price BETWEEN 22 AND 52 and (i_manufact_id) IN (678, 964, 918, 849) and i_item_sk is not null) (type: boolean)
+ filterExpr: ((i_manufact_id) IN (678, 964, 918, 849) and i_current_price BETWEEN 22 AND 52 and i_item_sk is not null) (type: boolean)
Statistics: Num rows: 462000 Data size: 663560457 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: (i_current_price BETWEEN 22 AND 52 and (i_manufact_id) IN (678, 964, 918, 849) and i_item_sk is not null) (type: boolean)
+ predicate: ((i_manufact_id) IN (678, 964, 918, 849) and i_current_price BETWEEN 22 AND 52 and i_item_sk is not null) (type: boolean)
Statistics: Num rows: 51333 Data size: 73728460 Basic stats: COMPLETE Column stats: NONE
Select Operator
expressions: i_item_sk (type: int), i_item_id (type: string), i_item_desc (type: string), i_current_price (type: decimal(7,2))
diff --git a/ql/src/test/results/clientpositive/perf/spark/query47.q.out b/ql/src/test/results/clientpositive/perf/spark/query47.q.out
index 2aa0a17..6b788f7 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query47.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query47.q.out
@@ -536,7 +536,7 @@ STAGE PLANS:
isPivotResult: true
Statistics: Num rows: 383325119 Data size: 33817053293 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: ((_col0 > 0) and rank_window_1 is not null and (_col5 = 2000)) (type: boolean)
+ predicate: (rank_window_1 is not null and (_col0 > 0) and (_col5 = 2000)) (type: boolean)
Statistics: Num rows: 63887519 Data size: 5636175475 Basic stats: COMPLETE Column stats: NONE
Select Operator
expressions: rank_window_1 (type: int), _col0 (type: decimal(21,6)), _col1 (type: string), _col2 (type: string), _col3 (type: string), _col4 (type: string), _col5 (type: int), _col6 (type: int), _col7 (type: decimal(17,2))
diff --git a/ql/src/test/results/clientpositive/perf/spark/query48.q.out b/ql/src/test/results/clientpositive/perf/spark/query48.q.out
index e903c43..4654da3 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query48.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query48.q.out
@@ -184,10 +184,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: store_sales
- filterExpr: ((ss_sales_price BETWEEN 100 AND 150 or ss_sales_price BETWEEN 50 AND 100 or ss_sales_price BETWEEN 150 AND 200) and ss_store_sk is not null and ss_cdemo_sk is not null and ss_addr_sk is not null and ss_sold_date_sk is not null and ((ss_sales_price >= 100) or (ss_sales_price <= 150) or (ss_sales_price >= 50) or (ss_sales_price <= 100) or (ss_sales_price >= 150) or (ss_sales_price <= 200)) and ((ss_net_profit >= 0) or (ss_net_profit <= 2000) or (ss_net_profit [...]
+ filterExpr: (ss_store_sk is not null and ss_cdemo_sk is not null and ss_addr_sk is not null and ss_sold_date_sk is not null and (ss_sales_price BETWEEN 100 AND 150 or ss_sales_price BETWEEN 50 AND 100 or ss_sales_price BETWEEN 150 AND 200) and ((ss_sales_price >= 100) or (ss_sales_price <= 150) or (ss_sales_price >= 50) or (ss_sales_price <= 100) or (ss_sales_price >= 150) or (ss_sales_price <= 200)) and ((ss_net_profit >= 0) or (ss_net_profit <= 2000) or (ss_net_profit [...]
Statistics: Num rows: 575995635 Data size: 50814502088 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: ((ss_sales_price BETWEEN 100 AND 150 or ss_sales_price BETWEEN 50 AND 100 or ss_sales_price BETWEEN 150 AND 200) and ss_store_sk is not null and ss_cdemo_sk is not null and ss_addr_sk is not null and ss_sold_date_sk is not null and ((ss_sales_price >= 100) or (ss_sales_price <= 150) or (ss_sales_price >= 50) or (ss_sales_price <= 100) or (ss_sales_price >= 150) or (ss_sales_price <= 200)) and ((ss_net_profit >= 0) or (ss_net_profit <= 2000) or (ss_net_profi [...]
+ predicate: (ss_store_sk is not null and ss_cdemo_sk is not null and ss_addr_sk is not null and ss_sold_date_sk is not null and (ss_sales_price BETWEEN 100 AND 150 or ss_sales_price BETWEEN 50 AND 100 or ss_sales_price BETWEEN 150 AND 200) and ((ss_sales_price >= 100) or (ss_sales_price <= 150) or (ss_sales_price >= 50) or (ss_sales_price <= 100) or (ss_sales_price >= 150) or (ss_sales_price <= 200)) and ((ss_net_profit >= 0) or (ss_net_profit <= 2000) or (ss_net_profi [...]
Statistics: Num rows: 191998545 Data size: 16938167362 Basic stats: COMPLETE Column stats: NONE
Select Operator
expressions: ss_sold_date_sk (type: int), ss_cdemo_sk (type: int), ss_addr_sk (type: int), ss_store_sk (type: int), ss_quantity (type: int), ss_net_profit BETWEEN 0 AND 2000 (type: boolean), ss_net_profit BETWEEN 150 AND 3000 (type: boolean), ss_net_profit BETWEEN 50 AND 25000 (type: boolean)
diff --git a/ql/src/test/results/clientpositive/perf/spark/query49.q.out b/ql/src/test/results/clientpositive/perf/spark/query49.q.out
index f7f0d44..54cb904 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query49.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query49.q.out
@@ -298,10 +298,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: ws
- filterExpr: ((ws_net_profit > 1) and (ws_net_paid > 0) and (ws_quantity > 0) and ws_order_number is not null and ws_item_sk is not null and ws_sold_date_sk is not null) (type: boolean)
+ filterExpr: ((ws_quantity > 0) and (ws_net_profit > 1) and (ws_net_paid > 0) and ws_order_number is not null and ws_item_sk is not null and ws_sold_date_sk is not null) (type: boolean)
Statistics: Num rows: 144002668 Data size: 19580198212 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: ((ws_net_profit > 1) and (ws_net_paid > 0) and (ws_quantity > 0) and ws_order_number is not null and ws_item_sk is not null and ws_sold_date_sk is not null) (type: boolean)
+ predicate: ((ws_quantity > 0) and (ws_net_profit > 1) and (ws_net_paid > 0) and ws_order_number is not null and ws_item_sk is not null and ws_sold_date_sk is not null) (type: boolean)
Statistics: Num rows: 5333432 Data size: 725192506 Basic stats: COMPLETE Column stats: NONE
Select Operator
expressions: ws_sold_date_sk (type: int), ws_item_sk (type: int), ws_order_number (type: int), CASE WHEN (ws_quantity is not null) THEN (ws_quantity) ELSE (0) END (type: int), CASE WHEN (ws_net_paid is not null) THEN (ws_net_paid) ELSE (0) END (type: decimal(7,2))
@@ -360,10 +360,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: cs
- filterExpr: ((cs_net_profit > 1) and (cs_net_paid > 0) and (cs_quantity > 0) and cs_order_number is not null and cs_item_sk is not null and cs_sold_date_sk is not null) (type: boolean)
+ filterExpr: ((cs_quantity > 0) and (cs_net_profit > 1) and (cs_net_paid > 0) and cs_order_number is not null and cs_item_sk is not null and cs_sold_date_sk is not null) (type: boolean)
Statistics: Num rows: 287989836 Data size: 38999608952 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: ((cs_net_profit > 1) and (cs_net_paid > 0) and (cs_quantity > 0) and cs_order_number is not null and cs_item_sk is not null and cs_sold_date_sk is not null) (type: boolean)
+ predicate: ((cs_quantity > 0) and (cs_net_profit > 1) and (cs_net_paid > 0) and cs_order_number is not null and cs_item_sk is not null and cs_sold_date_sk is not null) (type: boolean)
Statistics: Num rows: 10666290 Data size: 1444429931 Basic stats: COMPLETE Column stats: NONE
Select Operator
expressions: cs_sold_date_sk (type: int), cs_item_sk (type: int), cs_order_number (type: int), CASE WHEN (cs_quantity is not null) THEN (cs_quantity) ELSE (0) END (type: int), CASE WHEN (cs_net_paid is not null) THEN (cs_net_paid) ELSE (0) END (type: decimal(7,2))
@@ -402,10 +402,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: sts
- filterExpr: ((ss_net_profit > 1) and (ss_net_paid > 0) and (ss_quantity > 0) and ss_ticket_number is not null and ss_item_sk is not null and ss_sold_date_sk is not null) (type: boolean)
+ filterExpr: ((ss_quantity > 0) and (ss_net_profit > 1) and (ss_net_paid > 0) and ss_ticket_number is not null and ss_item_sk is not null and ss_sold_date_sk is not null) (type: boolean)
Statistics: Num rows: 575995635 Data size: 50814502088 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: ((ss_net_profit > 1) and (ss_net_paid > 0) and (ss_quantity > 0) and ss_ticket_number is not null and ss_item_sk is not null and ss_sold_date_sk is not null) (type: boolean)
+ predicate: ((ss_quantity > 0) and (ss_net_profit > 1) and (ss_net_paid > 0) and ss_ticket_number is not null and ss_item_sk is not null and ss_sold_date_sk is not null) (type: boolean)
Statistics: Num rows: 21333171 Data size: 1882018537 Basic stats: COMPLETE Column stats: NONE
Select Operator
expressions: ss_sold_date_sk (type: int), ss_item_sk (type: int), ss_ticket_number (type: int), CASE WHEN (ss_quantity is not null) THEN (ss_quantity) ELSE (0) END (type: int), CASE WHEN (ss_net_paid is not null) THEN (ss_net_paid) ELSE (0) END (type: decimal(7,2))
diff --git a/ql/src/test/results/clientpositive/perf/spark/query82.q.out b/ql/src/test/results/clientpositive/perf/spark/query82.q.out
index 3eb562b..bf4be94 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query82.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query82.q.out
@@ -103,10 +103,10 @@ STAGE PLANS:
Map Operator Tree:
TableScan
alias: item
- filterExpr: (i_current_price BETWEEN 30 AND 60 and (i_manufact_id) IN (437, 129, 727, 663) and i_item_sk is not null) (type: boolean)
+ filterExpr: ((i_manufact_id) IN (437, 129, 727, 663) and i_current_price BETWEEN 30 AND 60 and i_item_sk is not null) (type: boolean)
Statistics: Num rows: 462000 Data size: 663560457 Basic stats: COMPLETE Column stats: NONE
Filter Operator
- predicate: (i_current_price BETWEEN 30 AND 60 and (i_manufact_id) IN (437, 129, 727, 663) and i_item_sk is not null) (type: boolean)
+ predicate: ((i_manufact_id) IN (437, 129, 727, 663) and i_current_price BETWEEN 30 AND 60 and i_item_sk is not null) (type: boolean)
Statistics: Num rows: 51333 Data size: 73728460 Basic stats: COMPLETE Column stats: NONE
Select Operator
expressions: i_item_sk (type: int), i_item_id (type: string), i_item_desc (type: string), i_current_price (type: decimal(7,2))
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query10.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query10.q.out
index e076022..ef47177 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query10.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query10.q.out
@@ -144,7 +144,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$4], sort4=[$6], sort5=
HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($4), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer]], table:alias=[c])
HiveProject(ca_address_sk=[$0], ca_county=[$7])
- HiveFilter(condition=[AND(IN($7, _UTF-16LE'Walker County', _UTF-16LE'Richland County', _UTF-16LE'Gaines County', _UTF-16LE'Douglas County', _UTF-16LE'Dona Ana County'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($7, _UTF-16LE'Walker County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Richland County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Gaines County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Douglas County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Dona Ana County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[ca])
HiveProject(cd_demo_sk=[$0], cd_gender=[$1], cd_marital_status=[$2], cd_education_status=[$3], cd_purchase_estimate=[$4], cd_credit_rating=[$5], cd_dep_count=[$6], cd_dep_employed_count=[$7], cd_dep_college_count=[$8])
HiveFilter(condition=[IS NOT NULL($0)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query11.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query11.q.out
index b6f3727..65a61d4 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query11.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query11.q.out
@@ -189,7 +189,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject($f0=[$0], $f9=[$7])
- HiveFilter(condition=[>($7, 0:DECIMAL(1, 0))])
+ HiveFilter(condition=[>($7, 0)])
HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
@@ -203,7 +203,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(customer_id=[$0], year_total=[$7], CAST=[CAST(IS NOT NULL($7)):BOOLEAN])
- HiveFilter(condition=[>($7, 0:DECIMAL(1, 0))])
+ HiveFilter(condition=[>($7, 0)])
HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query12.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query12.q.out
index edb893e..21bd652 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query12.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query12.q.out
@@ -77,7 +77,7 @@ HiveProject(i_item_desc=[$0], i_category=[$1], i_class=[$2], i_current_price=[$3
HiveAggregate(group=[{1, 2, 3, 4, 5}], agg#0=[sum($8)])
HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_class=[$10], i_category=[$12])
- HiveFilter(condition=[AND(IN($12, _UTF-16LE'Jewelry', _UTF-16LE'Sports', _UTF-16LE'Books'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($12, _UTF-16LE'Jewelry':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Sports':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Books':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_ext_sales_price=[$23])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query13.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query13.q.out
index 9fab0cb..12e6834 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query13.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query13.q.out
@@ -119,8 +119,8 @@ HiveProject($f0=[/(CAST($0):DOUBLE, $1)], $f1=[CAST(/($2, $3)):DECIMAL(11, 6)],
HiveJoin(condition=[AND(=($6, $26), OR(AND($20, $21, $15, $27), AND($22, $23, $16, $28), AND($24, $25, $17, $28)))], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[=($19, $5)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[AND(=($7, $0), OR(AND($1, $12), AND($2, $13), AND($3, $14)))], joinType=[inner], algorithm=[none], cost=[not available])
- HiveProject(ca_address_sk=[$0], IN=[IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM')], IN2=[IN($8, _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN')], IN3=[IN($8, _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV')])
- HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM', _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN', _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), =($10, _UTF-16LE'United States'), IS NOT NULL($0))])
+ HiveProject(ca_address_sk=[$0], IN=[IN($8, _UTF-16LE'KY':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'GA':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'NM':VARCHAR(2147483647) CHARACTER SET "UTF-16LE")], IN2=[IN($8, _UTF-16LE'MT':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'OR':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'IN':VARCHAR(2147483647) CHARACTER SET "UTF-16LE")], IN3=[IN($8, _UTF-16LE'WI':VARCHAR(2147483647) CHARACTER SET " [...]
+ HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'GA':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'NM':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MT':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'OR':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'IN':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'WI':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MO':VARCHAR(214 [...]
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($0, $14)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ss_sold_date_sk=[$0], ss_cdemo_sk=[$4], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_quantity=[$10], ss_ext_sales_price=[$15], ss_ext_wholesale_cost=[$16], BETWEEN=[BETWEEN(false, $22, 100:DECIMAL(12, 2), 200:DECIMAL(12, 2))], BETWEEN9=[BETWEEN(false, $22, 150:DECIMAL(12, 2), 300:DECIMAL(12, 2))], BETWEEN10=[BETWEEN(false, $22, 50:DECIMAL(12, 2), 250:DECIMAL(12, 2))], BETWEEN11=[BETWEEN(false, $13, 100:DECIMAL(3, 0), 150:DECIMAL(3, 0))], BETWEEN12=[BE [...]
@@ -130,7 +130,7 @@ HiveProject($f0=[/(CAST($0):DOUBLE, $1)], $f1=[CAST(/($2, $3)):DECIMAL(11, 6)],
HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(cd_demo_sk=[$0], ==[=($2, _UTF-16LE'M')], =2=[=($3, _UTF-16LE'4 yr Degree')], =3=[=($2, _UTF-16LE'D')], =4=[=($3, _UTF-16LE'Primary')], =5=[=($2, _UTF-16LE'U')], =6=[=($3, _UTF-16LE'Advanced Degree')])
- HiveFilter(condition=[AND(IN($2, _UTF-16LE'M', _UTF-16LE'D', _UTF-16LE'U'), IN($3, _UTF-16LE'4 yr Degree', _UTF-16LE'Primary', _UTF-16LE'Advanced Degree'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($2, _UTF-16LE'M':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'D':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'U':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IN($3, _UTF-16LE'4 yr Degree':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Primary':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Advanced Degree':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
HiveProject(hd_demo_sk=[$0], ==[=($3, 3)], =2=[=($3, 1)])
HiveFilter(condition=[AND(IN($3, 3, 1), IS NOT NULL($0))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query15.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query15.q.out
index 62dab7c..dc760a8 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query15.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query15.q.out
@@ -55,12 +55,12 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
HiveTableScan(table=[[default, customer]], table:alias=[customer])
- HiveProject(ca_address_sk=[$0], ca_zip=[$9], IN=[IN(substr($9, 1, 5), _UTF-16LE'85669', _UTF-16LE'86197', _UTF-16LE'88274', _UTF-16LE'83405', _UTF-16LE'86475', _UTF-16LE'85392', _UTF-16LE'85460', _UTF-16LE'80348', _UTF-16LE'81792')], IN3=[IN($8, _UTF-16LE'CA', _UTF-16LE'WA', _UTF-16LE'GA')])
+ HiveProject(ca_address_sk=[$0], ca_zip=[$9], IN=[IN(substr($9, 1, 5), _UTF-16LE'85669':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'86197':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'88274':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'83405':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'86475':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'85392':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'85460':VARCHAR(214748364 [...]
HiveFilter(condition=[IS NOT NULL($0)])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$1], cs_sales_price=[$2], >=[$3], d_date_sk=[$4])
HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
- HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_sales_price=[$21], >=[>($21, 500:DECIMAL(3, 0))])
+ HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_sales_price=[$21], >=[>($21, 500)])
HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
HiveProject(d_date_sk=[$0])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query16.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query16.q.out
index 1bfd9d8..2bc16ff 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query16.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query16.q.out
@@ -89,7 +89,7 @@ HiveAggregate(group=[{}], agg#0=[count(DISTINCT $4)], agg#1=[sum($5)], agg#2=[su
HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 2001-04-01 00:00:00:TIMESTAMP(9), 2001-05-31 00:00:00:TIMESTAMP(9)), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(cc_call_center_sk=[$0], cc_county=[$25])
- HiveFilter(condition=[AND(IN($25, _UTF-16LE'Ziebach County', _UTF-16LE'Levy County', _UTF-16LE'Huron County', _UTF-16LE'Franklin Parish', _UTF-16LE'Daviess County'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($25, _UTF-16LE'Ziebach County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Levy County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Huron County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Franklin Parish':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Daviess County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
HiveProject(cs_warehouse_sk=[$14], cs_order_number=[$17])
HiveFilter(condition=[AND(IS NOT NULL($14), IS NOT NULL($17))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query17.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query17.q.out
index 302b72d..a45f6e8 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query17.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query17.q.out
@@ -125,7 +125,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[
HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3), IS NOT NULL($15))])
HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
HiveProject(d_date_sk=[$0])
- HiveFilter(condition=[AND(IN($15, _UTF-16LE'2000Q1', _UTF-16LE'2000Q2', _UTF-16LE'2000Q3'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($15, _UTF-16LE'2000Q1':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'2000Q2':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'2000Q3':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$1], sr_customer_sk=[$2], sr_ticket_number=[$3], sr_return_quantity=[$4], d_date_sk=[$5])
HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
@@ -133,7 +133,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[
HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0), IS NOT NULL($2), IS NOT NULL($9))])
HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
HiveProject(d_date_sk=[$0])
- HiveFilter(condition=[AND(IN($15, _UTF-16LE'2000Q1', _UTF-16LE'2000Q2', _UTF-16LE'2000Q3'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($15, _UTF-16LE'2000Q1':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'2000Q2':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'2000Q3':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
HiveProject(s_store_sk=[$0], s_state=[$24])
HiveFilter(condition=[IS NOT NULL($0)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query18.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query18.q.out
index c848aea..90648d8 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query18.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query18.q.out
@@ -89,7 +89,7 @@ HiveSortLimit(sort0=[$1], sort1=[$2], sort2=[$3], sort3=[$0], dir0=[ASC], dir1=[
HiveFilter(condition=[AND(IN($12, 9, 5, 12, 4, 1, 10), IS NOT NULL($2), IS NOT NULL($0), IS NOT NULL($4))])
HiveTableScan(table=[[default, customer]], table:alias=[customer])
HiveProject(ca_address_sk=[$0], ca_county=[$7], ca_state=[$8], ca_country=[$10])
- HiveFilter(condition=[AND(IN($8, _UTF-16LE'ND', _UTF-16LE'WI', _UTF-16LE'AL', _UTF-16LE'NC', _UTF-16LE'OK', _UTF-16LE'MS', _UTF-16LE'TN'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($8, _UTF-16LE'ND':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'WI':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'AL':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'NC':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'OK':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MS':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'TN':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveProject(cd_demo_sk=[$0])
HiveFilter(condition=[IS NOT NULL($0)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query20.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query20.q.out
index 9aa0653..2700e6a 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query20.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query20.q.out
@@ -69,7 +69,7 @@ HiveProject(i_item_desc=[$0], i_category=[$1], i_class=[$2], i_current_price=[$3
HiveAggregate(group=[{1, 2, 3, 4, 5}], agg#0=[sum($8)])
HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_class=[$10], i_category=[$12])
- HiveFilter(condition=[AND(IN($12, _UTF-16LE'Jewelry', _UTF-16LE'Sports', _UTF-16LE'Books'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($12, _UTF-16LE'Jewelry':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Sports':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Books':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_ext_sales_price=[$23])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query21.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query21.q.out
index 3822a36..89052c6 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query21.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query21.q.out
@@ -85,6 +85,6 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-09 00:00:00:TIMESTAMP(9), 1998-05-08 00:00:00:TIMESTAMP(9)), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(i_item_sk=[$0], i_item_id=[$1])
- HiveFilter(condition=[AND(BETWEEN(false, $5, 0.99:DECIMAL(3, 2), 1.49:DECIMAL(3, 2)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(BETWEEN(false, $5, 0.99:DECIMAL(2, 2), 1.49:DECIMAL(3, 2)), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out
index a210632..3092bf4 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out
@@ -146,7 +146,7 @@ HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
HiveProject(s_store_sk=[$0], s_store_name=[$5], s_state=[$24], s_zip=[$25])
HiveFilter(condition=[AND(=($10, 7), IS NOT NULL($0), IS NOT NULL($25))])
HiveTableScan(table=[[default, store]], table:alias=[store])
- HiveProject(_o__c0=[*(0.05:DECIMAL(3, 2), CAST(/($0, $1)):DECIMAL(21, 6))])
+ HiveProject(_o__c0=[*(0.05:DECIMAL(2, 2), CAST(/($0, $1)):DECIMAL(21, 6))])
HiveFilter(condition=[IS NOT NULL(CAST(/($0, $1)):DECIMAL(21, 6))])
HiveProject($f0=[$0], $f1=[$1])
HiveAggregate(group=[{}], agg#0=[sum($10)], agg#1=[count($10)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query27.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query27.q.out
index c0f1462..e8e0432 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query27.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query27.q.out
@@ -76,6 +76,6 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(s_store_sk=[$0], s_state=[$24])
- HiveFilter(condition=[AND(IN($24, _UTF-16LE'SD', _UTF-16LE'FL', _UTF-16LE'MI', _UTF-16LE'LA', _UTF-16LE'MO', _UTF-16LE'SC'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($24, _UTF-16LE'SD':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'FL':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MI':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'LA':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MO':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'SC':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, store]], table:alias=[store])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query31.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query31.q.out
index 5fd5f94..f840da1 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query31.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query31.q.out
@@ -112,10 +112,10 @@ POSTHOOK: Input: default@web_sales
POSTHOOK: Output: hdfs://### HDFS PATH ###
CBO PLAN:
HiveProject(ca_county=[$8], d_year=[CAST(2000):INTEGER], web_q1_q2_increase=[/($6, $1)], store_q1_q2_increase=[/($9, $11)], web_q2_q3_increase=[/($4, $6)], store_q2_q3_increase=[/($13, $9)])
- HiveJoin(condition=[AND(=($8, $0), CASE(>($11, 0:DECIMAL(1, 0)), CASE($2, >(/($6, $1), /($9, $11)), false), false), CASE(>($9, 0:DECIMAL(1, 0)), CASE($7, >(/($4, $6), /($13, $9)), false), false))], joinType=[inner], algorithm=[none], cost=[not available])
+ HiveJoin(condition=[AND(=($8, $0), CASE(>($11, 0), CASE($2, >(/($6, $1), /($9, $11)), false), false), CASE(>($9, 0), CASE($7, >(/($4, $6), /($13, $9)), false), false))], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
- HiveProject($f0=[$0], $f3=[$1], >=[>($1, 0:DECIMAL(1, 0))])
+ HiveProject($f0=[$0], $f3=[$1], >=[>($1, 0)])
HiveAggregate(group=[{1}], agg#0=[sum($4)])
HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0], ca_county=[$7])
@@ -141,7 +141,7 @@ HiveProject(ca_county=[$8], d_year=[CAST(2000):INTEGER], web_q1_q2_increase=[/($
HiveProject(d_date_sk=[$0])
HiveFilter(condition=[AND(=($6, 2000), =($10, 3), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
- HiveProject($f0=[$0], $f3=[$1], >=[>($1, 0:DECIMAL(1, 0))])
+ HiveProject($f0=[$0], $f3=[$1], >=[>($1, 0)])
HiveAggregate(group=[{1}], agg#0=[sum($4)])
HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0], ca_county=[$7])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query33.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query33.q.out
index 8419b70..ad831bf 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query33.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query33.q.out
@@ -180,7 +180,7 @@ HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
HiveProject(ca_address_sk=[$0], ss_sold_date_sk=[$1], ss_item_sk=[$2], ss_addr_sk=[$3], ss_ext_sales_price=[$4], d_date_sk=[$5])
HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -6:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
@@ -203,7 +203,7 @@ HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
HiveProject(ca_address_sk=[$0], cs_sold_date_sk=[$1], cs_bill_addr_sk=[$2], cs_item_sk=[$3], cs_ext_sales_price=[$4], d_date_sk=[$5])
HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -6:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(cs_sold_date_sk=[$0], cs_bill_addr_sk=[$6], cs_item_sk=[$15], cs_ext_sales_price=[$23])
@@ -226,7 +226,7 @@ HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
HiveProject(ca_address_sk=[$0], ws_sold_date_sk=[$1], ws_item_sk=[$2], ws_bill_addr_sk=[$3], ws_ext_sales_price=[$4], d_date_sk=[$5])
HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -6:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query34.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query34.q.out
index 817b82f..7282006 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query34.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query34.q.out
@@ -91,9 +91,9 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], dir0=[ASC], dir1=[
HiveFilter(condition=[AND(IN($6, 2000, 2001, 2002), OR(BETWEEN(false, $9, 1, 3), BETWEEN(false, $9, 25, 28)), OR(<=(1, $9), <=($9, 3), <=(25, $9), <=($9, 28)), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(hd_demo_sk=[$0])
- HiveFilter(condition=[AND(>($4, 0), CASE(>($4, 0), >(/(CAST($3):DOUBLE, CAST($4):DOUBLE), 1.2), false), IN($2, _UTF-16LE'>10000', _UTF-16LE'unknown'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(>($4, 0), CASE(>($4, 0), >(/(CAST($3):DOUBLE, CAST($4):DOUBLE), 1.2), false), IN($2, _UTF-16LE'>10000':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'unknown':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
HiveProject(s_store_sk=[$0])
- HiveFilter(condition=[AND(IN($23, _UTF-16LE'Mobile County', _UTF-16LE'Maverick County', _UTF-16LE'Huron County', _UTF-16LE'Kittitas County', _UTF-16LE'Fairfield County', _UTF-16LE'Jackson County', _UTF-16LE'Barrow County', _UTF-16LE'Pennington County'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($23, _UTF-16LE'Mobile County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Maverick County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Huron County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Kittitas County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Fairfield County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Jackson County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16 [...]
HiveTableScan(table=[[default, store]], table:alias=[store])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out
index c2a11d5..3f152fd 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out
@@ -83,7 +83,7 @@ HiveProject(gross_margin=[$0], i_category=[$1], i_class=[$2], lochierarchy=[$3],
HiveFilter(condition=[AND(=($6, 1999), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
HiveProject(s_store_sk=[$0])
- HiveFilter(condition=[AND(IN($24, _UTF-16LE'SD', _UTF-16LE'FL', _UTF-16LE'MI', _UTF-16LE'LA', _UTF-16LE'MO', _UTF-16LE'SC', _UTF-16LE'AL', _UTF-16LE'GA'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($24, _UTF-16LE'SD':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'FL':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MI':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'LA':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MO':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'SC':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'AL':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'GA':VARCHA [...]
HiveTableScan(table=[[default, store]], table:alias=[store])
HiveProject(i_item_sk=[$0], i_class=[$10], i_category=[$12])
HiveFilter(condition=[IS NOT NULL($0)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query37.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query37.q.out
index 2b553a7..35ba509 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query37.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query37.q.out
@@ -50,7 +50,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveFilter(condition=[IS NOT NULL($15)])
HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5])
- HiveFilter(condition=[AND(BETWEEN(false, $5, 22:DECIMAL(12, 2), 52:DECIMAL(2, 0)), IN($13, 678, 964, 918, 849), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($13, 678, 964, 918, 849), BETWEEN(false, $5, 22:DECIMAL(12, 2), 52:DECIMAL(2, 0)), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], d_date_sk=[$2])
HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query4.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query4.q.out
index 7b01a6e..a35db69 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query4.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query4.q.out
@@ -274,7 +274,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject($f0=[$0], $f8=[$7])
- HiveFilter(condition=[>($7, 0:DECIMAL(1, 0))])
+ HiveFilter(condition=[>($7, 0)])
HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
@@ -288,7 +288,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(customer_id=[$0], year_total=[$7], CAST=[CAST(IS NOT NULL($7)):BOOLEAN])
- HiveFilter(condition=[>($7, 0:DECIMAL(1, 0))])
+ HiveFilter(condition=[>($7, 0)])
HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
@@ -302,7 +302,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(customer_id=[$0], year_total=[$7], CAST=[CAST(IS NOT NULL($7)):BOOLEAN])
- HiveFilter(condition=[>($7, 0:DECIMAL(1, 0))])
+ HiveFilter(condition=[>($7, 0)])
HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out
index 312ac30..b5e2776 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out
@@ -86,6 +86,6 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-09 00:00:00:TIMESTAMP(9), 1998-05-08 00:00:00:TIMESTAMP(9)), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(i_item_sk=[$0], i_item_id=[$1])
- HiveFilter(condition=[AND(BETWEEN(false, $5, 0.99:DECIMAL(3, 2), 1.49:DECIMAL(3, 2)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(BETWEEN(false, $5, 0.99:DECIMAL(2, 2), 1.49:DECIMAL(3, 2)), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out
index d017e2c..e82afba 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out
@@ -56,6 +56,6 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=
HiveFilter(condition=[AND(=($6, 1998), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(s_store_sk=[$0], s_store_id=[$1], s_store_name=[$5])
- HiveFilter(condition=[AND(=($27, -6:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($27, -6), IS NOT NULL($0))])
HiveTableScan(table=[[default, store]], table:alias=[store])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query46.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query46.q.out
index a7491f5..2360931 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query46.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query46.q.out
@@ -107,7 +107,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], dir0=[
HiveFilter(condition=[AND(IN($6, 1998, 1999, 2000), IN($7, 6, 0), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(s_store_sk=[$0])
- HiveFilter(condition=[AND(IN($22, _UTF-16LE'Cedar Grove', _UTF-16LE'Wildwood', _UTF-16LE'Union', _UTF-16LE'Salem', _UTF-16LE'Highland Park'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($22, _UTF-16LE'Cedar Grove':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Wildwood':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Union':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Salem':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Highland Park':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, store]], table:alias=[store])
HiveProject(hd_demo_sk=[$0])
HiveFilter(condition=[AND(OR(=($3, 2), =($4, 1)), IS NOT NULL($0))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query47.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query47.q.out
index 60d80e0..c706a7d 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query47.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query47.q.out
@@ -155,7 +155,7 @@ HiveProject(i_category=[$0], d_year=[$1], d_moy=[$2], avg_monthly_sales=[$3], su
HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($5), IS NOT NULL($17))])
HiveTableScan(table=[[default, store]], table:alias=[store])
HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col s_store_name)=[$2], (tok_table_or_col s_company_name)=[$3], (tok_table_or_col d_year)=[$4], (tok_table_or_col d_moy)=[$5], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], avg_window_0=[$7], rank_window_1=[$8])
- HiveFilter(condition=[AND(=($4, 2000), >($7, 0:DECIMAL(1, 0)), CASE(>($7, 0:DECIMAL(1, 0)), >(/(ABS(-($6, $7)), $7), 0.1:DECIMAL(2, 1)), false), IS NOT NULL($8))])
+ HiveFilter(condition=[AND(=($4, 2000), >($7, 0), CASE(>($7, 0), >(/(ABS(-($6, $7)), $7), 0.1:DECIMAL(1, 1)), false), IS NOT NULL($8))])
HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col s_store_name)=[$4], (tok_table_or_col s_company_name)=[$5], (tok_table_or_col d_year)=[$2], (tok_table_or_col d_moy)=[$3], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], avg_window_0=[avg($6) OVER (PARTITION BY $1, $0, $4, $5, $2 ORDER BY $1 NULLS FIRST, $0 NULLS FIRST, $4 NULLS FIRST, $5 NULLS FIRST, $2 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 [...]
HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], s_store_name=[$4], s_company_name=[$5], $f6=[$6])
HiveAggregate(group=[{1, 2, 8, 9, 11, 12}], agg#0=[sum($6)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query48.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query48.q.out
index 97c9f47..5749c88 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query48.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query48.q.out
@@ -147,8 +147,8 @@ HiveAggregate(group=[{}], agg#0=[sum($10)])
HiveFilter(condition=[IS NOT NULL($0)])
HiveTableScan(table=[[default, store]], table:alias=[store])
HiveJoin(condition=[AND(=($7, $0), OR(AND($1, $10), AND($2, $11), AND($3, $12)))], joinType=[inner], algorithm=[none], cost=[not available])
- HiveProject(ca_address_sk=[$0], IN=[IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM')], IN2=[IN($8, _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN')], IN3=[IN($8, _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV')])
- HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM', _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN', _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), =($10, _UTF-16LE'United States'), IS NOT NULL($0))])
+ HiveProject(ca_address_sk=[$0], IN=[IN($8, _UTF-16LE'KY':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'GA':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'NM':VARCHAR(2147483647) CHARACTER SET "UTF-16LE")], IN2=[IN($8, _UTF-16LE'MT':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'OR':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'IN':VARCHAR(2147483647) CHARACTER SET "UTF-16LE")], IN3=[IN($8, _UTF-16LE'WI':VARCHAR(2147483647) CHARACTER SET "UTF-16 [...]
+ HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'GA':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'NM':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MT':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'OR':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'IN':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'WI':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MO':VARCHAR(214748364 [...]
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(cd_demo_sk=[$0])
@@ -156,7 +156,7 @@ HiveAggregate(group=[{}], agg#0=[sum($10)])
HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ss_sold_date_sk=[$0], ss_cdemo_sk=[$4], ss_addr_sk=[$6], ss_store_sk=[$7], ss_quantity=[$10], BETWEEN=[BETWEEN(false, $22, 0:DECIMAL(12, 2), 2000:DECIMAL(12, 2))], BETWEEN6=[BETWEEN(false, $22, 150:DECIMAL(12, 2), 3000:DECIMAL(12, 2))], BETWEEN7=[BETWEEN(false, $22, 50:DECIMAL(12, 2), 25000:DECIMAL(12, 2))])
- HiveFilter(condition=[AND(OR(BETWEEN(false, $13, 100:DECIMAL(3, 0), 150:DECIMAL(3, 0)), BETWEEN(false, $13, 50:DECIMAL(2, 0), 100:DECIMAL(3, 0)), BETWEEN(false, $13, 150:DECIMAL(3, 0), 200:DECIMAL(3, 0))), IS NOT NULL($4), IS NOT NULL($0), IS NOT NULL($6), IS NOT NULL($7), OR(<=(100:DECIMAL(3, 0), $13), <=($13, 150:DECIMAL(3, 0)), <=(50:DECIMAL(2, 0), $13), <=($13, 100:DECIMAL(3, 0)), <=(150:DECIMAL(3, 0), $13), <=($13, 200:DECIMAL(3, 0))), OR(<=(0:DECIMAL(12, 2), $22), <=($2 [...]
+ HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0), IS NOT NULL($6), IS NOT NULL($7), OR(BETWEEN(false, $13, 100:DECIMAL(3, 0), 150:DECIMAL(3, 0)), BETWEEN(false, $13, 50:DECIMAL(2, 0), 100:DECIMAL(3, 0)), BETWEEN(false, $13, 150:DECIMAL(3, 0), 200:DECIMAL(3, 0))), OR(<=(100:DECIMAL(3, 0), $13), <=($13, 150:DECIMAL(3, 0)), <=(50:DECIMAL(2, 0), $13), <=($13, 100:DECIMAL(3, 0)), <=(150:DECIMAL(3, 0), $13), <=($13, 200:DECIMAL(3, 0))), OR(<=(0:DECIMAL(12, 2), $22), <=($2 [...]
HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
HiveProject(d_date_sk=[$0])
HiveFilter(condition=[AND(=($6, 1998), IS NOT NULL($0))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out
index 99569a8..7de6c1f 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out
@@ -283,11 +283,11 @@ HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$4], dir0=[ASC], dir1=[ASC], dir2=[
HiveAggregate(group=[{5}], agg#0=[sum($2)], agg#1=[sum($7)], agg#2=[sum($3)], agg#3=[sum($8)])
HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(wr_item_sk=[$2], wr_order_number=[$13], CASE=[CASE(IS NOT NULL($14), $14, 0)], CASE3=[CASE(IS NOT NULL($15), $15, 0:DECIMAL(12, 2))])
- HiveFilter(condition=[AND(>($15, 10000:DECIMAL(5, 0)), IS NOT NULL($13), IS NOT NULL($2))])
+ HiveFilter(condition=[AND(>($15, 10000), IS NOT NULL($13), IS NOT NULL($2))])
HiveTableScan(table=[[default, web_returns]], table:alias=[wr])
HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_order_number=[$17], CASE=[CASE(IS NOT NULL($18), $18, 0)], CASE4=[CASE(IS NOT NULL($29), $29, 0:DECIMAL(12, 2))])
- HiveFilter(condition=[AND(>($33, 1:DECIMAL(1, 0)), >($29, 0:DECIMAL(1, 0)), >($18, 0), IS NOT NULL($0), IS NOT NULL($17), IS NOT NULL($3))])
+ HiveFilter(condition=[AND(>($18, 0), >($33, 1), >($29, 0), IS NOT NULL($0), IS NOT NULL($17), IS NOT NULL($3))])
HiveTableScan(table=[[default, web_sales]], table:alias=[ws])
HiveProject(d_date_sk=[$0])
HiveFilter(condition=[AND(=($6, 2000), =($8, 12), IS NOT NULL($0))])
@@ -299,11 +299,11 @@ HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$4], dir0=[ASC], dir1=[ASC], dir2=[
HiveAggregate(group=[{5}], agg#0=[sum($2)], agg#1=[sum($7)], agg#2=[sum($3)], agg#3=[sum($8)])
HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(cr_item_sk=[$2], cr_order_number=[$16], CASE=[CASE(IS NOT NULL($17), $17, 0)], CASE3=[CASE(IS NOT NULL($18), $18, 0:DECIMAL(12, 2))])
- HiveFilter(condition=[AND(>($18, 10000:DECIMAL(5, 0)), IS NOT NULL($16), IS NOT NULL($2))])
+ HiveFilter(condition=[AND(>($18, 10000), IS NOT NULL($16), IS NOT NULL($2))])
HiveTableScan(table=[[default, catalog_returns]], table:alias=[cr])
HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_order_number=[$17], CASE=[CASE(IS NOT NULL($18), $18, 0)], CASE4=[CASE(IS NOT NULL($29), $29, 0:DECIMAL(12, 2))])
- HiveFilter(condition=[AND(>($33, 1:DECIMAL(1, 0)), >($29, 0:DECIMAL(1, 0)), >($18, 0), IS NOT NULL($0), IS NOT NULL($17), IS NOT NULL($15))])
+ HiveFilter(condition=[AND(>($18, 0), >($33, 1), >($29, 0), IS NOT NULL($0), IS NOT NULL($17), IS NOT NULL($15))])
HiveTableScan(table=[[default, catalog_sales]], table:alias=[cs])
HiveProject(d_date_sk=[$0])
HiveFilter(condition=[AND(=($6, 2000), =($8, 12), IS NOT NULL($0))])
@@ -315,11 +315,11 @@ HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$4], dir0=[ASC], dir1=[ASC], dir2=[
HiveAggregate(group=[{5}], agg#0=[sum($2)], agg#1=[sum($7)], agg#2=[sum($3)], agg#3=[sum($8)])
HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], CASE=[CASE(IS NOT NULL($10), $10, 0)], CASE3=[CASE(IS NOT NULL($11), $11, 0:DECIMAL(12, 2))])
- HiveFilter(condition=[AND(>($11, 10000:DECIMAL(5, 0)), IS NOT NULL($9), IS NOT NULL($2))])
+ HiveFilter(condition=[AND(>($11, 10000), IS NOT NULL($9), IS NOT NULL($2))])
HiveTableScan(table=[[default, store_returns]], table:alias=[sr])
HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ticket_number=[$9], CASE=[CASE(IS NOT NULL($10), $10, 0)], CASE4=[CASE(IS NOT NULL($20), $20, 0:DECIMAL(12, 2))])
- HiveFilter(condition=[AND(>($22, 1:DECIMAL(1, 0)), >($20, 0:DECIMAL(1, 0)), >($10, 0), IS NOT NULL($0), IS NOT NULL($9), IS NOT NULL($2))])
+ HiveFilter(condition=[AND(>($10, 0), >($22, 1), >($20, 0), IS NOT NULL($0), IS NOT NULL($9), IS NOT NULL($2))])
HiveTableScan(table=[[default, store_sales]], table:alias=[sts])
HiveProject(d_date_sk=[$0])
HiveFilter(condition=[AND(=($6, 2000), =($8, 12), IS NOT NULL($0))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query53.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query53.q.out
index a440eb2..6e2aecf 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query53.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query53.q.out
@@ -65,7 +65,7 @@ POSTHOOK: Output: hdfs://### HDFS PATH ###
CBO PLAN:
HiveSortLimit(sort0=[$2], sort1=[$1], sort2=[$0], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
HiveProject((tok_table_or_col i_manufact_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$1], avg_window_0=[$2])
- HiveFilter(condition=[CASE(>($2, 0:DECIMAL(1, 0)), >(/(ABS(-($1, $2)), $2), 0.1:DECIMAL(2, 1)), false)])
+ HiveFilter(condition=[CASE(>($2, 0), >(/(ABS(-($1, $2)), $2), 0.1:DECIMAL(1, 1)), false)])
HiveProject((tok_table_or_col i_manufact_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$2], avg_window_0=[avg($2) OVER (PARTITION BY $0 ORDER BY $0 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
HiveProject(i_manufact_id=[$0], d_qoy=[$1], $f2=[$2])
HiveAggregate(group=[{6, 8}], agg#0=[sum($4)])
@@ -79,7 +79,7 @@ HiveSortLimit(sort0=[$2], sort1=[$1], sort2=[$0], dir0=[ASC], dir1=[ASC], dir2=[
HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($2))])
HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
HiveProject(i_item_sk=[$0], i_manufact_id=[$13])
- HiveFilter(condition=[AND(IN($10, _UTF-16LE'personal', _UTF-16LE'portable', _UTF-16LE'reference', _UTF-16LE'self-help', _UTF-16LE'accessories', _UTF-16LE'classical', _UTF-16LE'fragrances', _UTF-16LE'pants'), IN($8, _UTF-16LE'scholaramalgamalg #14', _UTF-16LE'scholaramalgamalg #7', _UTF-16LE'exportiunivamalg #9', _UTF-16LE'scholaramalgamalg #9', _UTF-16LE'amalgimporto #1', _UTF-16LE'edu packscholar #1', _UTF-16LE'exportiimporto #1', _UTF-16LE'importoamalg #1'), IN($12, [...]
+ HiveFilter(condition=[AND(IN($10, _UTF-16LE'personal':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'portable':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'reference':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'self-help':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'accessories':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'classical':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'fragrances':VARCHAR(214748 [...]
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(d_date_sk=[$0], d_qoy=[$10])
HiveFilter(condition=[AND(IN($3, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223), IS NOT NULL($0))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query56.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query56.q.out
index 8a3780b..54f4843 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query56.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query56.q.out
@@ -161,12 +161,12 @@ HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(i_item_id=[$0])
HiveAggregate(group=[{1}])
- HiveFilter(condition=[AND(IN($17, _UTF-16LE'orchid', _UTF-16LE'chiffon', _UTF-16LE'lace'), IS NOT NULL($1))])
+ HiveFilter(condition=[AND(IN($17, _UTF-16LE'orchid':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'chiffon':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'lace':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($1))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(ca_address_sk=[$0], ss_sold_date_sk=[$1], ss_item_sk=[$2], ss_addr_sk=[$3], ss_ext_sales_price=[$4], d_date_sk=[$5])
HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -8:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -8), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
@@ -184,12 +184,12 @@ HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(i_item_id=[$0])
HiveAggregate(group=[{1}])
- HiveFilter(condition=[AND(IN($17, _UTF-16LE'orchid', _UTF-16LE'chiffon', _UTF-16LE'lace'), IS NOT NULL($1))])
+ HiveFilter(condition=[AND(IN($17, _UTF-16LE'orchid':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'chiffon':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'lace':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($1))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(ca_address_sk=[$0], cs_sold_date_sk=[$1], cs_bill_addr_sk=[$2], cs_item_sk=[$3], cs_ext_sales_price=[$4], d_date_sk=[$5])
HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -8:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -8), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(cs_sold_date_sk=[$0], cs_bill_addr_sk=[$6], cs_item_sk=[$15], cs_ext_sales_price=[$23])
@@ -207,12 +207,12 @@ HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(i_item_id=[$0])
HiveAggregate(group=[{1}])
- HiveFilter(condition=[AND(IN($17, _UTF-16LE'orchid', _UTF-16LE'chiffon', _UTF-16LE'lace'), IS NOT NULL($1))])
+ HiveFilter(condition=[AND(IN($17, _UTF-16LE'orchid':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'chiffon':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'lace':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($1))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(ca_address_sk=[$0], ws_sold_date_sk=[$1], ws_item_sk=[$2], ws_bill_addr_sk=[$3], ws_ext_sales_price=[$4], d_date_sk=[$5])
HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -8:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -8), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query57.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query57.q.out
index f0dd0f2..1504116 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query57.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query57.q.out
@@ -149,7 +149,7 @@ HiveProject(i_category=[$0], i_brand=[$1], d_year=[$2], d_moy=[$3], avg_monthly_
HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col cc_name)=[$2], (tok_table_or_col d_year)=[$3], (tok_table_or_col d_moy)=[$4], (tok_function sum (tok_table_or_col cs_sales_price))=[$5], avg_window_0=[$6], rank_window_1=[$7])
- HiveFilter(condition=[AND(=($3, 2000), >($6, 0:DECIMAL(1, 0)), CASE(>($6, 0:DECIMAL(1, 0)), >(/(ABS(-($5, $6)), $6), 0.1:DECIMAL(2, 1)), false), IS NOT NULL($7))])
+ HiveFilter(condition=[AND(=($3, 2000), >($6, 0), CASE(>($6, 0), >(/(ABS(-($5, $6)), $6), 0.1:DECIMAL(1, 1)), false), IS NOT NULL($7))])
HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col cc_name)=[$4], (tok_table_or_col d_year)=[$2], (tok_table_or_col d_moy)=[$3], (tok_function sum (tok_table_or_col cs_sales_price))=[$5], avg_window_0=[avg($5) OVER (PARTITION BY $1, $0, $4, $2 ORDER BY $1 NULLS FIRST, $0 NULLS FIRST, $4 NULLS FIRST, $2 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4 [...]
HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], cc_name=[$4], $f5=[$5])
HiveAggregate(group=[{1, 2, 8, 9, 11}], agg#0=[sum($6)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query58.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query58.q.out
index 52e9e79..935d130 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query58.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query58.q.out
@@ -144,7 +144,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveProject(item_id=[$0], ss_item_rev=[$5], ss_dev=[*(/(/($5, +(+($5, $1), $9)), 3:DECIMAL(10, 0)), 100:DECIMAL(10, 0))], cs_item_rev=[$1], cs_dev=[*(/(/($1, +(+($5, $1), $9)), 3:DECIMAL(10, 0)), 100:DECIMAL(10, 0))], ws_item_rev=[$9], ws_dev=[*(/(/($9, +(+($5, $1), $9)), 3:DECIMAL(10, 0)), 100:DECIMAL(10, 0))], average=[/(+(+($5, $1), $9), 3:DECIMAL(10, 0))])
HiveJoin(condition=[AND(=($0, $8), BETWEEN(false, $5, $10, $11), BETWEEN(false, $1, $10, $11), BETWEEN(false, $9, $6, $7), BETWEEN(false, $9, $2, $3))], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[AND(=($4, $0), BETWEEN(false, $5, $2, $3), BETWEEN(false, $1, $6, $7))], joinType=[inner], algorithm=[none], cost=[not available])
- HiveProject($f0=[$0], $f1=[$1], *=[*(0.9:DECIMAL(2, 1), $1)], *3=[*(1.1:DECIMAL(2, 1), $1)])
+ HiveProject($f0=[$0], $f1=[$1], *=[*(0.9:DECIMAL(1, 1), $1)], *3=[*(1.1:DECIMAL(2, 1), $1)])
HiveAggregate(group=[{4}], agg#0=[sum($2)])
HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
@@ -175,7 +175,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveProject(d_week_seq=[$4])
HiveFilter(condition=[AND(=($2, _UTF-16LE'1998-02-19'), IS NOT NULL($4))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
- HiveProject($f0=[$0], $f1=[$1], *=[*(0.9:DECIMAL(2, 1), $1)], *3=[*(1.1:DECIMAL(2, 1), $1)])
+ HiveProject($f0=[$0], $f1=[$1], *=[*(0.9:DECIMAL(1, 1), $1)], *3=[*(1.1:DECIMAL(2, 1), $1)])
HiveAggregate(group=[{4}], agg#0=[sum($2)])
HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
@@ -206,7 +206,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveProject(d_week_seq=[$4])
HiveFilter(condition=[AND(=($2, _UTF-16LE'1998-02-19'), IS NOT NULL($4))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
- HiveProject($f0=[$0], $f1=[$1], *=[*(0.9:DECIMAL(2, 1), $1)], *3=[*(1.1:DECIMAL(2, 1), $1)])
+ HiveProject($f0=[$0], $f1=[$1], *=[*(0.9:DECIMAL(1, 1), $1)], *3=[*(1.1:DECIMAL(2, 1), $1)])
HiveAggregate(group=[{4}], agg#0=[sum($2)])
HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query60.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query60.q.out
index 8802220..986c28e 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query60.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query60.q.out
@@ -186,7 +186,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveProject(ca_address_sk=[$0], ss_sold_date_sk=[$1], ss_item_sk=[$2], ss_addr_sk=[$3], ss_ext_sales_price=[$4], d_date_sk=[$5])
HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -6:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
@@ -209,7 +209,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveProject(ca_address_sk=[$0], cs_sold_date_sk=[$1], cs_bill_addr_sk=[$2], cs_item_sk=[$3], cs_ext_sales_price=[$4], d_date_sk=[$5])
HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -6:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(cs_sold_date_sk=[$0], cs_bill_addr_sk=[$6], cs_item_sk=[$15], cs_ext_sales_price=[$23])
@@ -232,7 +232,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveProject(ca_address_sk=[$0], ws_sold_date_sk=[$1], ws_item_sk=[$2], ws_bill_addr_sk=[$3], ws_ext_sales_price=[$4], d_date_sk=[$5])
HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -6:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query61.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query61.q.out
index eec4847..921432c 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query61.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query61.q.out
@@ -112,7 +112,7 @@ HiveProject(promotions=[$0], total=[$1], _o__c2=[*(/(CAST($0):DECIMAL(15, 4), CA
HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
HiveTableScan(table=[[default, customer]], table:alias=[customer])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -7:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -7), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$1], ss_customer_sk=[$2], ss_store_sk=[$3], ss_promo_sk=[$4], ss_ext_sales_price=[$5], d_date_sk=[$6], i_item_sk=[$7], s_store_sk=[$8], p_promo_sk=[$9])
HiveJoin(condition=[=($4, $9)], joinType=[inner], algorithm=[none], cost=[not available])
@@ -129,7 +129,7 @@ HiveProject(promotions=[$0], total=[$1], _o__c2=[*(/(CAST($0):DECIMAL(15, 4), CA
HiveFilter(condition=[AND(=($12, _UTF-16LE'Electronics'), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(s_store_sk=[$0])
- HiveFilter(condition=[AND(=($27, -7:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($27, -7), IS NOT NULL($0))])
HiveTableScan(table=[[default, store]], table:alias=[store])
HiveProject(p_promo_sk=[$0])
HiveFilter(condition=[AND(OR(=($8, _UTF-16LE'Y'), =($9, _UTF-16LE'Y'), =($11, _UTF-16LE'Y')), IS NOT NULL($0))])
@@ -142,7 +142,7 @@ HiveProject(promotions=[$0], total=[$1], _o__c2=[*(/(CAST($0):DECIMAL(15, 4), CA
HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
HiveTableScan(table=[[default, customer]], table:alias=[customer])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -7:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -7), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$1], ss_customer_sk=[$2], ss_store_sk=[$3], ss_ext_sales_price=[$4], d_date_sk=[$5], i_item_sk=[$6], s_store_sk=[$7])
HiveJoin(condition=[=($3, $7)], joinType=[inner], algorithm=[none], cost=[not available])
@@ -158,6 +158,6 @@ HiveProject(promotions=[$0], total=[$1], _o__c2=[*(/(CAST($0):DECIMAL(15, 4), CA
HiveFilter(condition=[AND(=($12, _UTF-16LE'Electronics'), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(s_store_sk=[$0])
- HiveFilter(condition=[AND(=($27, -7:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($27, -7), IS NOT NULL($0))])
HiveTableScan(table=[[default, store]], table:alias=[store])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query63.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query63.q.out
index 3535115..ca3fe80 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query63.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query63.q.out
@@ -67,7 +67,7 @@ POSTHOOK: Output: hdfs://### HDFS PATH ###
CBO PLAN:
HiveSortLimit(sort0=[$0], sort1=[$2], sort2=[$1], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
HiveProject((tok_table_or_col i_manager_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$1], avg_window_0=[$2])
- HiveFilter(condition=[CASE(>($2, 0:DECIMAL(1, 0)), >(/(ABS(-($1, $2)), $2), 0.1:DECIMAL(2, 1)), false)])
+ HiveFilter(condition=[CASE(>($2, 0), >(/(ABS(-($1, $2)), $2), 0.1:DECIMAL(1, 1)), false)])
HiveProject((tok_table_or_col i_manager_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$2], avg_window_0=[avg($2) OVER (PARTITION BY $0 ORDER BY $0 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
HiveProject(i_manager_id=[$0], d_moy=[$1], $f2=[$2])
HiveAggregate(group=[{6, 8}], agg#0=[sum($4)])
@@ -81,7 +81,7 @@ HiveSortLimit(sort0=[$0], sort1=[$2], sort2=[$1], dir0=[ASC], dir1=[ASC], dir2=[
HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($2))])
HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
HiveProject(i_item_sk=[$0], i_manager_id=[$20])
- HiveFilter(condition=[AND(IN($10, _UTF-16LE'personal', _UTF-16LE'portable', _UTF-16LE'refernece', _UTF-16LE'self-help', _UTF-16LE'accessories', _UTF-16LE'classical', _UTF-16LE'fragrances', _UTF-16LE'pants'), IN($8, _UTF-16LE'scholaramalgamalg #14', _UTF-16LE'scholaramalgamalg #7', _UTF-16LE'exportiunivamalg #9', _UTF-16LE'scholaramalgamalg #9', _UTF-16LE'amalgimporto #1', _UTF-16LE'edu packscholar #1', _UTF-16LE'exportiimporto #1', _UTF-16LE'importoamalg #1'), IN($12, [...]
+ HiveFilter(condition=[AND(IN($10, _UTF-16LE'personal':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'portable':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'refernece':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'self-help':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'accessories':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'classical':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'fragrances':VARCHAR(214748 [...]
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(d_date_sk=[$0], d_moy=[$8])
HiveFilter(condition=[AND(IN($3, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223), IS NOT NULL($0))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query64.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query64.q.out
index 35b5275..2ce1b12 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query64.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query64.q.out
@@ -333,7 +333,7 @@ HiveProject(product_name=[$0], store_name=[$1], store_zip=[$2], b_street_number=
HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0), IS NOT NULL($8), IS NOT NULL($6), IS NOT NULL($3), IS NOT NULL($5), IS NOT NULL($7), IS NOT NULL($2), IS NOT NULL($9))])
HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
HiveProject(i_item_sk=[$0], i_product_name=[$21])
- HiveFilter(condition=[AND(BETWEEN(false, $5, 36:DECIMAL(2, 0), 45:DECIMAL(2, 0)), IN($17, _UTF-16LE'maroon', _UTF-16LE'burnished', _UTF-16LE'dim', _UTF-16LE'steel', _UTF-16LE'navajo', _UTF-16LE'chocolate'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(BETWEEN(false, $5, 36:DECIMAL(2, 0), 45:DECIMAL(2, 0)), IN($17, _UTF-16LE'maroon':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'burnished':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'dim':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'steel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'navajo':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'chocolate':VARCHAR(2147483647) [...]
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(d_date_sk=[$0])
HiveFilter(condition=[AND(=($6, 2000), IS NOT NULL($0))])
@@ -417,7 +417,7 @@ HiveProject(product_name=[$0], store_name=[$1], store_zip=[$2], b_street_number=
HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0), IS NOT NULL($8), IS NOT NULL($6), IS NOT NULL($3), IS NOT NULL($5), IS NOT NULL($7), IS NOT NULL($2), IS NOT NULL($9))])
HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
HiveProject(i_item_sk=[$0], i_product_name=[$21])
- HiveFilter(condition=[AND(BETWEEN(false, $5, 36:DECIMAL(2, 0), 45:DECIMAL(2, 0)), IN($17, _UTF-16LE'maroon', _UTF-16LE'burnished', _UTF-16LE'dim', _UTF-16LE'steel', _UTF-16LE'navajo', _UTF-16LE'chocolate'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(BETWEEN(false, $5, 36:DECIMAL(2, 0), 45:DECIMAL(2, 0)), IN($17, _UTF-16LE'maroon':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'burnished':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'dim':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'steel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'navajo':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'chocolate':VARCHAR(2147483647) [...]
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(d_date_sk=[$0])
HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query65.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query65.q.out
index ef48ec3..c376328 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query65.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query65.q.out
@@ -87,7 +87,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveProject(d_date_sk=[$0])
HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
- HiveProject($f0=[$0], *=[*(0.1:DECIMAL(2, 1), CAST(/($1, $2)):DECIMAL(21, 6))])
+ HiveProject($f0=[$0], *=[*(0.1:DECIMAL(1, 1), CAST(/($1, $2)):DECIMAL(21, 6))])
HiveFilter(condition=[IS NOT NULL(CAST(/($1, $2)):DECIMAL(21, 6))])
HiveAggregate(group=[{1}], agg#0=[sum($2)], agg#1=[count($2)])
HiveProject(ss_item_sk=[$0], ss_store_sk=[$1], $f2=[$2])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out
index 3255a9f..2f3ce4a 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out
@@ -481,7 +481,7 @@ HiveProject(w_warehouse_name=[$0], w_warehouse_sq_ft=[$1], w_city=[$2], w_county
HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(sm_ship_mode_sk=[$0])
- HiveFilter(condition=[AND(IN($4, _UTF-16LE'DIAMOND', _UTF-16LE'AIRBORNE'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($4, _UTF-16LE'DIAMOND':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'AIRBORNE':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, ship_mode]], table:alias=[ship_mode])
HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14], $f15=[$15], $f16=[$16], $f17=[$17], $f18=[$18], $f19=[$19], $f20=[$20], $f21=[$21], $f22=[$22], $f23=[$23], $f24=[$24], $f25=[$25], $f26=[$26], $f27=[$27], $f28=[$28], $f29=[$29])
HiveAggregate(group=[{0, 1, 2, 3, 4, 5}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)], agg#3=[sum($9)], agg#4=[sum($10)], agg#5=[sum($11)], agg#6=[sum($12)], agg#7=[sum($13)], agg#8=[sum($14)], agg#9=[sum($15)], agg#10=[sum($16)], agg#11=[sum($17)], agg#12=[sum($18)], agg#13=[sum($19)], agg#14=[sum($20)], agg#15=[sum($21)], agg#16=[sum($22)], agg#17=[sum($23)], agg#18=[sum($24)], agg#19=[sum($25)], agg#20=[sum($26)], agg#21=[sum($27)], agg#22=[sum($28)], agg#23=[sum($29)])
@@ -500,7 +500,7 @@ HiveProject(w_warehouse_name=[$0], w_warehouse_sq_ft=[$1], w_city=[$2], w_county
HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(sm_ship_mode_sk=[$0])
- HiveFilter(condition=[AND(IN($4, _UTF-16LE'DIAMOND', _UTF-16LE'AIRBORNE'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($4, _UTF-16LE'DIAMOND':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'AIRBORNE':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, ship_mode]], table:alias=[ship_mode])
HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2], w_warehouse_sq_ft=[$3], w_city=[$8], w_county=[$9], w_state=[$10], w_country=[$12])
HiveFilter(condition=[IS NOT NULL($0)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query68.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query68.q.out
index 6032192..887a6d6 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query68.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query68.q.out
@@ -121,7 +121,7 @@ HiveSortLimit(sort0=[$0], sort1=[$4], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveFilter(condition=[AND(BETWEEN(false, $9, 1, 2), IN($6, 1998, 1999, 2000), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(s_store_sk=[$0])
- HiveFilter(condition=[AND(IN($22, _UTF-16LE'Cedar Grove', _UTF-16LE'Wildwood'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($22, _UTF-16LE'Cedar Grove':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Wildwood':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, store]], table:alias=[store])
HiveProject(hd_demo_sk=[$0])
HiveFilter(condition=[AND(OR(=($3, 2), =($4, 1)), IS NOT NULL($0))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query69.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query69.q.out
index 4e617f9..e114e34 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query69.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query69.q.out
@@ -122,7 +122,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$4], sort4=[$6], dir0=[
HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($4), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer]], table:alias=[c])
HiveProject(ca_address_sk=[$0], ca_state=[$8])
- HiveFilter(condition=[AND(IN($8, _UTF-16LE'CO', _UTF-16LE'IL', _UTF-16LE'MN'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($8, _UTF-16LE'CO':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'IL':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MN':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[ca])
HiveProject(cd_demo_sk=[$0], cd_gender=[$1], cd_marital_status=[$2], cd_education_status=[$3], cd_purchase_estimate=[$4], cd_credit_rating=[$5])
HiveFilter(condition=[IS NOT NULL($0)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query71.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query71.q.out
index e1c8bc4..5ed9c4f 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query71.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query71.q.out
@@ -95,7 +95,7 @@ HiveProject(brand_id=[$0], brand=[$1], t_hour=[$2], t_minute=[$3], ext_price=[$4
HiveAggregate(group=[{1, 2, 7, 8}], agg#0=[sum($3)])
HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(t_time_sk=[$0], t_hour=[$3], t_minute=[$4])
- HiveFilter(condition=[AND(IN($9, _UTF-16LE'breakfast', _UTF-16LE'dinner'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($9, _UTF-16LE'breakfast':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'dinner':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ext_price=[$0], sold_item_sk=[$1], time_sk=[$2])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query73.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query73.q.out
index 671959d..b3db960 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query73.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query73.q.out
@@ -85,9 +85,9 @@ HiveSortLimit(sort0=[$5], dir0=[DESC-nulls-last])
HiveFilter(condition=[AND(BETWEEN(false, $9, 1, 2), IN($6, 2000, 2001, 2002), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(hd_demo_sk=[$0])
- HiveFilter(condition=[AND(>($4, 0), CASE(>($4, 0), >(/(CAST($3):DOUBLE, CAST($4):DOUBLE), 1), false), IN($2, _UTF-16LE'>10000', _UTF-16LE'unknown'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(>($4, 0), CASE(>($4, 0), >(/(CAST($3):DOUBLE, CAST($4):DOUBLE), 1), false), IN($2, _UTF-16LE'>10000':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'unknown':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
HiveProject(s_store_sk=[$0])
- HiveFilter(condition=[AND(IN($23, _UTF-16LE'Mobile County', _UTF-16LE'Maverick County', _UTF-16LE'Huron County', _UTF-16LE'Kittitas County'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($23, _UTF-16LE'Mobile County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Maverick County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Huron County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Kittitas County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, store]], table:alias=[store])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query74.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query74.q.out
index 6b180bd..047e21d 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query74.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query74.q.out
@@ -161,7 +161,7 @@ HiveSortLimit(sort0=[$1], sort1=[$0], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[
HiveFilter(condition=[AND(=($6, 2002), IN($6, 2001, 2002), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject($f0=[$0], $f4=[$3])
- HiveFilter(condition=[>($3, 0:DECIMAL(1, 0))])
+ HiveFilter(condition=[>($3, 0)])
HiveAggregate(group=[{1, 2, 3}], agg#0=[max($6)])
HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9])
@@ -175,7 +175,7 @@ HiveSortLimit(sort0=[$1], sort1=[$0], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[
HiveFilter(condition=[AND(=($6, 2001), IN($6, 2001, 2002), IS NOT NULL($0))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(customer_id=[$0], year_total=[$3], CAST=[CAST(IS NOT NULL($3)):BOOLEAN])
- HiveFilter(condition=[>($3, 0:DECIMAL(1, 0))])
+ HiveFilter(condition=[>($3, 0)])
HiveAggregate(group=[{1, 2, 3}], agg#0=[max($6)])
HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query75.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query75.q.out
index 73b9452..2737db0 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query75.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query75.q.out
@@ -158,7 +158,7 @@ CBO PLAN:
HiveProject(prev_year=[CAST(2001):INTEGER], year=[CAST(2002):INTEGER], i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], prev_yr_cnt=[$4], curr_yr_cnt=[$5], sales_cnt_diff=[$6], sales_amt_diff=[$7])
HiveSortLimit(sort0=[$6], dir0=[ASC], fetch=[100])
HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], prev_yr_cnt=[$4], curr_yr_cnt=[$10], sales_cnt_diff=[-($10, $4)], sales_amt_diff=[-($11, $5)])
- HiveJoin(condition=[AND(=($6, $0), =($7, $1), =($8, $2), =($9, $3), <(/(CAST($10):DECIMAL(17, 2), CAST($4):DECIMAL(17, 2)), 0.9:DECIMAL(2, 1)))], joinType=[inner], algorithm=[none], cost=[not available])
+ HiveJoin(condition=[AND(=($6, $0), =($7, $1), =($8, $2), =($9, $3), <(/(CAST($10):DECIMAL(17, 2), CAST($4):DECIMAL(17, 2)), 0.9:DECIMAL(1, 1)))], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], $f4=[$4], $f5=[$5])
HiveAggregate(group=[{0, 1, 2, 3}], agg#0=[sum($4)], agg#1=[sum($5)])
HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query8.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query8.q.out
index 3176ddd..621f32c 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query8.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query8.q.out
@@ -246,7 +246,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveProject(ca_zip=[$0], $f1=[$1])
HiveAggregate(group=[{0}], agg#0=[count()])
HiveProject(ca_zip=[substr($9, 1, 5)])
- HiveFilter(condition=[AND(IN(substr($9, 1, 5), _UTF-16LE'89436', _UTF-16LE'30868', _UTF-16LE'65085', _UTF-16LE'22977', _UTF-16LE'83927', _UTF-16LE'77557', _UTF-16LE'58429', _UTF-16LE'40697', _UTF-16LE'80614', _UTF-16LE'10502', _UTF-16LE'32779', _UTF-16LE'91137', _UTF-16LE'61265', _UTF-16LE'98294', _UTF-16LE'17921', _UTF-16LE'18427', _UTF-16LE'21203', _UTF-16LE'59362', _UTF-16LE'87291', _UTF-16LE'84093', _UTF-16LE'21505', _UTF-16LE'17184', _UTF-16LE'10866', _UT [...]
+ HiveFilter(condition=[AND(IN(substr($9, 1, 5), _UTF-16LE'89436':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'30868':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'65085':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'22977':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'83927':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'77557':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'58429':VARCHAR(2147483647) CH [...]
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveProject(ca_zip=[$0], $f1=[$1])
HiveAggregate(group=[{0}], agg#0=[count()])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out
index 634fc83..5d2ab05 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out
@@ -230,7 +230,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveJoin(condition=[=($4, $13)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(i_item_sk=[$0])
- HiveFilter(condition=[AND(>($5, 50:DECIMAL(2, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(>($5, 50), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveJoin(condition=[=($0, $11)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[AND(=($1, $7), =($4, $8))], joinType=[left], algorithm=[none], cost=[not available])
@@ -256,7 +256,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveJoin(condition=[=($4, $13)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(i_item_sk=[$0])
- HiveFilter(condition=[AND(>($5, 50:DECIMAL(2, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(>($5, 50), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveJoin(condition=[=($0, $11)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[AND(=($2, $7), =($4, $8))], joinType=[left], algorithm=[none], cost=[not available])
@@ -282,7 +282,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(i_item_sk=[$0])
- HiveFilter(condition=[AND(>($5, 50:DECIMAL(2, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(>($5, 50), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveJoin(condition=[=($0, $11)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[AND(=($1, $7), =($4, $8))], joinType=[left], algorithm=[none], cost=[not available])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query82.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query82.q.out
index 74fa05c..1037ce6 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query82.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query82.q.out
@@ -50,7 +50,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveFilter(condition=[IS NOT NULL($2)])
HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5])
- HiveFilter(condition=[AND(BETWEEN(false, $5, 30:DECIMAL(12, 2), 60:DECIMAL(2, 0)), IN($13, 437, 129, 727, 663), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($13, 437, 129, 727, 663), BETWEEN(false, $5, 30:DECIMAL(12, 2), 60:DECIMAL(2, 0)), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], d_date_sk=[$2])
HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query83.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query83.q.out
index 4741932..37d88da 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query83.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query83.q.out
@@ -169,7 +169,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(d_week_seq=[$4])
- HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02', _UTF-16LE'1998-10-15', _UTF-16LE'1998-11-10'), IS NOT NULL($4))])
+ HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'1998-10-15':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'1998-11-10':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($4))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject($f0=[$0], $f1=[$1], CAST=[CAST($1):DOUBLE])
HiveAggregate(group=[{4}], agg#0=[sum($2)])
@@ -193,7 +193,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(d_week_seq=[$4])
- HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02', _UTF-16LE'1998-10-15', _UTF-16LE'1998-11-10'), IS NOT NULL($4))])
+ HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'1998-10-15':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'1998-11-10':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($4))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject($f0=[$0], $f1=[$1], CAST=[CAST($1):DOUBLE])
HiveAggregate(group=[{4}], agg#0=[sum($2)])
@@ -217,6 +217,6 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject(d_week_seq=[$4])
- HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02', _UTF-16LE'1998-10-15', _UTF-16LE'1998-11-10'), IS NOT NULL($4))])
+ HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'1998-10-15':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'1998-11-10':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($4))])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query85.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query85.q.out
index c8f6ded..1c996ac 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query85.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query85.q.out
@@ -198,18 +198,18 @@ HiveProject(_o__c0=[$0], _o__c1=[$1], _o__c2=[$2], _o__c3=[$3])
HiveJoin(condition=[=($24, $13)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[AND(=($1, $22), =($2, $23), =($0, $10))], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2], cd_education_status=[$3], ==[=($2, _UTF-16LE'M')], =4=[=($3, _UTF-16LE'4 yr Degree')], =5=[=($2, _UTF-16LE'D')], =6=[=($3, _UTF-16LE'Primary')], =7=[=($2, _UTF-16LE'U')], =8=[=($3, _UTF-16LE'Advanced Degree')])
- HiveFilter(condition=[AND(IN($2, _UTF-16LE'M', _UTF-16LE'D', _UTF-16LE'U'), IN($3, _UTF-16LE'4 yr Degree', _UTF-16LE'Primary', _UTF-16LE'Advanced Degree'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($2, _UTF-16LE'M':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'D':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'U':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IN($3, _UTF-16LE'4 yr Degree':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Primary':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Advanced Degree':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd1])
HiveJoin(condition=[=($12, $3)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[=($8, $2)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(wr_item_sk=[$2], wr_refunded_cdemo_sk=[$4], wr_refunded_addr_sk=[$6], wr_returning_cdemo_sk=[$8], wr_reason_sk=[$12], wr_order_number=[$13], wr_fee=[$18], wr_refunded_cash=[$20])
HiveFilter(condition=[AND(IS NOT NULL($6), IS NOT NULL($8), IS NOT NULL($4), IS NOT NULL($12), IS NOT NULL($2), IS NOT NULL($13))])
HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
- HiveProject(ca_address_sk=[$0], IN=[IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM')], IN2=[IN($8, _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN')], IN3=[IN($8, _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV')])
- HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM', _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN', _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), =($10, _UTF-16LE'United States'), IS NOT NULL($0))])
+ HiveProject(ca_address_sk=[$0], IN=[IN($8, _UTF-16LE'KY':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'GA':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'NM':VARCHAR(2147483647) CHARACTER SET "UTF-16LE")], IN2=[IN($8, _UTF-16LE'MT':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'OR':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'IN':VARCHAR(2147483647) CHARACTER SET "UTF-16LE")], IN3=[IN($8, _UTF-16LE'WI':VARCHAR(2147483647) CHARA [...]
+ HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'GA':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'NM':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MT':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'OR':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'IN':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'WI':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'MO':V [...]
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2], cd_education_status=[$3])
- HiveFilter(condition=[AND(IN($2, _UTF-16LE'M', _UTF-16LE'D', _UTF-16LE'U'), IN($3, _UTF-16LE'4 yr Degree', _UTF-16LE'Primary', _UTF-16LE'Advanced Degree'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($2, _UTF-16LE'M':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'D':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'U':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IN($3, _UTF-16LE'4 yr Degree':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Primary':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Advanced Degree':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd2])
HiveProject(r_reason_sk=[$0], r_reason_desc=[$2])
HiveFilter(condition=[IS NOT NULL($0)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query89.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query89.q.out
index 62aa4bb..667c16e 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query89.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query89.q.out
@@ -66,7 +66,7 @@ CBO PLAN:
HiveProject(i_category=[$0], i_class=[$1], i_brand=[$2], s_store_name=[$3], s_company_name=[$4], d_moy=[$5], sum_sales=[$6], avg_monthly_sales=[$7])
HiveSortLimit(sort0=[$8], sort1=[$3], dir0=[ASC], dir1=[ASC], fetch=[100])
HiveProject(i_category=[$0], i_class=[$1], i_brand=[$2], s_store_name=[$3], s_company_name=[$4], d_moy=[$5], sum_sales=[$6], avg_monthly_sales=[$7], (- (tok_table_or_col sum_sales) (tok_table_or_col avg_monthly_sales))=[-($6, $7)])
- HiveFilter(condition=[CASE(<>($7, 0:DECIMAL(1, 0)), >(/(ABS(-($6, $7)), $7), 0.1:DECIMAL(2, 1)), false)])
+ HiveFilter(condition=[CASE(<>($7, 0), >(/(ABS(-($6, $7)), $7), 0.1:DECIMAL(1, 1)), false)])
HiveProject((tok_table_or_col i_category)=[$2], (tok_table_or_col i_class)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col s_store_name)=[$4], (tok_table_or_col s_company_name)=[$5], (tok_table_or_col d_moy)=[$3], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], avg_window_0=[avg($6) OVER (PARTITION BY $2, $0, $4, $5 ORDER BY $2 NULLS FIRST, $0 NULLS FIRST, $4 NULLS FIRST, $5 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
HiveProject(i_brand=[$0], i_class=[$1], i_category=[$2], d_moy=[$3], s_store_name=[$4], s_company_name=[$5], $f6=[$6])
HiveAggregate(group=[{5, 6, 7, 9, 11, 12}], agg#0=[sum($3)])
@@ -77,7 +77,7 @@ HiveProject(i_category=[$0], i_class=[$1], i_brand=[$2], s_store_name=[$3], s_co
HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($2))])
HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
HiveProject(i_item_sk=[$0], i_brand=[$8], i_class=[$10], i_category=[$12])
- HiveFilter(condition=[AND(IN($10, _UTF-16LE'wallpaper', _UTF-16LE'parenting', _UTF-16LE'musical', _UTF-16LE'womens', _UTF-16LE'birdal', _UTF-16LE'pants'), IN($12, _UTF-16LE'Home', _UTF-16LE'Books', _UTF-16LE'Electronics', _UTF-16LE'Shoes', _UTF-16LE'Jewelry', _UTF-16LE'Men'), OR(AND(IN($12, _UTF-16LE'Home', _UTF-16LE'Books', _UTF-16LE'Electronics'), IN($10, _UTF-16LE'wallpaper', _UTF-16LE'parenting', _UTF-16LE'musical')), AND(IN($12, _UTF-16LE'Shoes', _UTF-16LE'Jewe [...]
+ HiveFilter(condition=[AND(IN($10, _UTF-16LE'wallpaper':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'parenting':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'musical':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'womens':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'birdal':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'pants':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IN($12, _UTF-16LE'Home':VARCHAR(2147483647) C [...]
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveProject(d_date_sk=[$0], d_moy=[$8])
HiveFilter(condition=[AND(=($6, 2000), IS NOT NULL($0))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query91.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query91.q.out
index 3a2aacf..6cef63b 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query91.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query91.q.out
@@ -83,14 +83,14 @@ HiveProject(call_center=[$0], call_center_name=[$1], manager=[$2], returns_loss=
HiveJoin(condition=[=($9, $1)], joinType=[inner], algorithm=[none], cost=[not available])
HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ca_address_sk=[$0])
- HiveFilter(condition=[AND(=($11, -7:DECIMAL(1, 0)), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(=($11, -7), IS NOT NULL($0))])
HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
HiveJoin(condition=[=($4, $1)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_hdemo_sk=[$3], c_current_addr_sk=[$4])
HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($2), IS NOT NULL($0), IS NOT NULL($4))])
HiveTableScan(table=[[default, customer]], table:alias=[customer])
HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2], cd_education_status=[$3])
- HiveFilter(condition=[AND(IN($2, _UTF-16LE'M', _UTF-16LE'W'), IN($3, _UTF-16LE'Unknown', _UTF-16LE'Advanced Degree'), IN(ROW($2, $3), ROW(_UTF-16LE'M', _UTF-16LE'Unknown'), ROW(_UTF-16LE'W', _UTF-16LE'Advanced Degree')), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($2, _UTF-16LE'M':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'W':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IN($3, _UTF-16LE'Unknown':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Advanced Degree':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IN(ROW($2, $3), ROW(_UTF-16LE'M':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Unknown':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), ROW(_UTF-16LE'W':VARCHAR(214748 [...]
HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
HiveProject(cr_returned_date_sk=[$0], cr_returning_customer_sk=[$1], cr_call_center_sk=[$2], cr_net_loss=[$3], d_date_sk=[$4], cc_call_center_sk=[$5], cc_call_center_id=[$6], cc_name=[$7], cc_manager=[$8])
HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query98.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query98.q.out
index 8881f9e..e2a14a6 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query98.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query98.q.out
@@ -75,7 +75,7 @@ HiveProject(i_item_desc=[$0], i_category=[$1], i_class=[$2], i_current_price=[$3
HiveAggregate(group=[{1, 2, 3, 4, 5}], agg#0=[sum($8)])
HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_class=[$10], i_category=[$12])
- HiveFilter(condition=[AND(IN($12, _UTF-16LE'Jewelry', _UTF-16LE'Sports', _UTF-16LE'Books'), IS NOT NULL($0))])
+ HiveFilter(condition=[AND(IN($12, _UTF-16LE'Jewelry':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Sports':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Books':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"), IS NOT NULL($0))])
HiveTableScan(table=[[default, item]], table:alias=[item])
HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query10.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query10.q.out
index 8633ba2..b568921 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query10.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query10.q.out
@@ -144,7 +144,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$4], sort4=[$6], sort5=
HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($4))])
HiveTableScan(table=[[default, customer]], table:alias=[c])
HiveProject(ca_address_sk=[$0], ca_county=[$7])
- HiveFilter(condition=[IN($7, _UTF-16LE'Walker County', _UTF-16LE'Richland County', _UTF-16LE'Gaines County', _UTF-16LE'Douglas County', _UTF-16LE'Dona Ana County')])
+ HiveFilter(condition=[IN($7, _UTF-16LE'Walker County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Richland County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Gaines County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Douglas County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'Dona Ana County':VARCHAR(2147483647) CHARACTER SET "UTF-16LE")])
HiveTableScan(table=[[default, customer_address]], table:alias=[ca])
HiveProject(cd_demo_sk=[$0], cd_gender=[$1], cd_marital_status=[$2], cd_education_status=[$3], cd_purchase_estimate=[$4], cd_credit_rating=[$5], cd_dep_count=[$6], cd_dep_employed_count=[$7], cd_dep_college_count=[$8])
HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query11.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query11.q.out
index 53d470d..127003c 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query11.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query11.q.out
@@ -187,7 +187,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(customer_id=[$0], year_total=[$7], CAST=[CAST(IS NOT NULL($7)):BOOLEAN])
- HiveFilter(condition=[>($7, 0:DECIMAL(1, 0))])
+ HiveFilter(condition=[>($7, 0)])
HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
@@ -200,7 +200,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
HiveFilter(condition=[=($6, 2001)])
HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
HiveProject($f0=[$0], $f9=[$7])
- HiveFilter(condition=[>($7, 0:DECIMAL(1, 0))])
+ HiveFilter(condition=[>($7, 0)])
HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query12.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query12.q.out
index cfb7945..6737448 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query12.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query12.q.out
@@ -77,7 +77,7 @@ HiveProject(i_item_desc=[$0], i_category=[$1], i_class=[$2], i_current_price=[$3
HiveAggregate(group=[{1, 2, 3, 4, 5}], agg#0=[sum($8)])
HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_class=[$10], i_category=[$12])
- HiveFilter(condition=[IN($12, _UTF-16LE'Jewelry', _UTF-16LE'Sports', _UTF-16LE'Books')])
... 2022 lines suppressed ...