This commit is contained in:
Zoltan Haindrich 2024-12-13 10:09:37 +00:00
parent 19609943aa
commit c51607e1b1
3 changed files with 19 additions and 15 deletions

View File

@ -101,7 +101,7 @@ public class DruidRelFieldTrimmer extends RelFieldTrimmer
ImmutableBitSet fieldsUsed,
Set<RelDataTypeField> extraFields)
{
if (trimTableScan) {
if (fieldsUsed.cardinality()>0 || trimTableScan) {
return super.trimFields(tableAccessRel, fieldsUsed, extraFields);
} else {
Mapping mapping = Mappings.createIdentity(tableAccessRel.getRowType().getFieldCount());

View File

@ -30,10 +30,11 @@ LogicalProject(arrayString=[CAST(ARRAY('a':VARCHAR, 'b':VARCHAR)):VARCHAR ARRAY]
LogicalProject(arrayStringNulls=[$0], uln=[$2], udn=[$3])
LogicalFilter(condition=[OR(=($2, 1), =($3, 2.2))])
LogicalUnnest(unnestExpr=[$1])
LogicalProject(arrayStringNulls=[$2], arrayDoubleNulls=[$6], uln=[$12])
LogicalUnnest(unnestExpr=[$4])
LogicalFilter(condition=[=($1, CAST(ARRAY('a', 'b')):VARCHAR ARRAY NOT NULL)])
LogicalTableScan(table=[[druid, arrays]])
LogicalProject(arrayStringNulls=[$0], arrayDoubleNulls=[$2], uln=[$3])
LogicalUnnest(unnestExpr=[$1])
LogicalProject(arrayStringNulls=[$2], arrayLongNulls=[$4], arrayDoubleNulls=[$6])
LogicalFilter(condition=[=($1, CAST(ARRAY('a', 'b')):VARCHAR ARRAY NOT NULL)])
LogicalTableScan(table=[[druid, arrays]])
!logicalPlan
DruidProject(arrayString=[CAST(ARRAY('a':VARCHAR, 'b':VARCHAR)):VARCHAR ARRAY], uln=[$1], udn=[$2], usn=[$3], druid=[logical])
@ -41,10 +42,11 @@ DruidProject(arrayString=[CAST(ARRAY('a':VARCHAR, 'b':VARCHAR)):VARCHAR ARRAY],
DruidProject(arrayStringNulls=[$0], uln=[$2], udn=[$3], druid=[logical])
DruidFilter(condition=[OR(=($2, 1), =($3, 2.2))])
DruidUnnest(unnestExpr=[$1])
DruidProject(arrayStringNulls=[$2], arrayDoubleNulls=[$6], uln=[$12], druid=[logical])
DruidUnnest(unnestExpr=[$4])
DruidFilter(condition=[=($1, CAST(ARRAY('a', 'b')):VARCHAR ARRAY NOT NULL)])
DruidTableScan(table=[[druid, arrays]], druid=[logical])
DruidProject(arrayStringNulls=[$0], arrayDoubleNulls=[$2], uln=[$3], druid=[logical])
DruidUnnest(unnestExpr=[$1])
DruidProject(arrayStringNulls=[$2], arrayLongNulls=[$4], arrayDoubleNulls=[$6], druid=[logical])
DruidFilter(condition=[=($1, CAST(ARRAY('a', 'b')):VARCHAR ARRAY NOT NULL)])
DruidTableScan(table=[[druid, arrays]], druid=[logical])
!druidPlan
{

View File

@ -18,14 +18,16 @@ SELECT uln, COUNT(*) FROM druid.arrays, UNNEST(arrayLongNulls) AS unnested(uln)
(1 row)
!ok
LogicalAggregate(group=[{12}], EXPR$1=[COUNT()])
LogicalUnnest(unnestExpr=[$4], filter=[=($0, 1)])
LogicalTableScan(table=[[druid, arrays]])
LogicalAggregate(group=[{1}], EXPR$1=[COUNT()])
LogicalUnnest(unnestExpr=[$0], filter=[=($0, 1)])
LogicalProject(arrayLongNulls=[$4])
LogicalTableScan(table=[[druid, arrays]])
!logicalPlan
DruidAggregate(group=[{12}], EXPR$1=[COUNT()], druid=[logical])
DruidUnnest(unnestExpr=[$4], filter=[=($0, 1)])
DruidTableScan(table=[[druid, arrays]], druid=[logical])
DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical])
DruidUnnest(unnestExpr=[$0], filter=[=($0, 1)])
DruidProject(arrayLongNulls=[$4], druid=[logical])
DruidTableScan(table=[[druid, arrays]], druid=[logical])
!druidPlan
{