This is an automated email from the ASF dual-hosted git repository.
HappenLee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new b70ed797c16 [fix](query) Preserve session settings in point queries
and BE constant folding (#70941)
b70ed797c16 is described below
commit b70ed797c16be6f3c99815b1ed3fdc175a225253
Author: Jerry Hu <[email protected]>
AuthorDate: Tue Dec 1 19:03:21 2026 +0800
[fix](query) Preserve session settings in point queries and BE constant
folding (#70941)
### Background
Short-circuit point queries fetch rows by primary key and can cache both
the FE's output expressions and the BE's execution context for a
prepared statement. Nereids can also ask the BE to evaluate constant
expressions while planning. See [High-Concurrency Point
Query](https://doris.apache.org/docs/4.x/query-acceleration/high-concurrent-point-query/).
### What problem does this PR solve?
Issue Number: None
Related PR: #56915 (introduced localized date names), #66788 (introduced
the Hyperscan fallback setting), #60913 (related time zone propagation),
#70345 (added time zone cache checks)
PR Type: Bugfix
Problem Summary:
Point lookups and BE constant folding can use the wrong date-name
locale, and BE folding can use a regex fallback the session disabled. In
addition, long localized UTF-8 names can exceed the space allocated for
English names. Forward the session settings, refresh the FE plan and BE
context when the locale changes, and size the output for the active
locale.
The prepared regression evaluates a stored date and a date computed by
constant folding:
```sql
SELECT MONTHNAME(d),
MONTHNAME(STR_TO_DATE(CONCAT('2026-11-', CAST(10 + CRC32('a') % 10
AS STRING)), '%Y-%m-%d'))
FROM t WHERE id = ?;
```
With BE folding enabled, prepare once and execute the same statement
under `zh_CN`, then under `en_US`, with `d = '2026-11-17'`.
| Earlier result after the switch | With the fix |
|---|---|
| `November, 十一月` | `November, November` |
### Details
- **Change map:** Production +52/-13, tests +557/-8, and 198 generated
expected-output lines. The three commits cover session propagation and
BE cache matching (+27/-6 production lines), localized UTF-8 sizing
(+16/-4), and FE prepared-plan invalidation (+9/-3).
- **Frequency:** Reproducible when an optimized request omits a setting
that affects its result, when a reused prepared plan contains a literal
folded under the previous locale, or when a localized name exceeds the
English byte bound.
- **Root cause:** `PointQueryExecutor` omitted the locale and
`FoldConstantRuleOnBE` omitted the locale and fallback option. Even when
the BE receives a new locale, it cannot reevaluate a literal in the
cached `ShortCircuitQueryContext`. The date-name functions allocated
using English size limits but copied localized ICU strings.
- **Why existing tests missed it:** Point-query unit tests covered key
binding and cache reuse without changing locale.
`FoldConstantRuleOnBETest` checked expression selection before the RPC,
and date-name BE unit tests used English. The SQL suites did not combine
a locale switch, server-side prepared point queries, and a
constant-folded projection.
- **Fix:** Forward settings on the applicable optimized requests. Keep
the existing BE cache rebuild and lookup retry, and invalidate the FE
plan separately so folded literals are recomputed. Size `DAYNAME()` and
`MONTHNAME()` using the longest UTF-8 name for the active locale.
- **Other paths and branches:** Ordinary query execution already
forwards the settings. The locale omissions and fixed buffer sizing were
found on 4.0, 4.1, and 4.2; the Hyperscan omission was found on 4.1 and
4.2. Branch 3.1 predates both settings. Backports must account for cache
differences and preserve optional Protobuf field ID 10.
### Testing
- Local FE unit tests: 20 passed across `ShortCircuitQueryContextTest`,
`SessionContextRequestTest`, and `ExecuteCommandTest`.
- Local `test_point_query_lc_time_names`: the earlier FE package
reproduced the wrong folded literal in both lookup modes and failed the
comparison. The rebuilt FE passed with the existing ASAN BE, using the
same server-prepared statement across locale switches in both modes.
- Local `test_point_query_date_name_capacity` and
`test_be_fold_session_context`: passed on the same cluster. No BE
rebuild, cloud tests, or formal rolling-upgrade tests were run for the
FE follow-up.
### Release note
Correct date names in short-circuit point queries and BE constant
folding, including when a prepared statement is reused after a session
locale change, and honor disabled Hyperscan fallback during folding.
### Check List (For Author)
- Behavior changed: No
- Does this need documentation: No
- Pre-submission status: Ready
### AI Disclosure
- Tool: OpenAI Codex
- Generated: Code, tests, and description
- Human review: not stated
---
.../function_date_or_datetime_to_string.cpp | 20 ++-
be/src/runtime/runtime_state.h | 1 +
be/src/service/point_query_executor.cpp | 21 ++-
be/src/service/point_query_executor.h | 6 +-
be/test/exprs/function/function_time_test.cpp | 82 +++++++++++
be/test/runtime/fold_constant_executor_test.cpp | 43 ++++++
be/test/service/point_query_exector_test.cpp | 38 ++++-
be/test/testutil/function_utils.cpp | 1 +
.../expression/rules/FoldConstantRuleOnBE.java | 2 +
.../org/apache/doris/qe/PointQueryExecutor.java | 1 +
.../apache/doris/qe/ShortCircuitQueryContext.java | 9 +-
.../java/org/apache/doris/qe/StmtExecutor.java | 3 +-
.../trees/plans/commands/ExecuteCommandTest.java | 3 +-
.../apache/doris/qe/SessionContextRequestTest.java | 161 +++++++++++++++++++++
.../doris/qe/ShortCircuitQueryContextTest.java | 20 ++-
gensrc/proto/internal_service.proto | 2 +
.../test_point_query_date_name_capacity.out | 132 +++++++++++++++++
.../test_point_query_lc_time_names.out | 48 ++++++
.../fold_constant/test_be_fold_session_context.out | 18 +++
.../test_point_query_date_name_capacity.groovy | 81 +++++++++++
.../test_point_query_lc_time_names.groovy | 77 ++++++++++
.../test_be_fold_session_context.groovy | 59 ++++++++
22 files changed, 807 insertions(+), 21 deletions(-)
diff --git a/be/src/exprs/function/function_date_or_datetime_to_string.cpp
b/be/src/exprs/function/function_date_or_datetime_to_string.cpp
index 1fc78a74cdd..3c54d5c4f66 100644
--- a/be/src/exprs/function/function_date_or_datetime_to_string.cpp
+++ b/be/src/exprs/function/function_date_or_datetime_to_string.cpp
@@ -22,6 +22,7 @@
#include <unicode/locid.h>
#include <unicode/unistr.h>
+#include <algorithm>
#include <cstddef>
#include <memory>
#include <utility>
@@ -88,6 +89,8 @@ public:
std::string locale_name;
std::vector<std::string> day_name_storage {7};
std::vector<std::string> month_name_storage {13};
+ size_t max_day_name_bytes = 0;
+ size_t max_month_name_bytes = 0;
const char* day_names[7];
const char* month_names[13];
};
@@ -99,9 +102,6 @@ public:
auto state = std::make_shared<LocaleDayMonthNameState>();
state->locale_name = context->state()->lc_time_names();
-#ifdef BE_TEST
- state->locale_name = "en_US";
-#endif
UErrorCode status = U_ZERO_ERROR;
icu::Locale locale(state->locale_name.c_str());
icu::DateFormatSymbols symbols(locale, status);
@@ -120,6 +120,8 @@ public:
}
for (int i = 0; i < MONTH_NUM_IN_ICU; ++i) {
months[i].toUTF8String(state->month_name_storage[i + 1]);
+ state->max_month_name_bytes =
+ std::max(state->max_month_name_bytes,
state->month_name_storage[i + 1].size());
state->month_names[i + 1] = state->month_name_storage[i +
1].c_str();
}
@@ -128,9 +130,13 @@ public:
for (int i = 1; i < DAY_NUM_IN_ICU; ++i) {
if (i == 1) {
days[i].toUTF8String(state->day_name_storage[6]);
+ state->max_day_name_bytes =
+ std::max(state->max_day_name_bytes,
state->day_name_storage[6].size());
state->day_names[6] = state->day_name_storage[6].c_str();
} else {
days[i].toUTF8String(state->day_name_storage[i - 2]);
+ state->max_day_name_bytes =
+ std::max(state->max_day_name_bytes,
state->day_name_storage[i - 2].size());
state->day_names[i - 2] = state->day_name_storage[i -
2].c_str();
}
}
@@ -180,19 +186,25 @@ private:
ColumnString::Chars& res_data, ColumnString::Offsets&
res_offsets,
const NullMap* null_map = nullptr) {
const auto len = ts.size();
- res_data.resize(len * Transform::max_size);
res_offsets.resize(len);
size_t offset = 0;
auto* state = reinterpret_cast<LocaleDayMonthNameState*>(
context->get_function_state(FunctionContext::FunctionStateScope::FRAGMENT_LOCAL));
+ size_t max_bytes = Transform::max_size;
const char* const* names_ptr = nullptr;
if constexpr (std::is_same_v<Transform,
DayNameImpl<Transform::OpArgType>>) {
names_ptr = state->day_names;
+ max_bytes = state->max_day_name_bytes;
} else if constexpr (std::is_same_v<Transform,
MonthNameImpl<Transform::OpArgType>>) {
names_ptr = state->month_names;
+ max_bytes = state->max_month_name_bytes;
}
+ // Localized names can exceed the English byte bound (e.g. ru_RU
Sunday is 22 bytes).
+ // Allocate the locale-specific UTF-8 bound before any transform
writes into the buffer.
+ res_data.resize(len * max_bytes);
+
for (size_t i = 0; i < len; ++i) {
if (null_map && (*null_map)[i]) {
res_offsets[i] = cast_set<UInt32>(offset);
diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h
index 7231d0807f6..71d440b66b2 100644
--- a/be/src/runtime/runtime_state.h
+++ b/be/src/runtime/runtime_state.h
@@ -251,6 +251,7 @@ public:
DORIS_CHECK(TimezoneUtils::find_cctz_time_zone(_timezone,
_timezone_obj));
}
const std::string& lc_time_names() const { return _lc_time_names; }
+ void set_lc_time_names(const std::string& lc_time_names) { _lc_time_names
= lc_time_names; }
const TUniqueId& query_id() const { return _query_id; }
const TUniqueId& fragment_instance_id() const { return
_fragment_instance_id; }
// should only be called in pipeline engine
diff --git a/be/src/service/point_query_executor.cpp
b/be/src/service/point_query_executor.cpp
index 8a873a09e85..b16de726306 100644
--- a/be/src/service/point_query_executor.cpp
+++ b/be/src/service/point_query_executor.cpp
@@ -137,11 +137,13 @@ static void extract_slot_ref(const VExprSPtr& expr,
TupleDescriptor* tuple_desc,
Status Reusable::init(const TDescriptorTable& t_desc_tbl, const
std::vector<TExpr>& output_exprs,
const TQueryOptions& query_options, const std::string&
timezone,
- const TabletSchema& schema, size_t block_size) {
+ const std::string& lc_time_names, const TabletSchema&
schema,
+ size_t block_size) {
_runtime_state = RuntimeState::create_unique();
_runtime_state->set_query_options(query_options);
// Python UDF open binds schemas such as timestamp[us, tz=UTC] to this
state.
_runtime_state->set_timezone(timezone);
+ _runtime_state->set_lc_time_names(lc_time_names);
RETURN_IF_ERROR(DescriptorTbl::create(_runtime_state->obj_pool(),
t_desc_tbl, &_desc_tbl));
_runtime_state->set_desc_tbl(_desc_tbl);
for (const auto* slot : tuple_desc()->slots()) {
@@ -305,6 +307,12 @@ void
PointQueryExecutor::_init_remote_scan_cache_write_limiter() {
}
}
+bool Reusable::matches_timezone_and_locale(const std::string& timezone,
+ const std::string& lc_time_names)
const {
+ return _runtime_state->timezone() == timezone &&
+ _runtime_state->lc_time_names() == lc_time_names;
+}
+
Status PointQueryExecutor::init(const PTabletKeyLookupRequest* request,
PTabletKeyLookupResponse* response) {
SCOPED_TIMER(&_profile_metrics.init_ns);
@@ -317,11 +325,14 @@ Status PointQueryExecutor::init(const
PTabletKeyLookupRequest* request,
const auto& timezone = request->has_time_zone() &&
!request->time_zone().empty()
? request->time_zone()
: TimezoneUtils::default_time_zone;
+ const auto& lc_time_names = request->lc_time_names();
_binary_row_format = request->is_binary_row();
_tablet = DORIS_TRY(ExecEnv::get_tablet(request->tablet_id()));
- // SET time_zone='UTC' can reuse a prepared UUID whose cached client uses
+08:00.
- // Rebuild on timezone changes; existing requests retain their original
contexts.
- if (cache_handle != nullptr && cache_handle->runtime_state()->timezone()
== timezone) {
+ // SET time_zone or lc_time_names can reuse the same prepared UUID, but
expressions
+ // capture these settings at open (e.g. monthname changes from zh_CN to
en_US).
+ // Rebuild on changes; existing requests retain their original contexts.
+ if (cache_handle != nullptr &&
+ cache_handle->matches_timezone_and_locale(timezone, lc_time_names)) {
_reusable = cache_handle;
_profile_metrics.hit_lookup_cache = true;
} else {
@@ -365,7 +376,7 @@ Status PointQueryExecutor::init(const
PTabletKeyLookupRequest* request,
&t_query_options));
}
RETURN_IF_ERROR(reusable_ptr->init(t_desc_tbl, t_output_exprs.exprs,
t_query_options,
- timezone,
*_tablet->tablet_schema(), 1));
+ timezone, lc_time_names,
*_tablet->tablet_schema(), 1));
if (uuid != 0) {
LookupConnectionCache::instance()->add(uuid, reusable_ptr);
}
diff --git a/be/src/service/point_query_executor.h
b/be/src/service/point_query_executor.h
index 2ab958c46b7..701a3030b42 100644
--- a/be/src/service/point_query_executor.h
+++ b/be/src/service/point_query_executor.h
@@ -73,7 +73,11 @@ public:
Status init(const TDescriptorTable& t_desc_tbl, const std::vector<TExpr>&
output_exprs,
const TQueryOptions& query_options, const std::string&
timezone,
- const TabletSchema& schema, size_t block_size = 1);
+ const std::string& lc_time_names, const TabletSchema& schema,
+ size_t block_size = 1);
+
+ bool matches_timezone_and_locale(const std::string& timezone,
+ const std::string& lc_time_names) const;
std::unique_ptr<Block> get_block();
diff --git a/be/test/exprs/function/function_time_test.cpp
b/be/test/exprs/function/function_time_test.cpp
index 876538cad65..c47c3b88298 100644
--- a/be/test/exprs/function/function_time_test.cpp
+++ b/be/test/exprs/function/function_time_test.cpp
@@ -1867,6 +1867,88 @@ TEST(VTimestampFunctionsTest, dayname_test) {
}
}
+TEST(VTimestampFunctionsTest, localized_date_name_capacity) {
+ const std::array<std::array<const char*, 3>, 3> locales {{{"ru_RU",
"воскресенье", "сентября"},
+ {"zh_CN", "星期日",
"九月"},
+ {"en_US",
"Sunday", "September"}}};
+ for (const auto primitive : {TYPE_DATEV2, TYPE_DATETIMEV2,
TYPE_TIMESTAMP_NS}) {
+ for (const bool nullable : {false, true}) {
+ const auto type =
DataTypeFactory::instance().create_data_type(primitive, nullable);
+ const auto return_type = nullable ?
make_nullable(std::make_shared<DataTypeString>())
+ :
std::make_shared<DataTypeString>();
+ for (const auto& locale : locales) {
+ for (const auto* function : {"dayname", "monthname"}) {
+ const std::string expected = locale[std::string(function)
== "dayname" ? 1 : 2];
+ for (const size_t rows : {0, 1, 1024}) {
+ for (const bool constant : {false, true}) {
+ SCOPED_TRACE(testing::Message()
+ << type->get_name() << " " <<
locale[0] << " " << function
+ << " rows=" << rows << " constant="
<< constant);
+ auto column = type->create_column();
+ for (size_t row = 0; row < (constant ? 1 : rows);
++row) {
+ if (nullable && !constant && row % 7 == 1) {
+ column->insert_default();
+ } else {
+ const std::string date = primitive ==
TYPE_DATEV2
+ ?
"2026-09-20"
+ :
"2026-09-20 12:34:56";
+ ASSERT_TRUE(insert_cell(column, type,
date));
+ }
+ }
+ if (constant) {
+ column =
ColumnConst::create(std::move(column), rows);
+ }
+ Block block {{std::move(column), type, "date"},
+ {nullptr, return_type, "result"}};
+ auto func =
SimpleFunctionFactory::instance().get_function(
+ function, {block.get_by_position(0)},
return_type);
+ ASSERT_NE(func, nullptr);
+ FunctionUtils utils(return_type, {type}, false);
+ auto* context = utils.get_fn_ctx();
+ context->state()->set_lc_time_names(locale[0]);
+ ASSERT_TRUE(
+ func->open(context,
+
FunctionContext::FunctionStateScope::FRAGMENT_LOCAL)
+ .ok());
+ ASSERT_TRUE(
+ func->open(context,
+
FunctionContext::FunctionStateScope::THREAD_LOCAL)
+ .ok());
+ ASSERT_TRUE(func->execute(context, block, {0}, 1,
rows).ok());
+ const auto result = block.get_by_position(1)
+
.column->convert_to_full_column_if_const();
+ ASSERT_EQ(result->size(), rows);
+ const auto& strings = assert_cast<const
ColumnString&>(
+ nullable ? assert_cast<const
ColumnNullable&>(*result)
+ .get_nested_column()
+ : *result);
+ size_t offset = 0;
+ for (size_t row = 0; row < rows; ++row) {
+ const bool is_null = nullable && !constant &&
row % 7 == 1;
+ EXPECT_EQ(result->is_null_at(row), is_null);
+ if (!is_null) {
+
EXPECT_EQ(strings.get_data_at(row).to_string(), expected);
+ offset += expected.size();
+ }
+ EXPECT_EQ(strings.get_offsets()[row], offset);
+ }
+ EXPECT_EQ(strings.get_chars().size(), offset);
+ ASSERT_TRUE(
+ func->close(context,
+
FunctionContext::FunctionStateScope::THREAD_LOCAL)
+ .ok());
+ ASSERT_TRUE(
+ func->close(context,
+
FunctionContext::FunctionStateScope::FRAGMENT_LOCAL)
+ .ok());
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
TEST(VTimestampFunctionsTest, datetrunc_test) {
std::string func_name = "date_trunc";
{
diff --git a/be/test/runtime/fold_constant_executor_test.cpp
b/be/test/runtime/fold_constant_executor_test.cpp
index 214044530a5..e22eac6edda 100644
--- a/be/test/runtime/fold_constant_executor_test.cpp
+++ b/be/test/runtime/fold_constant_executor_test.cpp
@@ -22,6 +22,7 @@
#include <gen_cpp/internal_service.pb.h>
#include <gtest/gtest.h>
+#include <array>
#include <map>
#include <string>
#include <utility>
@@ -83,5 +84,47 @@ TEST(FoldConstantExecutorTest, LegacyTimeStampNsResult) {
}
}
+TEST(FoldConstantExecutorTest, LocalizedDateNames) {
+ const std::array<std::array<const char*, 3>, 3> locales {{{"ru_RU",
"воскресенье", "сентября"},
+ {"zh_CN", "星期日",
"九月"},
+ {"en_US",
"Sunday", "September"}}};
+ for (const auto& locale : locales) {
+ TFoldConstantParams params;
+ params.query_globals.__set_now_string("2026-09-20 00:00:00");
+ params.query_globals.__set_time_zone("UTC");
+ params.query_globals.__set_lc_time_names(locale[0]);
+ // Decode strings directly so FE evaluation cannot hide a missing BE
locale.
+ params.__set_is_nereids(false);
+ for (const auto* name : {"dayname", "monthname"}) {
+ TFunctionName function_name;
+ function_name.__set_function_name(name);
+ TFunction function;
+ function.__set_name(function_name);
+ function.__set_binary_type(TFunctionBinaryType::BUILTIN);
+ function.__set_arg_types({create_type_desc(TYPE_TIMESTAMP_NS)});
+ function.__set_ret_type(create_type_desc(TYPE_STRING));
+ TExprNode call;
+ call.__set_node_type(TExprNodeType::FUNCTION_CALL);
+ call.__set_type(create_type_desc(TYPE_STRING));
+ call.__set_is_nullable(false);
+ call.__set_num_children(1);
+ call.__set_fn(function);
+ auto expression = timestamp_ns_literal_expr("2026-09-20
12:34:56.123456789");
+ expression.nodes.insert(expression.nodes.begin(), std::move(call));
+ params.expr_map["names"].emplace(name, std::move(expression));
+ }
+ PConstantExprResult response;
+ FoldConstantExecutor executor;
+ const auto status = executor.fold_constant_vexpr(params, &response);
+ ASSERT_TRUE(status.ok()) << status;
+ const auto& results = response.expr_result_map().at("names").map();
+ ASSERT_EQ(results.size(), 2);
+ EXPECT_TRUE(results.at("dayname").success());
+ EXPECT_TRUE(results.at("monthname").success());
+ EXPECT_EQ(results.at("dayname").content(), locale[1]);
+ EXPECT_EQ(results.at("monthname").content(), locale[2]);
+ }
+}
+
} // namespace
} // namespace doris
diff --git a/be/test/service/point_query_exector_test.cpp
b/be/test/service/point_query_exector_test.cpp
index aafe4da0a97..c737b6d84f7 100644
--- a/be/test/service/point_query_exector_test.cpp
+++ b/be/test/service/point_query_exector_test.cpp
@@ -249,7 +249,8 @@ public:
return dtb.desc_tbl();
}
- static std::shared_ptr<Reusable> create_reusable(const std::string&
timezone = "+08:00") {
+ static std::shared_ptr<Reusable> create_reusable(const std::string&
timezone = "+08:00",
+ const std::string&
lc_time_names = "") {
auto obj_pool = std::make_unique<ObjectPool>();
auto runtime_state = RuntimeState::create_unique();
auto reusable = std::make_shared<Reusable>();
@@ -258,7 +259,7 @@ public:
TDescriptorTable t_desc_tbl = create_descriptor_tablet();
// Initialize Reusable
- Status st = reusable->init(t_desc_tbl, output_exprs, query_options,
timezone,
+ Status st = reusable->init(t_desc_tbl, output_exprs, query_options,
timezone, lc_time_names,
*tablet_schema, 2);
if (!st.ok()) {
return nullptr;
@@ -485,6 +486,37 @@ TEST_F(LookupConnectionCacheTest, PQTestInvalidKeys) {
cache.add(1, large_reusable);
}
+// Replacing a locale-specific context must not mutate in-flight requests.
+TEST_F(LookupConnectionCacheTest, PQTestLocaleContext) {
+ const __int128 uuid = 302;
+ auto chinese = ReusableTestHelper::create_reusable("UTC", "zh_CN");
+ ASSERT_NE(chinese, nullptr);
+ EXPECT_EQ(chinese->runtime_state()->lc_time_names(), "zh_CN");
+ EXPECT_TRUE(chinese->matches_timezone_and_locale("UTC", "zh_CN"));
+ EXPECT_FALSE(chinese->matches_timezone_and_locale("UTC", "en_US"));
+ EXPECT_FALSE(chinese->matches_timezone_and_locale("+08:00", "zh_CN"));
+ _lookup_cache->add(uuid, chinese);
+ auto retained = _lookup_cache->get(uuid);
+ ASSERT_EQ(retained, chinese);
+
+ auto english = ReusableTestHelper::create_reusable("UTC", "en_US");
+ ASSERT_NE(english, nullptr);
+ _lookup_cache->add(uuid, english);
+ auto current = _lookup_cache->get(uuid);
+ ASSERT_EQ(current, english);
+ EXPECT_TRUE(current->matches_timezone_and_locale("UTC", "en_US"));
+ EXPECT_FALSE(current->matches_timezone_and_locale("UTC", "zh_CN"));
+ EXPECT_EQ(retained->runtime_state()->lc_time_names(), "zh_CN");
+
+ PTabletKeyLookupRequest legacy_request;
+ EXPECT_FALSE(legacy_request.has_lc_time_names());
+ auto legacy = ReusableTestHelper::create_reusable("UTC",
legacy_request.lc_time_names());
+ ASSERT_NE(legacy, nullptr);
+ EXPECT_EQ(legacy->runtime_state()->lc_time_names(), "");
+ EXPECT_TRUE(legacy->matches_timezone_and_locale("UTC", ""));
+ EXPECT_FALSE(legacy->matches_timezone_and_locale("UTC", "en_US"));
+}
+
// A prepared statement can replace its cached context after SET time_zone.
TEST_F(LookupConnectionCacheTest, PQTestDuplicateAdd) {
LookupConnectionCache cache(1024 * 1024);
@@ -714,7 +746,7 @@ protected:
TQueryOptions options;
executor->_tablet = _tablet;
executor->_reusable = std::make_shared<Reusable>();
- RETURN_IF_ERROR(executor->_reusable->init(descriptor, output_exprs,
options, "+08:00",
+ RETURN_IF_ERROR(executor->_reusable->init(descriptor, output_exprs,
options, "+08:00", "",
*_tablet->tablet_schema(),
1));
PTabletKeyLookupRequest request;
ThriftSerializer serializer(false, 128);
diff --git a/be/test/testutil/function_utils.cpp
b/be/test/testutil/function_utils.cpp
index 079c506493c..b7593e1cbc8 100644
--- a/be/test/testutil/function_utils.cpp
+++ b/be/test/testutil/function_utils.cpp
@@ -33,6 +33,7 @@ FunctionUtils::FunctionUtils(const DataTypePtr& return_type,
globals.__set_now_string("2019-08-06 01:38:57");
globals.__set_timestamp_ms(1565026737805);
globals.__set_time_zone("Asia/Shanghai");
+ globals.__set_lc_time_names("en_US");
globals.__set_nano_seconds(805000000);
_state = std::make_unique<MockRuntimeState>(globals);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
index b993f209034..0a05ec4b1be 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
@@ -358,6 +358,7 @@ public class FoldConstantRuleOnBE implements
ExpressionPatternRuleFactory {
queryGlobals.setTimestampMs(System.currentTimeMillis());
queryGlobals.setTimeZone(
TimeUtils.getCanonicalTimeZone(context.getSessionVariable().getTimeZone()));
+
queryGlobals.setLcTimeNames(context.getSessionVariable().getLcTimeNames());
TQueryOptions tQueryOptions = new TQueryOptions();
tQueryOptions.setBeExecVersion(Config.be_exec_version);
@@ -366,6 +367,7 @@ public class FoldConstantRuleOnBE implements
ExpressionPatternRuleFactory {
tQueryOptions.setNewVersionPercentile(true);
tQueryOptions.setNewVersionBitmapOpCount(true);
tQueryOptions.setEnableStrictCast(SessionVariable.enableStrictCast());
+
tQueryOptions.setEnableHyperscanFallback(context.getSessionVariable().enableHyperscanFallback);
TFoldConstantParams tParams = new TFoldConstantParams(paramMap,
queryGlobals);
tParams.setVecExec(true);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java
index 0b51c6bcb10..b2a24b5cdf1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java
@@ -428,6 +428,7 @@ public class PointQueryExecutor implements CoordInterface {
// Set timezone for functions like from_unixtime
requestBuilder.setTimeZone(TimeUtils.getCanonicalTimeZone(
ConnectContext.get().getSessionVariable().getTimeZone()));
+
requestBuilder.setLcTimeNames(ConnectContext.get().getSessionVariable().getLcTimeNames());
if (snapshotVisibleVersions != null &&
!snapshotVisibleVersions.isEmpty()) {
requestBuilder.setVersion(snapshotVisibleVersions.get(0));
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java
index 99496be25c9..f2232e2a984 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java
@@ -61,6 +61,8 @@ public class ShortCircuitQueryContext {
public final String tableName;
private final long fileCacheQueryLimitBytes;
private final long partitionTopologyVersion;
+ // The serialized output expressions may contain locale-dependent folded
literals.
+ private final String lcTimeNames;
public final OlapScanNode scanNode;
public final Queriable analzyedQuery;
@@ -86,8 +88,9 @@ public class ShortCircuitQueryContext {
return returnTypes;
}
- public ShortCircuitQueryContext(Planner planner, Queriable analzyedQuery)
throws TException {
+ public ShortCircuitQueryContext(Planner planner, Queriable analzyedQuery,
String lcTimeNames) throws TException {
this.planner = planner;
+ this.lcTimeNames = lcTimeNames;
this.serializedDescTable = ByteString.copyFrom(
new
TSerializer().serialize(DescriptorToThriftConverter.toThrift(planner.getDescTable())));
TQueryOptions options = planner.getQueryOptions() != null ?
planner.getQueryOptions() : new TQueryOptions();
@@ -122,7 +125,7 @@ public class ShortCircuitQueryContext {
@VisibleForTesting
ShortCircuitQueryContext(OlapTable tbl, String tableName, int
schemaVersion,
- long fileCacheQueryLimitBytes) {
+ long fileCacheQueryLimitBytes, String lcTimeNames) {
this.planner = null;
this.serializedDescTable = ByteString.EMPTY;
this.serializedOutputExpr = ByteString.EMPTY;
@@ -133,6 +136,7 @@ public class ShortCircuitQueryContext {
this.schemaVersion = schemaVersion;
this.fileCacheQueryLimitBytes = fileCacheQueryLimitBytes;
this.partitionTopologyVersion = tbl.getPartitionTopologyVersion();
+ this.lcTimeNames = lcTimeNames;
this.scanNode = null;
this.analzyedQuery = null;
}
@@ -142,6 +146,7 @@ public class ShortCircuitQueryContext {
&& this.tbl.getBaseSchemaVersion() == this.schemaVersion
&& Objects.equals(this.tableName, this.tbl.getName())
&& this.fileCacheQueryLimitBytes ==
ctx.getSessionVariable().fileCacheQueryLimitBytes
+ && Objects.equals(this.lcTimeNames,
ctx.getSessionVariable().getLcTimeNames())
&& this.tbl.getPartitionTopologyVersion() ==
this.partitionTopologyVersion;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index 7fd24ad5318..3cd82ab1801 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -1886,7 +1886,8 @@ public class StmtExecutor {
if (statementContext.isShortCircuitQuery()) {
ShortCircuitQueryContext shortCircuitQueryContext =
statementContext.getShortCircuitQueryContext();
if (shortCircuitQueryContext == null) {
- shortCircuitQueryContext = new
ShortCircuitQueryContext(planner, (Queriable) parsedStmt);
+ shortCircuitQueryContext = new ShortCircuitQueryContext(
+ planner, (Queriable) parsedStmt,
context.getSessionVariable().getLcTimeNames());
// ExecuteCommand publishes this same context after a
successful first prepared execution.
statementContext.setShortCircuitQueryContext(shortCircuitQueryContext);
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommandTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommandTest.java
index 419120179e8..10f2038b7d4 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommandTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommandTest.java
@@ -414,7 +414,8 @@ public class ExecuteCommandTest {
Mockito.when(scanNode.getTableNameInPlan()).thenReturn("tbl");
Mockito.when(scanNode.getConjuncts()).thenReturn(Collections.emptyList());
Mockito.when(planner.getScanNodes()).thenReturn(Collections.singletonList(scanNode));
- ShortCircuitQueryContext cachedPlan = new
ShortCircuitQueryContext(planner, Mockito.mock(Queriable.class));
+ ShortCircuitQueryContext cachedPlan =
+ new ShortCircuitQueryContext(planner,
Mockito.mock(Queriable.class), "en_US");
preparedStatement.shortCircuitQueryContext = Optional.of(cachedPlan);
StmtExecutor executor = Mockito.mock(StmtExecutor.class);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/qe/SessionContextRequestTest.java
b/fe/fe-core/src/test/java/org/apache/doris/qe/SessionContextRequestTest.java
new file mode 100644
index 00000000000..6004af54cef
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/qe/SessionContextRequestTest.java
@@ -0,0 +1,161 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.qe;
+
+import org.apache.doris.analysis.DescriptorTable;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.common.jmockit.Deencapsulation;
+import org.apache.doris.mysql.MysqlCommand;
+import org.apache.doris.nereids.rules.expression.rules.FoldConstantRuleOnBE;
+import org.apache.doris.planner.OlapScanNode;
+import org.apache.doris.planner.Planner;
+import org.apache.doris.proto.InternalService;
+import org.apache.doris.rpc.BackendServiceProxy;
+import org.apache.doris.system.Backend;
+import org.apache.doris.system.SystemInfoService;
+import org.apache.doris.thrift.TFoldConstantParams;
+import org.apache.doris.thrift.TNetworkAddress;
+import org.apache.doris.thrift.TUniqueId;
+
+import org.apache.thrift.TDeserializer;
+import org.apache.thrift.TSerializer;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicReference;
+
+class SessionContextRequestTest {
+ @AfterEach
+ void clearContext() {
+ ConnectContext.remove();
+ }
+
+ @Test
+ void testFoldRequestKeepsChineseLocale() throws Exception {
+ assertFoldLocale("zh_CN");
+ }
+
+ @Test
+ void testFoldRequestKeepsEnglishLocale() throws Exception {
+ assertFoldLocale("en_US");
+ }
+
+ private void assertFoldLocale(String locale) throws Exception {
+ ConnectContext context = newContext(locale);
+ Assertions.assertEquals(locale,
CoordinatorContext.createQueryGlobals(context).getLcTimeNames());
+ TFoldConstantParams request = captureFoldRequest(context);
+ Assertions.assertTrue(request.getQueryGlobals().isSetLcTimeNames());
+ Assertions.assertEquals(locale,
request.getQueryGlobals().getLcTimeNames());
+ }
+
+ @Test
+ void testFoldRequestKeepsHyperscanFallback() throws Exception {
+ ConnectContext context = newContext("zh_CN");
+ for (boolean fallback : new boolean[] {false, true}) {
+ context.getSessionVariable().enableHyperscanFallback = fallback;
+ Assertions.assertEquals(fallback,
context.getSessionVariable().toThrift().isEnableHyperscanFallback());
+ TFoldConstantParams request = captureFoldRequest(context);
+
Assertions.assertTrue(request.getQueryOptions().isSetEnableHyperscanFallback());
+ Assertions.assertEquals(fallback,
request.getQueryOptions().isEnableHyperscanFallback());
+ }
+ }
+
+ @Test
+ void testPointLookupRequestChangesWithLocale() throws Exception {
+ ConnectContext context = newContext("zh_CN");
+ OlapTable table = Mockito.mock(OlapTable.class);
+ OlapScanNode scanNode = Mockito.mock(OlapScanNode.class);
+ Mockito.when(scanNode.getOlapTable()).thenReturn(table);
+
Mockito.when(scanNode.getTableNameInPlan()).thenReturn("session_context_case");
+
Mockito.when(scanNode.getPointQueryProjectList()).thenReturn(List.of());
+ Planner planner = Mockito.mock(Planner.class);
+ DescriptorTable descriptorTable = new DescriptorTable();
+ descriptorTable.createTupleDescriptor();
+ Mockito.when(planner.getDescTable()).thenReturn(descriptorTable);
+ Mockito.when(planner.getScanNodes()).thenReturn(List.of(scanNode));
+
Mockito.when(planner.getQueryOptions()).thenReturn(context.getSessionVariable().toThrift());
+ ShortCircuitQueryContext shortCircuit =
+ new ShortCircuitQueryContext(planner, null,
context.getSessionVariable().getLcTimeNames());
+ PointQueryExecutor executor = new PointQueryExecutor(shortCircuit,
1024);
+ for (MysqlCommand command : new MysqlCommand[]
{MysqlCommand.COM_QUERY, MysqlCommand.COM_STMT_EXECUTE}) {
+ context.command = command;
+ for (boolean full : new boolean[] {true, false, true}) {
+ for (String locale : new String[] {"zh_CN", "en_US", "zh_CN"})
{
+ context.getSessionVariable().setLcTimeNames(locale);
+ InternalService.PTabletKeyLookupRequest request =
Deencapsulation.invoke(
+ executor, "buildLookupRequest", full);
+ request =
InternalService.PTabletKeyLookupRequest.parseFrom(request.toByteArray());
+ Assertions.assertTrue(request.hasLcTimeNames());
+ Assertions.assertEquals(locale, request.getLcTimeNames());
+ Assertions.assertEquals(full, request.hasDescTbl());
+ Assertions.assertEquals(full, request.hasOutputExpr());
+ Assertions.assertEquals(full, request.hasQueryOptions());
+ Assertions.assertEquals(command ==
MysqlCommand.COM_STMT_EXECUTE, request.hasUuid());
+ if (request.hasUuid()) {
+
Assertions.assertEquals(shortCircuit.cacheID.getMostSignificantBits(),
+ request.getUuid().getUuidHigh());
+
Assertions.assertEquals(shortCircuit.cacheID.getLeastSignificantBits(),
+ request.getUuid().getUuidLow());
+ }
+ }
+ }
+ }
+ }
+
+ private ConnectContext newContext(String locale) {
+ ConnectContext context = new ConnectContext();
+ context.setThreadLocalInfo();
+ context.setQueryId(new TUniqueId(1, 2));
+ context.getSessionVariable().setLcTimeNames(locale);
+ return context;
+ }
+
+ private TFoldConstantParams captureFoldRequest(ConnectContext context)
throws Exception {
+ SystemInfoService systemInfo = Mockito.mock(SystemInfoService.class);
+ Backend backend = Mockito.mock(Backend.class);
+ BackendServiceProxy proxy = Mockito.mock(BackendServiceProxy.class);
+
Mockito.when(systemInfo.getAllBackendByCurrentCluster(true)).thenReturn(new
ArrayList<>(List.of(1L)));
+ Mockito.when(systemInfo.getBackend(1L)).thenReturn(backend);
+ Mockito.when(backend.getHost()).thenReturn("127.0.0.1");
+ Mockito.when(backend.getBrpcPort()).thenReturn(8060);
+ AtomicReference<TFoldConstantParams> captured = new
AtomicReference<>();
+
Mockito.when(proxy.foldConstantExpr(Mockito.any(TNetworkAddress.class),
Mockito.any(TFoldConstantParams.class)))
+ .thenAnswer(invocation -> {
+ captured.set(invocation.getArgument(1));
+ return
CompletableFuture.completedFuture(InternalService.PConstantExprResult.getDefaultInstance());
+ });
+ try (MockedStatic<Env> env = Mockito.mockStatic(Env.class);
+ MockedStatic<BackendServiceProxy> proxies =
Mockito.mockStatic(BackendServiceProxy.class)) {
+ env.when(Env::getCurrentSystemInfo).thenReturn(systemInfo);
+ proxies.when(BackendServiceProxy::getInstance).thenReturn(proxy);
+ Deencapsulation.invoke(FoldConstantRuleOnBE.class, "evalOnBE",
Map.of(), Map.of(), context);
+ }
+ Assertions.assertNotNull(captured.get(), "real evalOnBE must reach the
RPC boundary");
+ TFoldConstantParams wireCopy = new TFoldConstantParams();
+ new TDeserializer().deserialize(wireCopy, new
TSerializer().serialize(captured.get()));
+ return wireCopy;
+ }
+}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/qe/ShortCircuitQueryContextTest.java
b/fe/fe-core/src/test/java/org/apache/doris/qe/ShortCircuitQueryContextTest.java
index b43f0157073..e42905adb92 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/qe/ShortCircuitQueryContextTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/qe/ShortCircuitQueryContextTest.java
@@ -59,16 +59,28 @@ public class ShortCircuitQueryContextTest {
@Test
public void testReusableRequiresSameFileCacheQueryLimitBytes() {
ShortCircuitQueryContext context =
- new ShortCircuitQueryContext(table("tbl", 10), "tbl", 10, -1);
+ new ShortCircuitQueryContext(table("tbl", 10), "tbl", 10, -1,
"en_US");
Assertions.assertTrue(context.isReusable(connectContext(-1)));
Assertions.assertFalse(context.isReusable(connectContext(0)));
}
+ @Test
+ public void testReusableRequiresSameLcTimeNames() {
+ ConnectContext ctx = connectContext(-1);
+ ctx.getSessionVariable().setLcTimeNames("zh_CN");
+ ShortCircuitQueryContext context =
+ new ShortCircuitQueryContext(table("tbl", 10), "tbl", 10, -1,
"zh_CN");
+
+ Assertions.assertTrue(context.isReusable(ctx));
+ ctx.getSessionVariable().setLcTimeNames("en_US");
+ Assertions.assertFalse(context.isReusable(ctx));
+ }
+
@Test
public void testReusableStillChecksTableMetadata() {
ShortCircuitQueryContext context =
- new ShortCircuitQueryContext(table("tbl", 11), "tbl", 10, 0);
+ new ShortCircuitQueryContext(table("tbl", 11), "tbl", 10, 0,
"en_US");
Assertions.assertFalse(context.isReusable(connectContext(0)));
}
@@ -84,7 +96,7 @@ public class ShortCircuitQueryContextTest {
table.setIndexMeta(baseIndexId, "tbl", baseSchema, 10, 0, (short) 1,
TStorageType.COLUMN, KeysType.DUP_KEYS);
table.setBaseIndexId(baseIndexId);
- ShortCircuitQueryContext context = new ShortCircuitQueryContext(table,
"tbl", 10, -1);
+ ShortCircuitQueryContext context = new ShortCircuitQueryContext(table,
"tbl", 10, -1, "en_US");
Assertions.assertTrue(context.isReusable(connectContext(-1)));
table.addPartition(new Partition(3L, "p1",
@@ -110,7 +122,7 @@ public class ShortCircuitQueryContextTest {
Mockito.when(planner.getScanNodes()).thenReturn(Collections.singletonList(scanNode));
ShortCircuitQueryContext context =
- new ShortCircuitQueryContext(planner,
Mockito.mock(Queriable.class));
+ new ShortCircuitQueryContext(planner,
Mockito.mock(Queriable.class), "en_US");
TQueryOptions serializedQueryOptions = new TQueryOptions();
new TDeserializer().deserialize(serializedQueryOptions,
context.serializedQueryOptions.toByteArray());
diff --git a/gensrc/proto/internal_service.proto
b/gensrc/proto/internal_service.proto
index c0baef819c3..474ded65bee 100644
--- a/gensrc/proto/internal_service.proto
+++ b/gensrc/proto/internal_service.proto
@@ -359,6 +359,8 @@ message PTabletKeyLookupRequest {
optional bytes query_options = 8;
// timezone string, e.g. "America/Mexico_City"
optional string time_zone = 9;
+ // Session locale for expression evaluation, including lightweight
requests.
+ optional string lc_time_names = 10;
}
message PTabletKeyLookupResponse {
diff --git
a/regression-test/data/point_query_p0/test_point_query_date_name_capacity.out
b/regression-test/data/point_query_p0/test_point_query_date_name_capacity.out
new file mode 100644
index 00000000000..731df9af977
--- /dev/null
+++
b/regression-test/data/point_query_p0/test_point_query_date_name_capacity.out
@@ -0,0 +1,132 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !text_false_ru_RU_1 --
+1 1024 сентября воскресенье 22528 16384 22528 16384
22528 16384
+
+-- !text_false_ru_RU_2 --
+2 2 сентября воскресенье 22 16 22 16
22 16
+
+-- !text_false_ru_RU_3 --
+3 0 \N \N 0 0 0 0 0 0
+
+-- !text_false_ru_RU_4 --
+4 1 \N \N 0 0 0 0 0 0
+
+-- !text_false_ru_RU_5 --
+5 \N \N \N \N \N \N \N \N \N
+
+-- !text_false_zh_CN_1 --
+1 1024 九月 星期日 9216 6144 9216 6144 9216 6144
+
+-- !text_false_zh_CN_2 --
+2 2 九月 星期日 9 6 9 6 9 6
+
+-- !text_false_zh_CN_3 --
+3 0 \N \N 0 0 0 0 0 0
+
+-- !text_false_zh_CN_4 --
+4 1 \N \N 0 0 0 0 0 0
+
+-- !text_false_zh_CN_5 --
+5 \N \N \N \N \N \N \N \N \N
+
+-- !text_false_en_US_1 --
+1 1024 September Sunday 6144 9216 6144 9216 6144
9216
+
+-- !text_false_en_US_2 --
+2 2 September Sunday 6 9 6 9 6
9
+
+-- !text_false_en_US_3 --
+3 0 \N \N 0 0 0 0 0 0
+
+-- !text_false_en_US_4 --
+4 1 \N \N 0 0 0 0 0 0
+
+-- !text_false_en_US_5 --
+5 \N \N \N \N \N \N \N \N \N
+
+-- !text_true_ru_RU_1 --
+1 1024 сентября воскресенье 22528 16384 22528 16384
22528 16384
+
+-- !text_true_ru_RU_2 --
+2 2 сентября воскресенье 22 16 22 16
22 16
+
+-- !text_true_ru_RU_3 --
+3 0 \N \N 0 0 0 0 0 0
+
+-- !text_true_ru_RU_4 --
+4 1 \N \N 0 0 0 0 0 0
+
+-- !text_true_ru_RU_5 --
+5 \N \N \N \N \N \N \N \N \N
+
+-- !text_true_zh_CN_1 --
+1 1024 九月 星期日 9216 6144 9216 6144 9216 6144
+
+-- !text_true_zh_CN_2 --
+2 2 九月 星期日 9 6 9 6 9 6
+
+-- !text_true_zh_CN_3 --
+3 0 \N \N 0 0 0 0 0 0
+
+-- !text_true_zh_CN_4 --
+4 1 \N \N 0 0 0 0 0 0
+
+-- !text_true_zh_CN_5 --
+5 \N \N \N \N \N \N \N \N \N
+
+-- !text_true_en_US_1 --
+1 1024 September Sunday 6144 9216 6144 9216 6144
9216
+
+-- !text_true_en_US_2 --
+2 2 September Sunday 6 9 6 9 6
9
+
+-- !text_true_en_US_3 --
+3 0 \N \N 0 0 0 0 0 0
+
+-- !text_true_en_US_4 --
+4 1 \N \N 0 0 0 0 0 0
+
+-- !text_true_en_US_5 --
+5 \N \N \N \N \N \N \N \N \N
+
+-- !prepared_false_0 --
+1 1024 сентября воскресенье 22528 16384 22528 16384
22528 16384
+
+-- !prepared_false_1 --
+1 1024 сентября воскресенье 22528 16384 22528 16384
22528 16384
+
+-- !prepared_false_2 --
+1 1024 九月 星期日 9216 6144 9216 6144 9216 6144
+
+-- !prepared_false_3 --
+1 1024 九月 星期日 9216 6144 9216 6144 9216 6144
+
+-- !prepared_false_4 --
+1 1024 September Sunday 6144 9216 6144 9216 6144
9216
+
+-- !prepared_false_5 --
+1 1024 September Sunday 6144 9216 6144 9216 6144
9216
+
+-- !prepared_false_6 --
+1 1024 сентября воскресенье 22528 16384 22528 16384
22528 16384
+
+-- !prepared_true_0 --
+1 1024 сентября воскресенье 22528 16384 22528 16384
22528 16384
+
+-- !prepared_true_1 --
+1 1024 сентября воскресенье 22528 16384 22528 16384
22528 16384
+
+-- !prepared_true_2 --
+1 1024 九月 星期日 9216 6144 9216 6144 9216 6144
+
+-- !prepared_true_3 --
+1 1024 九月 星期日 9216 6144 9216 6144 9216 6144
+
+-- !prepared_true_4 --
+1 1024 September Sunday 6144 9216 6144 9216 6144
9216
+
+-- !prepared_true_5 --
+1 1024 September Sunday 6144 9216 6144 9216 6144
9216
+
+-- !prepared_true_6 --
+1 1024 сентября воскресенье 22528 16384 22528 16384
22528 16384
diff --git
a/regression-test/data/point_query_p0/test_point_query_lc_time_names.out
b/regression-test/data/point_query_p0/test_point_query_lc_time_names.out
new file mode 100644
index 00000000000..96cff82603b
--- /dev/null
+++ b/regression-test/data/point_query_p0/test_point_query_lc_time_names.out
@@ -0,0 +1,48 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !text_false_zh_CN --
+1 十一月 星期二
+
+-- !text_false_en_US --
+1 November Tuesday
+
+-- !text_true_zh_CN --
+1 十一月 星期二
+
+-- !text_true_en_US --
+1 November Tuesday
+
+-- !prepared_false_0 --
+1 十一月 星期二 十一月
+
+-- !prepared_false_1 --
+1 十一月 星期二 十一月
+
+-- !prepared_false_2 --
+1 November Tuesday November
+
+-- !prepared_false_3 --
+1 November Tuesday November
+
+-- !prepared_false_4 --
+1 十一月 星期二 十一月
+
+-- !prepared_false_5 --
+1 十一月 星期二 十一月
+
+-- !prepared_true_0 --
+1 十一月 星期二 十一月
+
+-- !prepared_true_1 --
+1 十一月 星期二 十一月
+
+-- !prepared_true_2 --
+1 November Tuesday November
+
+-- !prepared_true_3 --
+1 November Tuesday November
+
+-- !prepared_true_4 --
+1 十一月 星期二 十一月
+
+-- !prepared_true_5 --
+1 十一月 星期二 十一月
diff --git
a/regression-test/data/query_p0/expression/fold_constant/test_be_fold_session_context.out
b/regression-test/data/query_p0/expression/fold_constant/test_be_fold_session_context.out
new file mode 100644
index 00000000000..9ca13c5193e
--- /dev/null
+++
b/regression-test/data/query_p0/expression/fold_constant/test_be_fold_session_context.out
@@ -0,0 +1,18 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !date_false_zh_CN --
+十一月 星期二
+
+-- !date_false_en_US --
+November Tuesday
+
+-- !date_true_zh_CN --
+十一月 星期二
+
+-- !date_true_en_US --
+November Tuesday
+
+-- !regex_false --
+1
+
+-- !regex_true --
+1
diff --git
a/regression-test/suites/point_query_p0/test_point_query_date_name_capacity.groovy
b/regression-test/suites/point_query_p0/test_point_query_date_name_capacity.groovy
new file mode 100644
index 00000000000..17372c0d5d2
--- /dev/null
+++
b/regression-test/suites/point_query_p0/test_point_query_date_name_capacity.groovy
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_point_query_date_name_capacity", "p0,nonConcurrent") {
+ sql "DROP TABLE IF EXISTS test_point_query_date_name_capacity"
+ sql """CREATE TABLE test_point_query_date_name_capacity (
+ id INT, dates ARRAY<DATE>, datetimes ARRAY<DATETIMEV2(6)>, timestamps
ARRAY<TIMESTAMP_NS>)
+ UNIQUE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 1
+ PROPERTIES("replication_num" = "1", "enable_unique_key_merge_on_write"
= "true",
+ "store_row_column" = "true")"""
+ sql """INSERT INTO test_point_query_date_name_capacity VALUES
+ (1, array_repeat(CAST('2026-09-20' AS DATE), 1024),
+ array_repeat(CAST('2026-09-20 12:34:56.123456' AS DATETIMEV2(6)),
1024),
+ array_repeat(CAST('2026-09-20 12:34:56.123456789' AS
TIMESTAMP_NS), 1024)),
+ (2, array(CAST('2026-09-20' AS DATE), NULL),
+ array(CAST('2026-09-20 12:34:56' AS DATETIMEV2(6)), NULL),
+ array(CAST('2026-09-20 12:34:56' AS TIMESTAMP_NS), NULL)),
+ (3, [], [], []), (4, [NULL], [NULL], [NULL]), (5, NULL, NULL, NULL)"""
+ sql "SET enable_sql_cache = false"
+ def projection = """SELECT id, array_size(dates), monthname(dates[1]),
dayname(dates[1]),
+ length(array_join(array_map(x -> dayname(x), dates), '')),
+ length(array_join(array_map(x -> monthname(x), dates), '')),
+ length(array_join(array_map(x -> dayname(x), datetimes), '')),
+ length(array_join(array_map(x -> monthname(x), datetimes), '')),
+ length(array_join(array_map(x -> dayname(x), timestamps), '')),
+ length(array_join(array_map(x -> monthname(x), timestamps), ''))
+ FROM test_point_query_date_name_capacity"""
+ [false, true].each { shortCircuit ->
+ sql "SET enable_short_circuit_query = ${shortCircuit}"
+ ["ru_RU", "zh_CN", "en_US"].each { locale ->
+ sql "SET lc_time_names = '${locale}'"
+ if (shortCircuit) {
+ explain {
+ sql "${projection} WHERE id = 1"
+ contains "SHORT-CIRCUIT"
+ }
+ }
+ (1..5).each { id ->
+ quickRunTest("text_${shortCircuit}_${locale}_${id}",
"${projection} WHERE id = ${id}", true)
+ }
+ }
+ }
+
+ def oldLightweight = sql("ADMIN SHOW FRONTEND CONFIG LIKE
'enable_lightweight_lookup_request'")[0][1]
+ def database = sql("SELECT DATABASE()")[0][0]
+ def prepareUrl = getServerPrepareJdbcUrl(context.config.jdbcUrl, database,
false)
+ try {
+ [false, true].each { lightweight ->
+ sql """ADMIN SET FRONTEND CONFIG
("enable_lightweight_lookup_request" = "${lightweight}")"""
+ connectToDoris(context.config.jdbcUser,
context.config.jdbcPassword, prepareUrl) {
+ sql "SET enable_sql_cache = false"
+ sql "SET enable_short_circuit_query = true"
+ try (def statement = prepareStatement("${projection} WHERE id
= ?")) {
+ assertEquals(statement.class,
com.mysql.cj.jdbc.ServerPreparedStatement)
+ statement.setInt(1, 1)
+ // Long UTF-8 names must remain safe on both cache hits
and locale changes.
+ ["ru_RU", "ru_RU", "zh_CN", "zh_CN", "en_US", "en_US",
"ru_RU"].eachWithIndex { locale, index ->
+ sql "SET lc_time_names = '${locale}'"
+ quickRunTest("prepared_${lightweight}_${index}",
statement, true)
+ }
+ }
+ }
+ }
+ } finally {
+ sql """ADMIN SET FRONTEND CONFIG ("enable_lightweight_lookup_request"
= "${oldLightweight}")"""
+ }
+}
diff --git
a/regression-test/suites/point_query_p0/test_point_query_lc_time_names.groovy
b/regression-test/suites/point_query_p0/test_point_query_lc_time_names.groovy
new file mode 100644
index 00000000000..04cf607e0c2
--- /dev/null
+++
b/regression-test/suites/point_query_p0/test_point_query_lc_time_names.groovy
@@ -0,0 +1,77 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_point_query_lc_time_names", "p0,nonConcurrent") {
+ sql "DROP TABLE IF EXISTS test_point_query_lc_time_names_tbl"
+ sql """CREATE TABLE test_point_query_lc_time_names_tbl (id INT, d DATE)
+ UNIQUE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 1
+ PROPERTIES("replication_num" = "1", "enable_unique_key_merge_on_write"
= "true",
+ "store_row_column" = "true")"""
+ sql """INSERT INTO test_point_query_lc_time_names_tbl VALUES
+ (1, '2026-11-17'), (2, '2026-03-02')"""
+ sql "SET enable_sql_cache = false"
+ def query = "SELECT id, monthname(d), dayname(d) FROM
test_point_query_lc_time_names_tbl WHERE id = 1"
+ [false, true].each { shortCircuit ->
+ sql "SET enable_short_circuit_query = ${shortCircuit}"
+ ["zh_CN", "en_US"].each { locale ->
+ sql "SET lc_time_names = '${locale}'"
+ if (shortCircuit) {
+ explain {
+ sql query
+ contains "SHORT-CIRCUIT"
+ }
+ }
+ quickRunTest("text_${shortCircuit}_${locale}", query, true)
+ }
+ }
+
+ // crc32 prevents FE-only folding before MONTHNAME is evaluated by BE
constant folding.
+ def preparedProjection = """SELECT id, monthname(d), dayname(d),
+ monthname(str_to_date(concat('2026-11-', CAST(10 + crc32('a') % 10 AS
STRING)), '%Y-%m-%d')) AS folded_month
+ FROM test_point_query_lc_time_names_tbl"""
+ def oldLightweight = sql("ADMIN SHOW FRONTEND CONFIG LIKE
'enable_lightweight_lookup_request'")[0][1]
+ def database = sql("SELECT DATABASE()")[0][0]
+ def prepareUrl = getServerPrepareJdbcUrl(context.config.jdbcUrl, database,
false)
+ try {
+ [false, true].each { lightweight ->
+ sql """ADMIN SET FRONTEND CONFIG
("enable_lightweight_lookup_request" = "${lightweight}")"""
+ connectToDoris(context.config.jdbcUser,
context.config.jdbcPassword, prepareUrl) {
+ sql "SET enable_sql_cache = false"
+ sql "SET enable_short_circuit_query = true"
+ sql "SET enable_fold_constant_by_be = true"
+ sql "SET lc_time_names = 'zh_CN'"
+ explain {
+ sql "${preparedProjection} WHERE id = 1"
+ contains "SHORT-CIRCUIT"
+ contains "十一月"
+ notContains "crc32"
+ }
+ try (def statement = prepareStatement("${preparedProjection}
WHERE id = ?")) {
+ assertEquals(statement.class,
com.mysql.cj.jdbc.ServerPreparedStatement)
+ statement.setInt(1, 1)
+ // Reuse the JDBC statement across both cache hits and
locale changes.
+ ["zh_CN", "zh_CN", "en_US", "en_US", "zh_CN",
"zh_CN"].eachWithIndex { locale, index ->
+ sql "SET lc_time_names = '${locale}'"
+ quickRunTest("prepared_${lightweight}_${index}",
statement, true)
+ }
+ }
+ }
+ }
+ } finally {
+ sql """ADMIN SET FRONTEND CONFIG ("enable_lightweight_lookup_request"
= "${oldLightweight}")"""
+ }
+}
diff --git
a/regression-test/suites/query_p0/expression/fold_constant/test_be_fold_session_context.groovy
b/regression-test/suites/query_p0/expression/fold_constant/test_be_fold_session_context.groovy
new file mode 100644
index 00000000000..2122bc8b5e8
--- /dev/null
+++
b/regression-test/suites/query_p0/expression/fold_constant/test_be_fold_session_context.groovy
@@ -0,0 +1,59 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_be_fold_session_context") {
+ sql "SET enable_sql_cache = false"
+ def dateExpr = "str_to_date(concat('2026-11-', CAST(10 + crc32('a') % 10
AS STRING)), '%Y-%m-%d')"
+ def dateQuery = "SELECT monthname(${dateExpr}) AS m, dayname(${dateExpr})
AS d"
+ [false, true].each { fold ->
+ sql "SET enable_fold_constant_by_be = ${fold}"
+ ["zh_CN", "en_US"].each { locale ->
+ sql "SET lc_time_names = '${locale}'"
+ explain {
+ sql dateQuery
+ if (fold) {
+ notContains "crc32"
+ contains(locale == "zh_CN" ? "十一月" : "November")
+ } else {
+ contains "crc32"
+ }
+ }
+ quickRunTest("date_${fold}_${locale}", dateQuery, true)
+ }
+ }
+
+ sql "DROP TABLE IF EXISTS test_be_fold_session_context_tbl"
+ sql """CREATE TABLE test_be_fold_session_context_tbl (id INT, txt STRING)
+ DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 1
+ PROPERTIES("replication_num" = "1")"""
+ sql "INSERT INTO test_be_fold_session_context_tbl VALUES (1, 'abc'), (2,
'def')"
+ def regexQuery = """SELECT id FROM test_be_fold_session_context_tbl
+ WHERE txt = 'abc' AND ('abc' REGEXP '(?U)a+') ORDER BY id"""
+ sql "SET enable_hyperscan_fallback = false"
+ [false, true].each { fold ->
+ sql "SET enable_fold_constant_by_be = ${fold}"
+ test {
+ sql regexQuery
+ exception "hs_compile regex pattern error"
+ }
+ }
+ sql "SET enable_hyperscan_fallback = true"
+ [false, true].each { fold ->
+ sql "SET enable_fold_constant_by_be = ${fold}"
+ quickRunTest("regex_${fold}", regexQuery, true)
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]