diff --git a/common/src/main/java/org/apache/drill/common/types/Types.java b/common/src/main/java/org/apache/drill/common/types/Types.java index 4f152fd30b1..4f4a9a35a7a 100644 --- a/common/src/main/java/org/apache/drill/common/types/Types.java +++ b/common/src/main/java/org/apache/drill/common/types/Types.java @@ -17,19 +17,18 @@ */ package org.apache.drill.common.types; -import static org.apache.drill.common.types.TypeProtos.DataMode.REPEATED; +import com.google.protobuf.TextFormat; +import org.apache.drill.common.exceptions.DrillRuntimeException; +import org.apache.drill.common.types.TypeProtos.DataMode; +import org.apache.drill.common.types.TypeProtos.MajorType; +import org.apache.drill.common.types.TypeProtos.MinorType; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.apache.drill.common.exceptions.DrillRuntimeException; -import org.apache.drill.common.types.TypeProtos.DataMode; -import org.apache.drill.common.types.TypeProtos.MajorType; -import org.apache.drill.common.types.TypeProtos.MinorType; - -import com.google.protobuf.TextFormat; +import static org.apache.drill.common.types.TypeProtos.DataMode.REPEATED; public class Types { private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Types.class); @@ -936,11 +935,10 @@ public static int maxPrecision(MinorType type) { return 28; case DECIMAL38DENSE: case DECIMAL38SPARSE: + case VARDECIMAL: return 38; case DECIMAL9: return 9; - case VARDECIMAL: - return 38; default: return 0; } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java index 1b67da275a8..0dfe35ca5c9 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java @@ -419,6 +419,7 @@ private static AggregateCall getAggCall(AggregateCall oldCall, oldCall.isDistinct(), oldCall.isApproximate(), oldCall.ignoreNulls(), + oldCall.rexList, oldCall.getArgList(), oldCall.filterArg, oldCall.distinctKeys, @@ -541,6 +542,7 @@ private RexNode reduceStddev( oldCall.isDistinct(), oldCall.isApproximate(), oldCall.ignoreNulls(), + oldCall.rexList, ImmutableIntList.of(argSquaredOrdinal), oldCall.filterArg, oldCall.distinctKeys, @@ -562,6 +564,7 @@ private RexNode reduceStddev( oldCall.isDistinct(), oldCall.isApproximate(), oldCall.ignoreNulls(), + oldCall.rexList, ImmutableIntList.of(argOrdinal), oldCall.filterArg, oldCall.distinctKeys, @@ -739,6 +742,7 @@ public void onMatch(RelOptRuleCall call) { oldAggregateCall.isDistinct(), oldAggregateCall.isApproximate(), oldAggregateCall.ignoreNulls(), + oldAggregateCall.rexList, oldAggregateCall.getArgList(), oldAggregateCall.filterArg, oldAggregateCall.distinctKeys, diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/AggPrelBase.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/AggPrelBase.java index ed236f7cdab..a984b44a899 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/AggPrelBase.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/AggPrelBase.java @@ -17,6 +17,7 @@ */ package org.apache.drill.exec.planner.physical; +import com.google.common.collect.ImmutableList; import org.apache.drill.common.expression.IfExpression; import org.apache.drill.common.expression.NullExpression; import com.google.common.collect.Lists; @@ -179,6 +180,7 @@ protected void createKeysAndExprs() { aggCall.e.isDistinct(), aggCall.e.isApproximate(), false, + ImmutableList.of(), Collections.singletonList(aggExprOrdinal), aggCall.e.filterArg, null, @@ -194,6 +196,7 @@ protected void createKeysAndExprs() { aggCall.e.isDistinct(), aggCall.e.isApproximate(), false, + ImmutableList.of(), Collections.singletonList(aggExprOrdinal), aggCall.e.filterArg, null, @@ -270,6 +273,7 @@ public Prel prepareForLateralUnnestPipeline(List children) { aggCall.isDistinct(), aggCall.isApproximate(), false, + ImmutableList.of(), arglist, aggCall.filterArg, null, diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/conversion/DrillRexBuilder.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/conversion/DrillRexBuilder.java index 299859c8427..dd76f9c35e3 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/conversion/DrillRexBuilder.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/conversion/DrillRexBuilder.java @@ -17,8 +17,6 @@ */ package org.apache.drill.exec.planner.sql.conversion; -import java.math.BigDecimal; - import org.apache.calcite.rel.type.RelDataType; import org.apache.calcite.rel.type.RelDataTypeFactory; import org.apache.calcite.rex.RexBuilder; @@ -30,6 +28,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.math.BigDecimal; + class DrillRexBuilder extends RexBuilder { private static final Logger logger = LoggerFactory.getLogger(DrillRexBuilder.class); diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestVarlenDecimal.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestVarlenDecimal.java index 61f8e4df872..5397e810477 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestVarlenDecimal.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestVarlenDecimal.java @@ -197,7 +197,7 @@ public void testWideningLimit() throws Exception { // A union of VARDECIMALs that requires a widening to an unsupported // DECIMAL(40, 6). The resulting column should be limited DECIMAL(38, 6) // and a precision loss warning logged. - String query = "SELECT CAST(10 AS DECIMAL(38, 4)) AS `Col1` " + + String query = "SELECT CAST('10' AS DECIMAL(38, 4)) AS `Col1` " + "UNION ALL " + "SELECT CAST(22 AS DECIMAL(29, 6)) AS `Col1`"; diff --git a/pom.xml b/pom.xml index 1b5693b34e7..e3577445892 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 1.78.1 2.9.3 org.apache.calcite - 1.34.0 + 1.35.0 2.6 1.9.4 1.4