Skip to content

Commit fff0c9f

Browse files
committed
WIP
1 parent 70d6a95 commit fff0c9f

File tree

5 files changed

+52
-12
lines changed

5 files changed

+52
-12
lines changed

common/src/main/java/org/apache/drill/common/types/Types.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@
1717
*/
1818
package org.apache.drill.common.types;
1919

20-
import static org.apache.drill.common.types.TypeProtos.DataMode.REPEATED;
20+
import com.google.protobuf.TextFormat;
21+
import org.apache.drill.common.exceptions.DrillRuntimeException;
22+
import org.apache.drill.common.types.TypeProtos.DataMode;
23+
import org.apache.drill.common.types.TypeProtos.MajorType;
24+
import org.apache.drill.common.types.TypeProtos.MinorType;
2125

2226
import java.util.ArrayList;
2327
import java.util.Arrays;
2428
import java.util.Collections;
2529
import java.util.List;
2630

27-
import org.apache.drill.common.exceptions.DrillRuntimeException;
28-
import org.apache.drill.common.types.TypeProtos.DataMode;
29-
import org.apache.drill.common.types.TypeProtos.MajorType;
30-
import org.apache.drill.common.types.TypeProtos.MinorType;
31-
32-
import com.google.protobuf.TextFormat;
31+
import static org.apache.drill.common.types.TypeProtos.DataMode.REPEATED;
3332

3433
public class Types {
3534
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Types.class);
@@ -816,7 +815,7 @@ public static MajorType.Builder calculateTypePrecisionAndScale(MajorType leftTyp
816815
return typeBuilder.setPrecision(Math.max(leftType.getPrecision(), rightType.getPrecision()));
817816
}
818817

819-
MinorType minorType = leftType.getMinorType();
818+
MinorType minorType = leftType.getMinorType();s
820819
if (isDecimalType(leftType)) {
821820
int scale = Math.max(leftType.getScale(), rightType.getScale());
822821
// resulting precision should take into account resulting scale value and be calculated as
@@ -936,11 +935,10 @@ public static int maxPrecision(MinorType type) {
936935
return 28;
937936
case DECIMAL38DENSE:
938937
case DECIMAL38SPARSE:
938+
case VARDECIMAL:
939939
return 38;
940940
case DECIMAL9:
941941
return 9;
942-
case VARDECIMAL:
943-
return 38;
944942
default:
945943
return 0;
946944
}

exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ private static AggregateCall getAggCall(AggregateCall oldCall,
419419
oldCall.isDistinct(),
420420
oldCall.isApproximate(),
421421
oldCall.ignoreNulls(),
422+
oldCall.rexList,
422423
oldCall.getArgList(),
423424
oldCall.filterArg,
424425
oldCall.distinctKeys,
@@ -541,6 +542,7 @@ private RexNode reduceStddev(
541542
oldCall.isDistinct(),
542543
oldCall.isApproximate(),
543544
oldCall.ignoreNulls(),
545+
oldCall.rexList,
544546
ImmutableIntList.of(argSquaredOrdinal),
545547
oldCall.filterArg,
546548
oldCall.distinctKeys,
@@ -562,6 +564,7 @@ private RexNode reduceStddev(
562564
oldCall.isDistinct(),
563565
oldCall.isApproximate(),
564566
oldCall.ignoreNulls(),
567+
oldCall.rexList,
565568
ImmutableIntList.of(argOrdinal),
566569
oldCall.filterArg,
567570
oldCall.distinctKeys,
@@ -739,6 +742,7 @@ public void onMatch(RelOptRuleCall call) {
739742
oldAggregateCall.isDistinct(),
740743
oldAggregateCall.isApproximate(),
741744
oldAggregateCall.ignoreNulls(),
745+
oldAggregateCall.rexList,
742746
oldAggregateCall.getArgList(),
743747
oldAggregateCall.filterArg,
744748
oldAggregateCall.distinctKeys,

exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/AggPrelBase.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
package org.apache.drill.exec.planner.physical;
1919

20+
import com.google.common.collect.ImmutableList;
2021
import org.apache.drill.common.expression.IfExpression;
2122
import org.apache.drill.common.expression.NullExpression;
2223
import com.google.common.collect.Lists;
@@ -179,13 +180,48 @@ protected void createKeysAndExprs() {
179180
aggCall.e.isDistinct(),
180181
aggCall.e.isApproximate(),
181182
false,
183+
ImmutableList.of(),
182184
Collections.singletonList(aggExprOrdinal),
183185
aggCall.e.filterArg,
184186
null,
185187
RelCollations.EMPTY,
186188
aggCall.e.getType(),
187189
aggCall.e.getName());
188190

191+
/*
192+
SqlAggFunction aggFunction,
193+
boolean distinct,
194+
boolean approximate,
195+
boolean ignoreNulls,
196+
List<Integer> argList,
197+
int filterArg,
198+
@Nullable ImmutableBitSet distinctKeys,
199+
RelCollation collation,
200+
RelDataType type,
201+
@Nullable String name
202+
203+
SqlAggFunction aggFunction,
204+
boolean distinct,
205+
boolean approximate,
206+
boolean ignoreNulls,
207+
List<RexNode> rexList,
208+
List<Integer> argList,
209+
int filterArg,
210+
@Nullable ImmutableBitSet distinctKeys, RelCollation collation,
211+
RelDataType type, @Nullable String name
212+
213+
public static AggregateCall create(SqlAggFunction aggFunction, boolean distinct, boolean approximate, boolean ignoreNulls,
214+
List<Integer> argList, int filterArg,
215+
@Nullable ImmutableBitSet distinctKeys, RelCollation collation,
216+
RelDataType type, @Nullable String name) {
217+
final boolean distinct2 = distinct
218+
&& (aggFunction.getDistinctOptionality() != Optionality.IGNORED);
219+
return new AggregateCall(aggFunction, distinct2, approximate, ignoreNulls,
220+
argList, filterArg, distinctKeys, collation, type, name);
221+
}
222+
223+
*/
224+
189225
phase2AggCallList.add(newAggCall);
190226
} else {
191227
AggregateCall newAggCall =
@@ -194,6 +230,7 @@ protected void createKeysAndExprs() {
194230
aggCall.e.isDistinct(),
195231
aggCall.e.isApproximate(),
196232
false,
233+
ImmutableList.of(),
197234
Collections.singletonList(aggExprOrdinal),
198235
aggCall.e.filterArg,
199236
null,
@@ -270,6 +307,7 @@ public Prel prepareForLateralUnnestPipeline(List<RelNode> children) {
270307
aggCall.isDistinct(),
271308
aggCall.isApproximate(),
272309
false,
310+
ImmutableList.of(),
273311
arglist,
274312
aggCall.filterArg,
275313
null,

exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestVarlenDecimal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public void testWideningLimit() throws Exception {
197197
// A union of VARDECIMALs that requires a widening to an unsupported
198198
// DECIMAL(40, 6). The resulting column should be limited DECIMAL(38, 6)
199199
// and a precision loss warning logged.
200-
String query = "SELECT CAST(10 AS DECIMAL(38, 4)) AS `Col1` " +
200+
String query = "SELECT CAST('10' AS DECIMAL(38, 4)) AS `Col1` " +
201201
"UNION ALL " +
202202
"SELECT CAST(22 AS DECIMAL(29, 6)) AS `Col1`";
203203

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<bouncycastle.version>1.78.1</bouncycastle.version>
5858
<caffeine.version>2.9.3</caffeine.version>
5959
<calcite.groupId>org.apache.calcite</calcite.groupId>
60-
<calcite.version>1.34.0</calcite.version>
60+
<calcite.version>1.35.0</calcite.version>
6161
<codemodel.version>2.6</codemodel.version>
6262
<commons.beanutils.version>1.9.4</commons.beanutils.version>
6363
<commons.cli.version>1.4</commons.cli.version>

0 commit comments

Comments
 (0)