This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new adc9ef4cd94 branch-4.1: [enhance](variant) add condition cache for
variant type #60532 (#61542)
adc9ef4cd94 is described below
commit adc9ef4cd94fb5a22a1822f0092ac0a788defe4b
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Mar 20 14:27:58 2026 +0800
branch-4.1: [enhance](variant) add condition cache for variant type #60532
(#61542)
Cherry-picked from #60532
Co-authored-by: Sun Chenyang <[email protected]>
---
be/src/vec/exprs/vslot_ref.cpp | 3 --
regression-test/data/variant_p0/multi_var.out | 36 ++++++++++++++++++++++
regression-test/suites/variant_p0/multi_var.groovy | 24 ++++++++++++++-
3 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/be/src/vec/exprs/vslot_ref.cpp b/be/src/vec/exprs/vslot_ref.cpp
index 173f889b0c8..91969165422 100644
--- a/be/src/vec/exprs/vslot_ref.cpp
+++ b/be/src/vec/exprs/vslot_ref.cpp
@@ -138,9 +138,6 @@ bool VSlotRef::equals(const VExpr& other) {
}
uint64_t VSlotRef::get_digest(uint64_t seed) const {
- if (_data_type->get_primitive_type() == TYPE_VARIANT) {
- return 0;
- }
seed = HashUtil::hash64(&_column_uniq_id, sizeof(int), seed);
return HashUtil::hash64(_column_name->c_str(), _column_name->size(), seed);
}
diff --git a/regression-test/data/variant_p0/multi_var.out
b/regression-test/data/variant_p0/multi_var.out
index 18e31a4a5a5..70033d66399 100644
--- a/regression-test/data/variant_p0/multi_var.out
+++ b/regression-test/data/variant_p0/multi_var.out
@@ -35,3 +35,39 @@
\N \N \N 123 \N \N
\N \N \N 123 elden ring \N
+-- !sql_condition_cache1 --
+600
+
+-- !sql_condition_cache2 --
+600
+
+-- !sql_condition_cache3 --
+700
+
+-- !sql_condition_cache4 --
+700
+
+-- !sql_condition_cache5 --
+600
+
+-- !sql_condition_cache6 --
+600
+
+-- !sql_condition_cache7 --
+700
+
+-- !sql_condition_cache8 --
+700
+
+-- !sql_condition_cache9 --
+0
+
+-- !sql_condition_cache10 --
+0
+
+-- !sql_condition_cache11 --
+700
+
+-- !sql_condition_cache12 --
+700
+
diff --git a/regression-test/suites/variant_p0/multi_var.groovy
b/regression-test/suites/variant_p0/multi_var.groovy
index 91d5810a670..ef56aa68dae 100644
--- a/regression-test/suites/variant_p0/multi_var.groovy
+++ b/regression-test/suites/variant_p0/multi_var.groovy
@@ -25,7 +25,7 @@ suite("regression_test_variant_multi_var", "variant_type"){
)
DUPLICATE KEY(`k`)
DISTRIBUTED BY HASH(k) BUCKETS 4
- properties("replication_num" = "1");
+ properties("replication_num" = "1", "disable_auto_compaction" =
"true");
"""
sql """INSERT INTO ${table_name} SELECT *, '{"k1":1, "k2": "hello world",
"k3" : [1234], "k4" : 1.10000, "k5" : [[123]]}' FROM numbers("number" =
"101")"""
sql """INSERT INTO ${table_name} SELECT *, '{"k7":123, "k8": "elden ring",
"k9" : 1.1112, "k10" : [1.12], "k11" : ["moon"]}' FROM numbers("number" =
"203") where number > 100"""
@@ -45,4 +45,26 @@ suite("regression_test_variant_multi_var", "variant_type"){
for (int i = 0; i < 20; i++) {
sql """insert into ${table_name} values (1, '{"a" : 1}', '{"a" : 1}',
'{"a" : 1}', '{"a" : 1}', '{"a" : 1}')"""
}
+
+ trigger_and_wait_compaction(table_name, "full")
+
+ sql "set enable_condition_cache = true"
+ sql "set enable_sql_cache = false"
+ qt_sql_condition_cache1 """select count() from ${table_name} where
cast(v3['k1'] as bigint) = 1 and cast(v2['k2'] as string) = 'hello world' """
+ qt_sql_condition_cache2 """select count() from ${table_name} where
cast(v3['k1'] as bigint) = 1 and cast(v2['k2'] as string) = 'hello world' """
+
+ qt_sql_condition_cache3 """select count() from ${table_name} where
cast(v3['k1'] as bigint) = 1 or cast(v2['k2'] as string) = 'hello world' """
+ qt_sql_condition_cache4 """select count() from ${table_name} where
cast(v3['k1'] as bigint) = 1 or cast(v2['k2'] as string) = 'hello world' """
+
+ qt_sql_condition_cache5 """select count() from ${table_name} where
cast(v3['k1'] as bigint) = 1 and cast(v3['k2'] as string) = 'hello world' """
+ qt_sql_condition_cache6 """select count() from ${table_name} where
cast(v3['k1'] as bigint) = 1 and cast(v3['k2'] as string) = 'hello world' """
+
+ qt_sql_condition_cache7 """select count() from ${table_name} where
cast(v2['k1'] as bigint) = 1 or cast(v2['k2'] as string) = 'hello world' """
+ qt_sql_condition_cache8 """select count() from ${table_name} where
cast(v2['k1'] as bigint) = 1 or cast(v2['k2'] as string) = 'hello world' """
+
+ qt_sql_condition_cache9 """select count() from ${table_name} where
cast(v2['k2'] as string) = 'hello world' and array_contains(cast(v3['k11'] as
array<string>), 'moon') """
+ qt_sql_condition_cache10 """select count() from ${table_name} where
cast(v2['k2'] as string) = 'hello world' and array_contains(cast(v3['k11'] as
array<string>), 'moon') """
+
+ qt_sql_condition_cache11 """select count() from ${table_name} where
cast(v2['k1'] as bigint) = 1 or cast(v2['k1'] as double) < 2.0 """
+ qt_sql_condition_cache12 """select count() from ${table_name} where
cast(v2['k1'] as bigint) = 1 or cast(v2['k1'] as double) < 2.0 """
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]