mirror of https://github.com/apache/druid.git
Adjust for empty MAX result.
This commit is contained in:
parent
a94acebfa4
commit
e111520271
|
@ -4231,6 +4231,20 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
|
||||||
@Test
|
@Test
|
||||||
public void testGroupByNothingWithLiterallyFalseFilter()
|
public void testGroupByNothingWithLiterallyFalseFilter()
|
||||||
{
|
{
|
||||||
|
// Result of MAX(cnt) when nothing matches the filter.
|
||||||
|
final Long emptyMaxResult;
|
||||||
|
|
||||||
|
if (testBuilder().config.isRunningMSQ() && NullHandling.replaceWithDefault()) {
|
||||||
|
// Standard SQL dictates an empty MAX should return NULL. Calcite is smart enough to know that this query can
|
||||||
|
// never match anything, and therefore the query should return COUNT(*) = 0, MAX(cnt) = NULL. However, when
|
||||||
|
// running with MSQ in replace-with-default mode, the null gets turned into a 0 because we actually run the
|
||||||
|
// inline datasource through the MSQ engine. This doesn't happen with native, where the null from Calcite's
|
||||||
|
// plan is returned as-is.
|
||||||
|
emptyMaxResult = 0L;
|
||||||
|
} else {
|
||||||
|
emptyMaxResult = null;
|
||||||
|
}
|
||||||
|
|
||||||
testQuery(
|
testQuery(
|
||||||
"SELECT COUNT(*), MAX(cnt) FROM druid.foo WHERE 1 = 0",
|
"SELECT COUNT(*), MAX(cnt) FROM druid.foo WHERE 1 = 0",
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
|
@ -4247,7 +4261,7 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
|
||||||
.build()
|
.build()
|
||||||
),
|
),
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
new Object[]{0L, null}
|
new Object[]{0L, emptyMaxResult}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue