You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ro...@apache.org on 2023/03/30 18:07:37 UTC
[pinot] branch master updated: Type match between resultType and function's dataType (#10472)
This is an automated email from the ASF dual-hosted git repository.
rongr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new d97f2d92bc Type match between resultType and function's dataType (#10472)
d97f2d92bc is described below
commit d97f2d92bc6cdb1f6bafb7fd98f69afae1266caa
Author: Abhishek Sharma <ab...@spothero.com>
AuthorDate: Thu Mar 30 14:07:29 2023 -0400
Type match between resultType and function's dataType (#10472)
this fixes #10415.
---
.../runtime/operator/operands/FunctionOperand.java | 4 +++-
.../src/test/resources/queries/Case.json | 25 ++++++++++++++++------
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/operands/FunctionOperand.java b/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/operands/FunctionOperand.java
index b5852bad11..6d3fdda40a 100644
--- a/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/operands/FunctionOperand.java
+++ b/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/operands/FunctionOperand.java
@@ -50,8 +50,10 @@ public class FunctionOperand extends TransformOperand {
Preconditions.checkNotNull(functionInfo, "Cannot find function with Name: " + functionCall.getFunctionName());
_functionInvoker = new FunctionInvoker(functionInfo);
_resultName = computeColumnName(functionCall.getFunctionName(), _childOperandList);
- // TODO: Check type match between functionCall's data type and result type.
_resultType = FunctionUtils.getColumnDataType(_functionInvoker.getResultClass());
+ if (functionCall.getDataType() != FunctionUtils.getDataType(_functionInvoker.getResultClass())) {
+ _resultType = DataSchema.ColumnDataType.fromDataType(functionCall.getDataType(), true);
+ }
_reusableOperandHolder = new Object[operandExpressions.size()];
}
diff --git a/pinot-query-runtime/src/test/resources/queries/Case.json b/pinot-query-runtime/src/test/resources/queries/Case.json
index 82b7612c4f..eac0c1f222 100644
--- a/pinot-query-runtime/src/test/resources/queries/Case.json
+++ b/pinot-query-runtime/src/test/resources/queries/Case.json
@@ -7,13 +7,14 @@
{"name": "boolCol", "type": "BOOLEAN"},
{"name": "floatCol", "type": "FLOAT"},
{"name": "doubleCol", "type": "DOUBLE"},
+ {"name": "longCol", "type": "LONG"},
{"name": "strCol", "type": "STRING"}
],
"inputs": [
- [1, true, 2.0, 3.0, "one"],
- [2, false, 4.0, 6.0, "two"],
- [3, true, 6.0, 9.0, "three"],
- [4, false, 8.0, 12.0, "four"]
+ [1, true, 2.0, 3.0, 10, "one"],
+ [2, false, 4.0, 6.0, 20, "two"],
+ [3, true, 6.0, 9.0, 5, "three"],
+ [4, false, 8.0, 12.0, 2, "four"]
]
}
},
@@ -29,11 +30,23 @@
{ "sql": "SELECT intCol, CASE WHEN intCol % 2 = 0 THEN intCol ELSE intCol * 2 END AS intVal, strCol FROM {tbl1}"},
{ "sql": "SELECT intCol, CASE WHEN floatCol > 4.0 THEN floatCol ELSE floatCol / 2.0 END AS floatVal, strCol FROM {tbl1}"},
{ "sql": "SELECT intCol, CASE WHEN doubleCol > 6.0 THEN doubleCol ELSE doubleCol / 2.0 END AS doubleVal, strCol FROM {tbl1}"},
+ { "sql": "SELECT intCol, CASE WHEN floatCol < 10 THEN floatCol ELSE floatCol * 2 END AS doubleVal, strCol FROM {tbl1}"},
+ { "sql": "SELECT intCol, CASE WHEN floatCol < 10 THEN doubleCol ELSE floatCol * 2 END AS doubleVal, strCol FROM {tbl1}"},
+ { "sql": "SELECT intCol, CASE WHEN floatCol < 10 THEN floatCol * 4 ELSE doubleCol * 2 END AS doubleVal, strCol FROM {tbl1}"},
+ { "sql": "SELECT intCol, CASE WHEN doubleCol < 10 THEN floatCol * 4 ELSE floatCol * 2 END AS doubleVal, strCol FROM {tbl1}"},
+ { "sql": "SELECT intCol, CASE WHEN doubleCol < 10 THEN doubleCol * 4 ELSE floatCol * 2 END AS doubleVal, strCol FROM {tbl1}"},
+ { "sql": "SELECT intCol, CASE WHEN doubleCol < 1.3 THEN doubleCol ELSE doubleCol / 2.0 END AS doubleVal, strCol FROM {tbl1}"},
+ { "sql": "SELECT intCol, CASE WHEN longCol > 10 THEN longCol * 4 ELSE longCol * 2 END AS longVal, strCol FROM {tbl1}"},
+ { "sql": "SELECT intCol, CASE WHEN longCol > 10 THEN longCol * 4 ELSE intCol * 2 END AS longVal, strCol FROM {tbl1}"},
+ { "sql": "SELECT intCol, CASE WHEN intCol > 10 THEN longCol * 4 ELSE intCol * 2 END AS longVal, strCol FROM {tbl1}"},
+ { "sql": "SELECT intCol, CASE WHEN longCol > 10 THEN intCol * 4 ELSE longCol * 2 END AS longVal, strCol FROM {tbl1}"},
+ { "sql": "SELECT intCol, CASE WHEN longCol > 10 THEN longCol * 4 ELSE longCol * 2 END AS longVal, strCol FROM {tbl1} WHERE longCol < 10 and doubleCol < 1.3 and floatCol < 10"},
{
- "ignored": true,
"comment": "See https://github.com/apache/pinot/issues/10415 for more details",
"sql": "SELECT intCol, CASE WHEN (SELECT SUM(floatCol) FROM {tbl1}) > 16.0 THEN 'Large sum' ELSE 'Small sum' END AS aggVal, strCol FROM {tbl1}"
- }
+ },
+ { "sql": "SELECT intCol, CASE WHEN (SELECT SUM(floatCol) FROM {tbl1} WHERE longCol < 10 and doubleCol < 1.3 and floatCol < 10 ) > 16.0 THEN 'Large sum' ELSE 'Small sum' END AS aggVal, strCol FROM {tbl1}"},
+ { "sql": "with tmp as (select sum(floatCol) as float_sum from {tbl1} group by floatCol) select * from tmp where float_sum < 10" }
]
},
"nested_case_when_test": {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org