diff --git a/optd-datafusion-repr/src/properties/schema.rs b/optd-datafusion-repr/src/properties/schema.rs index 6c1befd5..932da32f 100644 --- a/optd-datafusion-repr/src/properties/schema.rs +++ b/optd-datafusion-repr/src/properties/schema.rs @@ -117,18 +117,19 @@ impl SchemaPropertyBuilder { Schema { fields } } DfPredType::LogOp(_) => Schema { - fields: vec![Field::placeholder(); children.len()], + fields: vec![Field { + typ: ConstantType::Bool, + ..Field::placeholder() + }], + }, + DfPredType::BinOp(_) => Schema { + fields: vec![Field::placeholder()], }, - DfPredType::Cast => Schema { - fields: children[0] - .fields - .iter() - .map(|field| Field { - typ: children[1].fields[0].typ, - ..field.clone() - }) - .collect(), + fields: vec![Field { + typ: children[1].fields[0].typ, + ..children[0].fields[0].clone() + }], }, DfPredType::DataType(data_type) => Schema { fields: vec![Field { @@ -144,7 +145,9 @@ impl SchemaPropertyBuilder { // The real type should be the column type. fields: vec![Field::placeholder()], }, - _ => Schema { fields: vec![] }, + _ => Schema { + fields: vec![Field::placeholder()], // all predicates produce at least one column + }, } } } diff --git a/optd-sqllogictest/slt/tpch-q11.slt.disabled b/optd-sqllogictest/slt/tpch-q11.slt similarity index 100% rename from optd-sqllogictest/slt/tpch-q11.slt.disabled rename to optd-sqllogictest/slt/tpch-q11.slt diff --git a/optd-sqlplannertest/tests/tpch/tpch-11-15.planner.sql b/optd-sqlplannertest/tests/tpch/tpch-11-15.planner.sql index 235fe273..ec31472a 100644 --- a/optd-sqlplannertest/tests/tpch/tpch-11-15.planner.sql +++ b/optd-sqlplannertest/tests/tpch/tpch-11-15.planner.sql @@ -195,45 +195,46 @@ LogicalSort PhysicalSort ├── exprs:SortOrder { order: Desc } │ └── #1 -└── PhysicalNestedLoopJoin - ├── join_type: Inner - ├── cond:Gt - │ ├── Cast { cast_to: Decimal128(38, 15), child: #1 } - │ └── #0 - ├── PhysicalAgg - │ ├── aggrs:Agg(Sum) - │ │ └── Mul - │ │ ├── #2 - │ │ └── Cast { cast_to: Decimal128(10, 0), child: #1 } - │ ├── groups: [ #0 ] - │ └── PhysicalProjection { exprs: [ #11, #13, #14 ] } - │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #4 ], right_keys: [ #1 ] } - │ ├── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #3 ] } - │ │ ├── PhysicalFilter - │ │ │ ├── cond:Eq - │ │ │ │ ├── #1 - │ │ │ │ └── "CHINA" - │ │ │ └── PhysicalScan { table: nation } - │ │ └── PhysicalScan { table: supplier } - │ └── PhysicalScan { table: partsupp } - └── PhysicalProjection - ├── exprs:Cast - │ ├── cast_to: Decimal128(38, 15) - │ ├── child:Mul - │ │ ├── Cast { cast_to: Float64, child: #0 } - │ │ └── 0.0001(float) +└── PhysicalProjection { exprs: [ #1, #2 ] } + └── PhysicalNestedLoopJoin + ├── join_type: Inner + ├── cond:Gt + │ ├── Cast { cast_to: Decimal128(38, 15), child: #2 } + │ └── #0 + ├── PhysicalProjection + │ ├── exprs:Cast + │ │ ├── cast_to: Decimal128(38, 15) + │ │ ├── child:Mul + │ │ │ ├── Cast { cast_to: Float64, child: #0 } + │ │ │ └── 0.0001(float) + │ └── PhysicalAgg + │ ├── aggrs:Agg(Sum) + │ │ └── Mul + │ │ ├── #1 + │ │ └── Cast { cast_to: Decimal128(10, 0), child: #0 } + │ ├── groups: [] + │ └── PhysicalProjection { exprs: [ #13, #14 ] } + │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #4 ], right_keys: [ #1 ] } + │ ├── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #3 ] } + │ │ ├── PhysicalFilter + │ │ │ ├── cond:Eq + │ │ │ │ ├── #1 + │ │ │ │ └── "CHINA" + │ │ │ └── PhysicalScan { table: nation } + │ │ └── PhysicalScan { table: supplier } + │ └── PhysicalScan { table: partsupp } └── PhysicalAgg ├── aggrs:Agg(Sum) │ └── Mul - │ ├── #1 - │ └── Cast { cast_to: Decimal128(10, 0), child: #0 } - ├── groups: [] - └── PhysicalProjection { exprs: [ #0, #1 ] } - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #2 ], right_keys: [ #0 ] } - ├── PhysicalProjection { exprs: [ #1, #2, #4 ] } - │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ] } - │ ├── PhysicalProjection { exprs: [ #1, #2, #3 ] } + │ ├── #2 + │ └── Cast { cast_to: Decimal128(10, 0), child: #1 } + ├── groups: [ #0 ] + └── PhysicalProjection { exprs: [ #0, #1, #2 ] } + └── PhysicalHashJoin { join_type: Inner, left_keys: [ #3 ], right_keys: [ #0 ] } + ├── PhysicalProjection { exprs: [ #0, #2, #3, #5 ] } + │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #1 ], right_keys: [ #0 ] } + │ ├── PhysicalProjection { exprs: [ #0, #1, #2, #3 ] } │ │ └── PhysicalScan { table: partsupp } │ └── PhysicalProjection { exprs: [ #0, #3 ] } │ └── PhysicalScan { table: supplier } diff --git a/optd-sqlplannertest/tests/tpch/tpch-16-20.planner.sql b/optd-sqlplannertest/tests/tpch/tpch-16-20.planner.sql index c8a8deb8..a02c6b73 100644 --- a/optd-sqlplannertest/tests/tpch/tpch-16-20.planner.sql +++ b/optd-sqlplannertest/tests/tpch/tpch-16-20.planner.sql @@ -180,7 +180,7 @@ PhysicalProjection ├── cond:And │ ├── Eq │ │ ├── #0 - │ │ └── #13 + │ │ └── #26 │ └── Lt │ ├── Cast { cast_to: Decimal128(30, 15), child: #13 } │ └── #25