mirror of https://github.com/apache/druid.git
Keep traitSet of logicalValues (#11138)
This commit is contained in:
parent
57ddae782e
commit
261c1f271f
|
@ -76,7 +76,7 @@ public class DruidQueryRel extends DruidRel<DruidQueryRel>
|
||||||
return new DruidQueryRel(
|
return new DruidQueryRel(
|
||||||
scanRel.getCluster(),
|
scanRel.getCluster(),
|
||||||
scanRel.getCluster().traitSetOf(Convention.NONE),
|
scanRel.getCluster().traitSetOf(Convention.NONE),
|
||||||
table,
|
Preconditions.checkNotNull(table, "table"),
|
||||||
druidTable,
|
druidTable,
|
||||||
queryMaker,
|
queryMaker,
|
||||||
PartialDruidQuery.create(scanRel)
|
PartialDruidQuery.create(scanRel)
|
||||||
|
@ -91,7 +91,7 @@ public class DruidQueryRel extends DruidRel<DruidQueryRel>
|
||||||
{
|
{
|
||||||
return new DruidQueryRel(
|
return new DruidQueryRel(
|
||||||
valuesRel.getCluster(),
|
valuesRel.getCluster(),
|
||||||
valuesRel.getCluster().traitSetOf(Convention.NONE),
|
valuesRel.getTraitSet(), // the traitSet of valuesRel should be kept
|
||||||
null,
|
null,
|
||||||
druidTable,
|
druidTable,
|
||||||
queryMaker,
|
queryMaker,
|
||||||
|
|
|
@ -109,6 +109,7 @@ import org.apache.druid.query.topn.TopNQueryBuilder;
|
||||||
import org.apache.druid.segment.column.RowSignature;
|
import org.apache.druid.segment.column.RowSignature;
|
||||||
import org.apache.druid.segment.column.ValueType;
|
import org.apache.druid.segment.column.ValueType;
|
||||||
import org.apache.druid.segment.join.JoinType;
|
import org.apache.druid.segment.join.JoinType;
|
||||||
|
import org.apache.druid.segment.virtual.ExpressionVirtualColumn;
|
||||||
import org.apache.druid.server.QueryLifecycle;
|
import org.apache.druid.server.QueryLifecycle;
|
||||||
import org.apache.druid.server.QueryLifecycleFactory;
|
import org.apache.druid.server.QueryLifecycleFactory;
|
||||||
import org.apache.druid.server.security.Access;
|
import org.apache.druid.server.security.Access;
|
||||||
|
@ -150,7 +151,29 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
|
||||||
// from a table.
|
// from a table.
|
||||||
testQuery(
|
testQuery(
|
||||||
"SELECT REGEXP_EXTRACT('foo', '^(.)')",
|
"SELECT REGEXP_EXTRACT('foo', '^(.)')",
|
||||||
ImmutableList.of(),
|
ImmutableList.of(
|
||||||
|
Druids.newScanQueryBuilder()
|
||||||
|
.dataSource(
|
||||||
|
InlineDataSource.fromIterable(
|
||||||
|
ImmutableList.of(new Object[]{0L}),
|
||||||
|
RowSignature.builder().add("ZERO", ValueType.LONG).build()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.intervals(querySegmentSpec(Filtration.eternity()))
|
||||||
|
.virtualColumns(
|
||||||
|
new ExpressionVirtualColumn(
|
||||||
|
"v0",
|
||||||
|
"'f'",
|
||||||
|
ValueType.STRING,
|
||||||
|
ExprMacroTable.nil()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.columns("v0")
|
||||||
|
.resultFormat(ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
|
||||||
|
.legacy(false)
|
||||||
|
.context(QUERY_CONTEXT_DEFAULT)
|
||||||
|
.build()
|
||||||
|
),
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
new Object[]{"f"}
|
new Object[]{"f"}
|
||||||
)
|
)
|
||||||
|
@ -160,13 +183,32 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
|
||||||
@Test
|
@Test
|
||||||
public void testExpressionContainingNull() throws Exception
|
public void testExpressionContainingNull() throws Exception
|
||||||
{
|
{
|
||||||
List<String> expectedResult = new ArrayList<>();
|
|
||||||
expectedResult.add("Hello");
|
|
||||||
expectedResult.add(null);
|
|
||||||
testQuery(
|
testQuery(
|
||||||
"SELECT ARRAY ['Hello', NULL]",
|
"SELECT ARRAY ['Hello', NULL]",
|
||||||
ImmutableList.of(),
|
ImmutableList.of(
|
||||||
ImmutableList.of(new Object[]{expectedResult})
|
Druids.newScanQueryBuilder()
|
||||||
|
.dataSource(
|
||||||
|
InlineDataSource.fromIterable(
|
||||||
|
ImmutableList.of(new Object[]{0L}),
|
||||||
|
RowSignature.builder().add("ZERO", ValueType.LONG).build()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.intervals(querySegmentSpec(Filtration.eternity()))
|
||||||
|
.virtualColumns(
|
||||||
|
new ExpressionVirtualColumn(
|
||||||
|
"v0",
|
||||||
|
"array('Hello',null)",
|
||||||
|
ValueType.STRING,
|
||||||
|
ExprMacroTable.nil()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.columns("v0")
|
||||||
|
.resultFormat(ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
|
||||||
|
.legacy(false)
|
||||||
|
.context(QUERY_CONTEXT_DEFAULT)
|
||||||
|
.build()
|
||||||
|
),
|
||||||
|
ImmutableList.of(new Object[]{"[\"Hello\",null]"})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7543,7 +7585,21 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
|
||||||
|
|
||||||
testQuery(
|
testQuery(
|
||||||
"SELECT dim2 FROM druid.foo ORDER BY dim2 LIMIT 0",
|
"SELECT dim2 FROM druid.foo ORDER BY dim2 LIMIT 0",
|
||||||
ImmutableList.of(),
|
ImmutableList.of(
|
||||||
|
Druids.newScanQueryBuilder()
|
||||||
|
.dataSource(
|
||||||
|
InlineDataSource.fromIterable(
|
||||||
|
ImmutableList.of(),
|
||||||
|
RowSignature.builder().add("dim2", ValueType.STRING).build()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.intervals(querySegmentSpec(Filtration.eternity()))
|
||||||
|
.columns("dim2")
|
||||||
|
.resultFormat(ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
|
||||||
|
.legacy(false)
|
||||||
|
.context(QUERY_CONTEXT_DEFAULT)
|
||||||
|
.build()
|
||||||
|
),
|
||||||
ImmutableList.of()
|
ImmutableList.of()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue