mirror of https://github.com/apache/druid.git
picked akshat's 3e0202811e05dcd07db5ab47791151fab5dd5772
This commit is contained in:
parent
82436df585
commit
8ada2ff238
|
@ -213,6 +213,32 @@
|
|||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.hydromatic</groupId>
|
||||
<artifactId>quidem</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.calcite</groupId>
|
||||
<artifactId>calcite-testkit</artifactId>
|
||||
<version>${calcite.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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.druid.msq.exec;
|
||||
|
||||
import org.apache.druid.common.config.NullHandling;
|
||||
import org.apache.druid.quidem.DruidQuidemTestBase;
|
||||
import org.apache.druid.quidem.ProjectPathUtils;
|
||||
import org.junit.jupiter.api.condition.EnabledIf;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@EnabledIf(value = "enabled", disabledReason = "These tests are only run in SqlCompatible mode!")
|
||||
public class MSQQuidemTest extends DruidQuidemTestBase
|
||||
{
|
||||
public static boolean enabled()
|
||||
{
|
||||
NullHandling.initializeForTests();
|
||||
return NullHandling.sqlCompatible();
|
||||
}
|
||||
|
||||
public MSQQuidemTest()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File getTestRoot()
|
||||
{
|
||||
return ProjectPathUtils.getPathFromProjectRoot("extensions-core/multi-stage-query/src/test/quidem/" + getClass().getName());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
!set plannerStrategy DECOUPLED
|
||||
!use druidtest://?componentSupplier=DrillWindowQueryMSQComponentSupplier
|
||||
!set outputformat mysql
|
||||
|
||||
select cityName, count(case when delta > 0 then channel end) as cnt, count(1) as aall
|
||||
from wikipedia
|
||||
where cityName in ('New York', 'Aarhus')
|
||||
group by 1
|
||||
order by 1;
|
||||
+----------+-----+------+
|
||||
| cityName | cnt | aall |
|
||||
+----------+-----+------+
|
||||
| Aarhus | 0 | 1 |
|
||||
| New York | 7 | 13 |
|
||||
+----------+-----+------+
|
||||
(2 rows)
|
||||
|
||||
!ok
|
||||
LogicalSort(sort0=[$0], dir0=[ASC])
|
||||
LogicalAggregate(group=[{0}], cnt=[COUNT($1)], aall=[COUNT()])
|
||||
LogicalProject(cityName=[$2], $f1=[CASE(>($17, 0), $1, null:VARCHAR)])
|
||||
LogicalFilter(condition=[OR(=($2, 'New York'), =($2, 'Aarhus'))])
|
||||
LogicalTableScan(table=[[druid, wikipedia]])
|
||||
|
||||
!convertedPlan
|
||||
LogicalSort(sort0=[$0], dir0=[ASC])
|
||||
LogicalAggregate(group=[{0}], cnt=[COUNT($1) FILTER $2], aall=[COUNT()])
|
||||
LogicalProject(cityName=[$2], channel=[$1], $f3=[IS TRUE(>($17, 0))])
|
||||
LogicalFilter(condition=[SEARCH($2, Sarg['Aarhus':VARCHAR(8), 'New York':VARCHAR(8)]:VARCHAR(8))])
|
||||
LogicalTableScan(table=[[druid, wikipedia]])
|
||||
|
||||
!logicalPlan
|
||||
DruidAggregate(group=[{0}], cnt=[COUNT($1) FILTER $2], aall=[COUNT()], druid=[logical])
|
||||
DruidProject(cityName=[$2], channel=[$1], $f3=[IS TRUE(>($17, 0))], druid=[logical])
|
||||
DruidFilter(condition=[SEARCH($2, Sarg['Aarhus':VARCHAR(8), 'New York':VARCHAR(8)]:VARCHAR(8))])
|
||||
DruidTableScan(table=[[druid, wikipedia]], druid=[logical])
|
||||
|
||||
!druidPlan
|
||||
{
|
||||
"queryType" : "groupBy",
|
||||
"dataSource" : {
|
||||
"type" : "table",
|
||||
"name" : "wikipedia"
|
||||
},
|
||||
"intervals" : {
|
||||
"type" : "intervals",
|
||||
"intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ]
|
||||
},
|
||||
"filter" : {
|
||||
"type" : "inType",
|
||||
"column" : "cityName",
|
||||
"matchValueType" : "STRING",
|
||||
"sortedValues" : [ "Aarhus", "New York" ]
|
||||
},
|
||||
"granularity" : {
|
||||
"type" : "all"
|
||||
},
|
||||
"dimensions" : [ {
|
||||
"type" : "default",
|
||||
"dimension" : "cityName",
|
||||
"outputName" : "d0",
|
||||
"outputType" : "STRING"
|
||||
} ],
|
||||
"aggregations" : [ {
|
||||
"type" : "filtered",
|
||||
"aggregator" : {
|
||||
"type" : "count",
|
||||
"name" : "a0"
|
||||
},
|
||||
"filter" : {
|
||||
"type" : "and",
|
||||
"fields" : [ {
|
||||
"type" : "not",
|
||||
"field" : {
|
||||
"type" : "null",
|
||||
"column" : "channel"
|
||||
}
|
||||
}, {
|
||||
"type" : "range",
|
||||
"column" : "delta",
|
||||
"matchValueType" : "LONG",
|
||||
"lower" : 0,
|
||||
"lowerOpen" : true
|
||||
} ]
|
||||
},
|
||||
"name" : "a0"
|
||||
}, {
|
||||
"type" : "count",
|
||||
"name" : "a1"
|
||||
} ],
|
||||
"limitSpec" : {
|
||||
"type" : "NoopLimitSpec"
|
||||
}
|
||||
}
|
||||
!nativePlan
|
||||
|
|
@ -51,6 +51,8 @@ public class SqlToolbox
|
|||
)
|
||||
{
|
||||
this.engine = engine;
|
||||
System.out.println("SqlToolbox.SqlToolbox");
|
||||
System.out.println("engine = " + engine);
|
||||
this.plannerFactory = plannerFactory;
|
||||
this.emitter = emitter;
|
||||
this.requestLogger = requestLogger;
|
||||
|
|
|
@ -746,6 +746,7 @@ public abstract class QueryHandler extends SqlStatementHandler.BaseStatementHand
|
|||
@Override
|
||||
protected QueryMaker buildQueryMaker(final RelRoot rootQueryRel) throws ValidationException
|
||||
{
|
||||
System.out.println("SelectHandler.buildQueryMaker");
|
||||
return handlerContext.engine().buildQueryMakerForSelect(
|
||||
rootQueryRel,
|
||||
handlerContext.plannerContext()
|
||||
|
|
|
@ -123,6 +123,7 @@ public abstract class DruidQuidemTestBase
|
|||
File inFile = new File(getTestRoot(), testFileName);
|
||||
|
||||
final File outFile = new File(inFile.getParentFile(), inFile.getName() + ".out");
|
||||
System.out.println("druidQuidemRunner = " + druidQuidemRunner);
|
||||
druidQuidemRunner.run(inFile, outFile);
|
||||
}
|
||||
|
||||
|
|
|
@ -527,6 +527,7 @@ public class SqlTestFrameworkConfig
|
|||
Set<Class<? extends QueryComponentSupplier>> availableSuppliers = componentSupplierClassCache.get(pkg);
|
||||
for (Class<? extends QueryComponentSupplier> cl : availableSuppliers) {
|
||||
if (cl.getSimpleName().equals(name)) {
|
||||
System.out.println("cl = " + cl);
|
||||
return cl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -688,6 +688,7 @@ public class SqlTestFramework
|
|||
|
||||
this.injector = serviceInjector.build();
|
||||
this.engine = builder.componentSupplier.createEngine(queryLifecycleFactory(), queryJsonMapper(), injector);
|
||||
System.out.println("engine = " + this.engine);
|
||||
componentSupplier.configureJsonMapper(queryJsonMapper());
|
||||
componentSupplier.finalizeTestFramework(this);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue