mirror of https://github.com/apache/druid.git
Fix assertion error in sql planning for latest aggregators (#13151)
* Fix sql planning bug for latest aggregators * change test name * Fix error messages * fix error message again
This commit is contained in:
parent
cffa3bd263
commit
94e36731f9
|
@ -202,12 +202,20 @@ public class EarliestLatestAnySqlAggregator implements SqlAggregator
|
|||
theAggFactory = aggregatorType.createAggregatorFactory(aggregatorName, fieldName, null, outputType, -1);
|
||||
break;
|
||||
case 2:
|
||||
int maxStringBytes;
|
||||
try {
|
||||
maxStringBytes = RexLiteral.intValue(rexNodes.get(1));
|
||||
}
|
||||
catch (AssertionError ae) {
|
||||
plannerContext.setPlanningError("The second argument '%s' to function '%s' is not a number", rexNodes.get(1), aggregateCall.getName());
|
||||
return null;
|
||||
}
|
||||
theAggFactory = aggregatorType.createAggregatorFactory(
|
||||
aggregatorName,
|
||||
fieldName,
|
||||
null,
|
||||
outputType,
|
||||
RexLiteral.intValue(rexNodes.get(1))
|
||||
maxStringBytes
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -122,12 +122,20 @@ public class EarliestLatestBySqlAggregator implements SqlAggregator
|
|||
);
|
||||
break;
|
||||
case 3:
|
||||
int maxStringBytes;
|
||||
try {
|
||||
maxStringBytes = RexLiteral.intValue(rexNodes.get(2));
|
||||
}
|
||||
catch (AssertionError ae) {
|
||||
plannerContext.setPlanningError("The third argument '%s' to function '%s' is not a number", rexNodes.get(2), aggregateCall.getName());
|
||||
return null;
|
||||
}
|
||||
theAggFactory = aggregatorType.createAggregatorFactory(
|
||||
aggregatorName,
|
||||
fieldName,
|
||||
EarliestLatestAnySqlAggregator.getColumnName(plannerContext, virtualColumnRegistry, args.get(1), rexNodes.get(1)),
|
||||
outputType,
|
||||
RexLiteral.intValue(rexNodes.get(2))
|
||||
maxStringBytes
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -997,6 +997,56 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
|
|||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringLatestGroupByWithAlwaysFalseCondition()
|
||||
{
|
||||
testQuery(
|
||||
"SELECT LATEST(dim4, 10),dim2 FROM numfoo WHERE (dim1 = 'something' AND dim1 IN( 'something else') ) GROUP BY dim2",
|
||||
ImmutableList.of(
|
||||
Druids.newScanQueryBuilder()
|
||||
.dataSource(InlineDataSource.fromIterable(
|
||||
ImmutableList.of(),
|
||||
RowSignature.builder()
|
||||
.add("EXPR$0", ColumnType.STRING)
|
||||
.add("dim2", ColumnType.STRING)
|
||||
.build()
|
||||
))
|
||||
.intervals(querySegmentSpec(Filtration.eternity()))
|
||||
.columns("EXPR$0", "dim2")
|
||||
.context(QUERY_CONTEXT_DEFAULT)
|
||||
.resultFormat(ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
|
||||
.legacy(false)
|
||||
.build()
|
||||
),
|
||||
ImmutableList.of()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringLatestByGroupByWithAlwaysFalseCondition()
|
||||
{
|
||||
testQuery(
|
||||
"SELECT LATEST_BY(dim4, __time, 10),dim2 FROM numfoo WHERE (dim1 = 'something' AND dim1 IN( 'something else') ) GROUP BY dim2",
|
||||
ImmutableList.of(
|
||||
Druids.newScanQueryBuilder()
|
||||
.dataSource(InlineDataSource.fromIterable(
|
||||
ImmutableList.of(),
|
||||
RowSignature.builder()
|
||||
.add("EXPR$0", ColumnType.STRING)
|
||||
.add("dim2", ColumnType.STRING)
|
||||
.build()
|
||||
))
|
||||
.intervals(querySegmentSpec(Filtration.eternity()))
|
||||
.columns("EXPR$0", "dim2")
|
||||
.context(QUERY_CONTEXT_DEFAULT)
|
||||
.resultFormat(ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
|
||||
.legacy(false)
|
||||
.build()
|
||||
),
|
||||
ImmutableList.of()
|
||||
);
|
||||
}
|
||||
|
||||
// This test the off-heap (buffer) version of the EarliestAggregator (Double/Float/Long)
|
||||
@Test
|
||||
public void testPrimitiveEarliestInSubquery()
|
||||
|
|
Loading…
Reference in New Issue