This is an automated email from the ASF dual-hosted git repository.
eldenmoon pushed a commit to branch branch-2.0-var
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0-var by this push:
new 35b9cd5a422 [Fix](variant) fix groupby multi variant columns leading
to error (#26023)
35b9cd5a422 is described below
commit 35b9cd5a42200c9403f3407d29aac3727ce3398a
Author: lihangyu <[email protected]>
AuthorDate: Mon Oct 30 14:09:30 2023 +0800
[Fix](variant) fix groupby multi variant columns leading to error (#26023)
```
ERROR 1105 (HY000): errCode = 2, detailMessage = select list expression not
produced by aggregation output (missing from GROUP BY clause?): CAST(`var` AS
TEXT)
```
The hash code of slot ref should consider sub column names
---
fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java | 9 ++++++++-
regression-test/suites/variant_p0/load.groovy | 3 +++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java
index 9a7d7308d35..27088de26f3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java
@@ -341,7 +341,14 @@ public class SlotRef extends Expr {
if (desc != null) {
return desc.getId().hashCode();
}
- return Objects.hashCode((tblName == null ? "" : tblName.toSql() + "."
+ label).toLowerCase());
+ if (subColLables == null || subColLables.isEmpty()) {
+ return Objects.hashCode((tblName == null ? "" : tblName.toSql() +
"." + label).toLowerCase());
+ }
+ int result = Objects.hashCode((tblName == null ? "" : tblName.toSql()
+ "." + label).toLowerCase());
+ for (String sublabel : subColLables) {
+ result = 31 * result + Objects.hashCode(sublabel);
+ }
+ return result;
}
@Override
diff --git a/regression-test/suites/variant_p0/load.groovy
b/regression-test/suites/variant_p0/load.groovy
index a014911034c..5501347a51a 100644
--- a/regression-test/suites/variant_p0/load.groovy
+++ b/regression-test/suites/variant_p0/load.groovy
@@ -449,6 +449,9 @@ suite("regression_test_variant", "variant_type"){
sql """insert into var_index values(7, '{"a1" : 0, "b1": 3}', 'hello
world'), (8, '{"a2" : 123}', 'world'),(9, '{"a3" : 123}', 'hello world')"""
qt_sql_inv6 """select * from ${table_name} order by k desc limit 4"""
+ // test groupby with multiple variants
+ sql """select cast(v:xxx as int), cast(v:yyy as text) from
${table_name} group by cast(v:xxx as int), cast(v:yyy as text)"""
+
} finally {
// reset flags
set_be_config.call("max_filter_ratio_for_variant_parsing", "0.05")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]