Skip to content

Commit

Permalink
Fix ROUND scalar function in the multi-stage query engine (apache#14284)
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmayya authored Oct 23, 2024
1 parent a1291a5 commit 604f767
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ public static PinotOperatorTable instance() {
SqlStdOperatorTable.DEGREES,
SqlStdOperatorTable.EXP,
SqlStdOperatorTable.RADIANS,
SqlStdOperatorTable.ROUND,
SqlStdOperatorTable.SIGN,
SqlStdOperatorTable.SIN,
SqlStdOperatorTable.TAN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ static Schema.SchemaBuilder getSchemaBuilder(String schemaName) {
.addSingleValueDimension("col2", FieldSpec.DataType.STRING, "")
.addSingleValueDimension("col5", FieldSpec.DataType.BOOLEAN, false)
.addDateTime("ts", FieldSpec.DataType.LONG, "1:MILLISECONDS:EPOCH", "1:HOURS")
.addDateTime("ts_timestamp", FieldSpec.DataType.TIMESTAMP, "1:MILLISECONDS:EPOCH", "1:HOURS")
.addMetric("col3", FieldSpec.DataType.INT, 0)
.addMetric("col4", FieldSpec.DataType.BIG_DECIMAL, 0)
.addMetric("col6", FieldSpec.DataType.INT, 0)
Expand Down Expand Up @@ -231,6 +232,7 @@ protected Object[][] provideQueries() {
"SELECT /*+ aggOptions(is_skip_leaf_stage_group_by='true') */ a.col2, a.col3 FROM a JOIN b "
+ "ON a.col1 = b.col1 WHERE a.col3 >= 0 GROUP BY a.col2, a.col3"
},
new Object[]{"SELECT ROUND(ts_timestamp, 10000) FROM a"}
};
}

Expand Down
18 changes: 9 additions & 9 deletions pinot-query-planner/src/test/resources/queries/JoinPlans.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"sql": "EXPLAIN PLAN FOR SELECT * FROM a JOIN b ON a.col1 = b.col2",
"output": [
"Execution Plan",
"\nLogicalJoin(condition=[=($0, $8)], joinType=[inner])",
"\nLogicalJoin(condition=[=($0, $9)], joinType=[inner])",
"\n PinotLogicalExchange(distribution=[hash[0]])",
"\n LogicalTableScan(table=[[default, a]])",
"\n PinotLogicalExchange(distribution=[hash[1]])",
Expand All @@ -55,7 +55,7 @@
"sql": "EXPLAIN PLAN FOR SELECT * FROM a JOIN b ON a.col1 = b.col2 WHERE a.col3 >= 0",
"output": [
"Execution Plan",
"\nLogicalJoin(condition=[=($0, $8)], joinType=[inner])",
"\nLogicalJoin(condition=[=($0, $9)], joinType=[inner])",
"\n PinotLogicalExchange(distribution=[hash[0]])",
"\n LogicalFilter(condition=[>=($2, 0)])",
"\n LogicalTableScan(table=[[default, a]])",
Expand All @@ -69,7 +69,7 @@
"sql": "EXPLAIN PLAN FOR SELECT * FROM a JOIN b ON a.col1 = b.col2 WHERE a.col3 >= 0 AND a.col3 > b.col3",
"output": [
"Execution Plan",
"\nLogicalJoin(condition=[AND(=($0, $8), >($2, $9))], joinType=[inner])",
"\nLogicalJoin(condition=[AND(=($0, $9), >($2, $10))], joinType=[inner])",
"\n PinotLogicalExchange(distribution=[hash[0]])",
"\n LogicalFilter(condition=[>=($2, 0)])",
"\n LogicalTableScan(table=[[default, a]])",
Expand All @@ -83,7 +83,7 @@
"sql": "EXPLAIN PLAN FOR SELECT * FROM a JOIN b on a.col1 = b.col1 AND a.col2 = b.col2",
"output": [
"Execution Plan",
"\nLogicalJoin(condition=[AND(=($0, $7), =($1, $8))], joinType=[inner])",
"\nLogicalJoin(condition=[AND(=($0, $8), =($1, $9))], joinType=[inner])",
"\n PinotLogicalExchange(distribution=[hash[0, 1]])",
"\n LogicalTableScan(table=[[default, a]])",
"\n PinotLogicalExchange(distribution=[hash[0, 1]])",
Expand Down Expand Up @@ -431,9 +431,9 @@
"sql": "EXPLAIN PLAN FOR WITH tmp1 AS ( SELECT * FROM a WHERE col2 NOT IN ('foo', 'bar') ) SELECT * FROM a WHERE col2 IN (SELECT col1 FROM tmp1) AND col2 IN (SELECT col1 FROM b WHERE col3 > 100) AND col3 IN (SELECT col3 from b WHERE col3 < 100)",
"output": [
"Execution Plan",
"\nLogicalJoin(condition=[=($2, $7)], joinType=[semi])",
"\n LogicalJoin(condition=[=($1, $7)], joinType=[semi])",
"\n LogicalJoin(condition=[=($1, $7)], joinType=[semi])",
"\nLogicalJoin(condition=[=($2, $8)], joinType=[semi])",
"\n LogicalJoin(condition=[=($1, $8)], joinType=[semi])",
"\n LogicalJoin(condition=[=($1, $8)], joinType=[semi])",
"\n LogicalTableScan(table=[[default, a]])",
"\n PinotLogicalExchange(distribution=[broadcast], relExchangeType=[PIPELINE_BREAKER])",
"\n LogicalProject(col1=[$0])",
Expand Down Expand Up @@ -505,8 +505,8 @@
"sql": "EXPLAIN PLAN FOR WITH tmp1 AS ( SELECT * FROM a WHERE col2 NOT IN ('foo', 'bar') ), tmp2 AS ( SELECT * FROM b WHERE col1 IN (SELECT col1 FROM tmp1) AND col3 < 100 ) SELECT * FROM tmp2 WHERE col3 IN (SELECT col3 from tmp1)",
"output": [
"Execution Plan",
"\nLogicalJoin(condition=[=($2, $7)], joinType=[semi])",
"\n LogicalJoin(condition=[=($0, $7)], joinType=[semi])",
"\nLogicalJoin(condition=[=($2, $8)], joinType=[semi])",
"\n LogicalJoin(condition=[=($0, $8)], joinType=[semi])",
"\n LogicalFilter(condition=[<($2, 100)])",
"\n LogicalTableScan(table=[[default, b]])",
"\n PinotLogicalExchange(distribution=[broadcast], relExchangeType=[PIPELINE_BREAKER])",
Expand Down

0 comments on commit 604f767

Please sign in to comment.