This is an automated email from the ASF dual-hosted git repository.
CalvinKirs 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 a96aad9f4bd [fix](variables) Normalize case-insensitive session
variables, configs, and load headers (#70907)
a96aad9f4bd is described below
commit a96aad9f4bd38dbacc7f7b7f7203135022d48cb1
Author: linrrarity <[email protected]>
AuthorDate: Wed Dec 2 09:55:13 2026 +0800
[fix](variables) Normalize case-insensitive session variables, configs, and
load headers (#70907)
### Background
Doris accepts string options through session variables, FE/BE configs,
and Stream Load `group_commit` headers that users may pass in upper,
lower, or mixed case.
### What problem does this PR solve?
Issue Number: None
Related PR: None
PR Type: Bugfix
Problem Summary:
Several option handlers store or compare parameter values
case-sensitively, so mixed-case inputs like `PRESTO` or `aes_256_cbc`
fail or miss branches downstream. This PR normalizes those values at
entry or compares them case-insensitively across session variables,
FE/BE configs, and Stream Load `group_commit` headers.
```text
Before: mixed-case variable / config / group_commit --> case-sensitive
compare --> error or wrong branch
After: mixed-case variable / config / group_commit --> normalized /
ignore-case --> executes consistently
```
### Details
```sql
SET serde_dialect = 'PRESTO';
SELECT 1;
```
Before:
```text
ERROR 1105 (HY000) at line 1: errCode = 2, detailMessage = Unknown serde
dialect: PRESTO
```
After:
```text
+------+
| 1 |
+------+
| 1 |
+------+
1 row in set (0.01 sec)
```
### Testing
- Verified the SQL reproducer above end-to-end on local Doris clusters
(unpatched baseline vs. `2314ba2220e`).
### Release note
Fixed case-sensitivity issues in FE session variables, FE/BE configs,
and Stream Load `group_commit` headers.
### Check List (For Author)
- Behavior changed: Yes (see Details)
- Does this need documentation: No
- Pre-submission status: Partially verified (end-to-end cluster SQL
reproducer passed; run CI unit and regression suites for full FE/BE
coverage)
### AI Disclosure
- Tool: Antigravity
- Generated: Rewritten PR description and real-cluster Before/After
verification
- Human review: Author reviewed and confirmed scope and cluster outputs
---
be/src/agent/heartbeat_server.cpp | 3 +-
be/src/common/daemon.cpp | 7 +-
be/src/common/logconfig.cpp | 6 +-
be/src/service/http/action/http_stream.cpp | 6 +-
be/src/service/http/action/stream_load.cpp | 2 +-
.../main/java/org/apache/doris/qe/VarAttrDef.java | 27 +++
.../connector/hive/HiveConnectorMetadata.java | 6 +-
.../connector/hive/HiveWritePlanProvider.java | 13 +-
.../hive/HiveConnectorMetadataDdlTest.java | 16 ++
.../connector/hive/HiveWritePlanProviderTest.java | 6 +
.../main/java/org/apache/doris/catalog/Env.java | 3 +-
.../java/org/apache/doris/common/Log4jConfig.java | 8 +-
.../apache/doris/common/util/PropertyAnalyzer.java | 15 +-
.../org/apache/doris/nereids/NereidsPlanner.java | 16 +-
.../functions/scalar/AesCryptoFunction.java | 3 +-
.../functions/scalar/CryptoFunction.java | 3 +-
.../java/org/apache/doris/qe/SessionVariable.java | 60 ++++--
.../main/java/org/apache/doris/qe/VariableMgr.java | 4 +-
.../org/apache/doris/qe/VariableVarCallbacks.java | 2 +-
.../main/java/org/apache/doris/resource/Tag.java | 6 +-
.../apache/doris/service/FrontendServiceImpl.java | 2 +-
.../main/java/org/apache/doris/system/Backend.java | 23 ++-
.../java/org/apache/doris/system/HeartbeatMgr.java | 3 +-
.../apache/doris/common/PropertyAnalyzerTest.java | 27 +++
.../qe/SessionVariableCaseInsensitiveTest.java | 217 +++++++++++++++++++++
.../qe/SessionVariableMongoReadPolicyTest.java | 9 +-
.../data/datatype_p0/serde/test_serde_dialect.out | 6 +
.../encryption_digest/test_encryption_function.out | 15 ++
.../datatype_p0/serde/test_serde_dialect.groovy | 6 +
.../test_encryption_function.groovy | 10 +
30 files changed, 456 insertions(+), 74 deletions(-)
diff --git a/be/src/agent/heartbeat_server.cpp
b/be/src/agent/heartbeat_server.cpp
index c0fd08d434a..e13ad1dc809 100644
--- a/be/src/agent/heartbeat_server.cpp
+++ b/be/src/agent/heartbeat_server.cpp
@@ -43,6 +43,7 @@
#include "util/mem_info.h"
#include "util/network_util.h"
#include "util/private_rpc_tls.h"
+#include "util/string_util.h"
#include "util/thrift_server.h"
#include "util/time.h"
@@ -96,7 +97,7 @@ void HeartbeatServer::heartbeat(THeartbeatResult&
heartbeat_result,
heartbeat_result.backend_info.__set_arrow_flight_sql_port(config::arrow_flight_sql_port);
heartbeat_result.backend_info.__set_version(get_short_version());
heartbeat_result.backend_info.__set_be_start_time(_be_epoch);
- heartbeat_result.backend_info.__set_be_node_role(config::be_node_role);
+
heartbeat_result.backend_info.__set_be_node_role(to_lower(config::be_node_role));
// If be is gracefully stop, then k_doris_exist is set to true
heartbeat_result.backend_info.__set_is_shutdown(doris::k_doris_exit);
heartbeat_result.backend_info.__set_fragment_executing_count(
diff --git a/be/src/common/daemon.cpp b/be/src/common/daemon.cpp
index df5ae68520d..ddc6ac1bcc1 100644
--- a/be/src/common/daemon.cpp
+++ b/be/src/common/daemon.cpp
@@ -61,6 +61,7 @@
#include "util/algorithm_util.h"
#include "util/mem_info.h"
#include "util/perf_counters.h"
+#include "util/string_util.h"
#include "util/time.h"
namespace doris {
@@ -101,12 +102,14 @@ void Daemon::tcmalloc_gc_thread() {
std::min(MemInfo::physical_mem() -
MemInfo::sys_mem_available_low_water_mark(),
MemInfo::mem_limit());
- if (config::memory_mode == std::string("performance")) {
+ // be.conf may spell the mode in any letter case; "PERFORMANCE" or
"Compact" must not silently
+ // fall back to the moderate defaults.
+ if (iequal(config::memory_mode, "performance")) {
max_cache_percent = 100;
pressure_limit = 90;
is_performance_mode = true;
physical_limit_bytes = std::min(MemInfo::mem_limit(),
MemInfo::physical_mem());
- } else if (config::memory_mode == std::string("compact")) {
+ } else if (iequal(config::memory_mode, "compact")) {
max_cache_percent = 20;
pressure_limit = 80;
}
diff --git a/be/src/common/logconfig.cpp b/be/src/common/logconfig.cpp
index 73d4177a8de..30552f52720 100644
--- a/be/src/common/logconfig.cpp
+++ b/be/src/common/logconfig.cpp
@@ -211,13 +211,13 @@ bool init_glog(const char* basename) {
std::string& rollmode = config::sys_log_roll_mode;
std::string sizeflag = "SIZE-MB-";
bool ok = false;
- if (rollmode.compare("TIME-DAY") == 0) {
+ if (iequals(rollmode, "TIME-DAY")) {
FLAGS_log_split_method = "day";
ok = true;
- } else if (rollmode.compare("TIME-HOUR") == 0) {
+ } else if (iequals(rollmode, "TIME-HOUR")) {
FLAGS_log_split_method = "hour";
ok = true;
- } else if (rollmode.substr(0, sizeflag.length()).compare(sizeflag) == 0) {
+ } else if (iequals(rollmode.substr(0, sizeflag.length()), sizeflag)) {
FLAGS_log_split_method = "size";
std::string sizestr = rollmode.substr(sizeflag.size(), rollmode.size()
- sizeflag.size());
if (sizestr.size() != 0) {
diff --git a/be/src/service/http/action/http_stream.cpp
b/be/src/service/http/action/http_stream.cpp
index 09c33b03e86..40f45f4303e 100644
--- a/be/src/service/http/action/http_stream.cpp
+++ b/be/src/service/http/action/http_stream.cpp
@@ -363,8 +363,8 @@ Status HttpStreamAction::process_put(HttpRequest* http_req,
request.__set_loadId(ctx->id.to_thrift());
request.__set_label(ctx->label);
if (ctx->group_commit) {
- if (!http_req->header(HTTP_GROUP_COMMIT).empty()) {
-
request.__set_group_commit_mode(http_req->header(HTTP_GROUP_COMMIT));
+ if (http_req != nullptr &&
!http_req->header(HTTP_GROUP_COMMIT).empty()) {
+
request.__set_group_commit_mode(to_lower(http_req->header(HTTP_GROUP_COMMIT)));
} else {
// used for wait_internal_group_commit_finish
request.__set_group_commit_mode("sync_mode");
@@ -402,7 +402,7 @@ Status HttpStreamAction::process_put(HttpRequest* http_req,
ctx->txn_id = ctx->put_result.pipeline_params.txn_conf.txn_id;
ctx->label = ctx->put_result.pipeline_params.import_label;
ctx->put_result.pipeline_params.__set_wal_id(ctx->wal_id);
- if (http_req != nullptr && http_req->header(HTTP_GROUP_COMMIT) ==
"async_mode") {
+ if (http_req != nullptr && iequal(http_req->header(HTTP_GROUP_COMMIT),
"async_mode")) {
// FIXME find a way to avoid chunked stream load write large WALs
size_t content_length = 0;
if (!http_req->header(HttpHeaders::CONTENT_LENGTH).empty()) {
diff --git a/be/src/service/http/action/stream_load.cpp
b/be/src/service/http/action/stream_load.cpp
index 312e0ae4d96..ed924b781f8 100644
--- a/be/src/service/http/action/stream_load.cpp
+++ b/be/src/service/http/action/stream_load.cpp
@@ -1033,7 +1033,7 @@ Status
StreamLoadAction::_handle_group_commit(HttpRequest* req,
ctx->group_commit = false;
} else {
if (!group_commit_header.empty()) {
- ctx->group_commit_mode = group_commit_header;
+ ctx->group_commit_mode = to_lower(group_commit_header);
ctx->group_commit = true;
} else {
// use table property to decide group commit or not
diff --git a/fe/fe-common/src/main/java/org/apache/doris/qe/VarAttrDef.java
b/fe/fe-common/src/main/java/org/apache/doris/qe/VarAttrDef.java
index a5d4eda4391..cc815125de7 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/qe/VarAttrDef.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/qe/VarAttrDef.java
@@ -21,6 +21,7 @@ import org.apache.doris.common.VariableAnnotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.Locale;
/**
* Variable attribute definitions for session and global variables.
@@ -38,6 +39,29 @@ public class VarAttrDef {
// Variables with this flag can not be seen with `SHOW VARIABLES`
statement.
public static final int INVISIBLE = 16;
+ /**
+ * Case normalization applied when assigning a String variable.
+ */
+ public enum StringCase {
+ NONE,
+ LOWER,
+ UPPER
+ }
+
+ public static String normalizeString(StringCase stringCase, String value) {
+ if (value == null || stringCase == null) {
+ return value;
+ }
+ switch (stringCase) {
+ case LOWER:
+ return value.toLowerCase(Locale.ROOT);
+ case UPPER:
+ return value.toUpperCase(Locale.ROOT);
+ default:
+ return value;
+ }
+ }
+
@Retention(RetentionPolicy.RUNTIME)
public @interface VarAttr {
// Name in show variables and set statement;
@@ -60,6 +84,9 @@ public class VarAttrDef {
// could specify the setter method for a variable, not depend on
reflect mechanism
String setter() default "";
+ // Case normalization applied when storing a String variable.
+ StringCase stringCase() default StringCase.NONE;
+
// Set to true if the variables need to be forwarded along with
forward statement.
boolean needForward() default false;
diff --git
a/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveConnectorMetadata.java
b/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveConnectorMetadata.java
index 1f150a0b051..ac9c64bf153 100644
---
a/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveConnectorMetadata.java
+++
b/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveConnectorMetadata.java
@@ -2407,13 +2407,13 @@ public class HiveConnectorMetadata implements
ConnectorMetadata {
* property, replicating legacy {@code
SessionVariable.hiveTextCompression()} (the "uncompressed" alias maps
* to "plain"). The value rides on the request; the write converter only
consults it for a text table.
*/
- private static String resolveTextCompressionDefault(ConnectorSession
session) {
+ static String resolveTextCompressionDefault(ConnectorSession session) {
String textCompression = session.getSessionProperties()
.get(SESSION_HIVE_TEXT_COMPRESSION);
- if (TEXT_COMPRESSION_UNCOMPRESSED.equals(textCompression)) {
+ if (TEXT_COMPRESSION_UNCOMPRESSED.equalsIgnoreCase(textCompression)) {
return TEXT_COMPRESSION_PLAIN;
}
- return textCompression;
+ return textCompression == null ? null :
textCompression.toLowerCase(Locale.ROOT);
}
// ========== Internal helpers ==========
diff --git
a/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveWritePlanProvider.java
b/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveWritePlanProvider.java
index 70a8b3e28ef..d39858d9c73 100644
---
a/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveWritePlanProvider.java
+++
b/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveWritePlanProvider.java
@@ -369,7 +369,7 @@ public class HiveWritePlanProvider implements
ConnectorWritePlanProvider {
case FORMAT_TEXT:
compressType = params.get("text.compression");
if (Strings.isNullOrEmpty(compressType)) {
- compressType = resolveTextCompressionDefault(session);
+ compressType =
HiveConnectorMetadata.resolveTextCompressionDefault(session);
}
break;
default:
@@ -379,17 +379,6 @@ public class HiveWritePlanProvider implements
ConnectorWritePlanProvider {
tSink.setCompressionType(HiveSinkHelper.getTFileCompressType(compressType));
}
- // Re-impl of legacy SessionVariable.hiveTextCompression() (the
"uncompressed" alias maps to "plain"); the
- // value rides on the session properties threaded from the engine.
- private static String resolveTextCompressionDefault(ConnectorSession
session) {
- String textCompression = session.getSessionProperties()
- .get(HiveConnectorMetadata.SESSION_HIVE_TEXT_COMPRESSION);
- if
(HiveConnectorMetadata.TEXT_COMPRESSION_UNCOMPRESSED.equals(textCompression)) {
- return HiveConnectorMetadata.TEXT_COMPRESSION_PLAIN;
- }
- return textCompression;
- }
-
// Mirror iceberg buildHadoopConfig: BE-canonical static catalog creds
(AWS_* for object stores, dfs/hadoop
// for HDFS). Hive has no vended overlay.
private Map<String, String> buildHadoopConfig() {
diff --git
a/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveConnectorMetadataDdlTest.java
b/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveConnectorMetadataDdlTest.java
index 191597668e2..67278417019 100644
---
a/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveConnectorMetadataDdlTest.java
+++
b/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveConnectorMetadataDdlTest.java
@@ -321,6 +321,22 @@ public class HiveConnectorMetadataDdlTest {
Assertions.assertEquals("plain",
client.lastCreateTable.getDefaultTextCompression());
}
+ @Test
+ public void
createTableThreadsTextCompressionSessionDefaultInAnyLetterCase() {
+ RecordingHmsClient client = new RecordingHmsClient();
+ Map<String, String> sessionProps = Collections.singletonMap(
+ HiveConnectorMetadata.SESSION_HIVE_TEXT_COMPRESSION,
"UNCOMPRESSED");
+ metadata(client, Collections.emptyMap(), Collections.emptyMap())
+ .createTable(sessionWith(sessionProps), request().build());
+ Assertions.assertEquals("plain",
client.lastCreateTable.getDefaultTextCompression());
+
+ RecordingHmsClient zstdClient = new RecordingHmsClient();
+ metadata(zstdClient, Collections.emptyMap(), Collections.emptyMap())
+ .createTable(sessionWith(Collections.singletonMap(
+ HiveConnectorMetadata.SESSION_HIVE_TEXT_COMPRESSION,
"ZSTD")), request().build());
+ Assertions.assertEquals("zstd",
zstdClient.lastCreateTable.getDefaultTextCompression());
+ }
+
// ==================== createDatabase ====================
@Test
diff --git
a/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveWritePlanProviderTest.java
b/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveWritePlanProviderTest.java
index b98697a085e..c34b6620fbe 100644
---
a/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveWritePlanProviderTest.java
+++
b/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveWritePlanProviderTest.java
@@ -413,6 +413,12 @@ public class HiveWritePlanProviderTest {
Assertions.assertEquals(TFileCompressType.PLAIN,
compressionFor(TEXT_INPUT_FORMAT, Collections.emptyMap(),
Collections.singletonMap("hive_text_compression",
"uncompressed")));
+ Assertions.assertEquals(TFileCompressType.PLAIN,
+ compressionFor(TEXT_INPUT_FORMAT, Collections.emptyMap(),
+ Collections.singletonMap("hive_text_compression",
"UNCOMPRESSED")));
+ Assertions.assertEquals(TFileCompressType.ZSTD,
+ compressionFor(TEXT_INPUT_FORMAT, Collections.emptyMap(),
+ Collections.singletonMap("hive_text_compression",
"ZSTD")));
}
private TFileCompressType compressionFor(String inputFormat, Map<String,
String> tableParams,
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index fb23934c7df..1c1503a77df 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -296,7 +296,6 @@ import org.apache.doris.task.AgentTaskQueue;
import org.apache.doris.task.CompactionTask;
import org.apache.doris.task.MasterTaskExecutor;
import org.apache.doris.task.PriorityMasterTaskExecutor;
-import org.apache.doris.thrift.TCompressionType;
import org.apache.doris.thrift.TFrontendInfo;
import org.apache.doris.thrift.TGetMetaDBMeta;
import org.apache.doris.thrift.TGetMetaIndexMeta;
@@ -4150,7 +4149,7 @@ public class Env {
}
// compression type
- if (olapTable.getCompressionType() !=
TCompressionType.valueOf(Config.default_compression_type)) {
+ if (olapTable.getCompressionType() !=
PropertyAnalyzer.getDefaultCompressionType()) {
sb.append(",\n\"").append(PropertyAnalyzer.PROPERTIES_COMPRESSION).append("\" =
\"");
sb.append(olapTable.getCompressionType()).append("\"");
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/Log4jConfig.java
b/fe/fe-core/src/main/java/org/apache/doris/common/Log4jConfig.java
index b35e076c07f..312b052b50b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/Log4jConfig.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/Log4jConfig.java
@@ -219,9 +219,9 @@ public class Log4jConfig extends XmlConfiguration {
String sysLogRollPattern = "%d{yyyyMMdd}";
String sysRollMaxSize = String.valueOf(Config.log_roll_size_mb);
- if (Config.sys_log_roll_interval.equals("HOUR")) {
+ if (Config.sys_log_roll_interval.equalsIgnoreCase("HOUR")) {
sysLogRollPattern = "%d{yyyyMMddHH}";
- } else if (Config.sys_log_roll_interval.equals("DAY")) {
+ } else if (Config.sys_log_roll_interval.equalsIgnoreCase("DAY")) {
sysLogRollPattern = "%d{yyyyMMdd}";
} else {
throw new IOException("sys_log_roll_interval config error: " +
Config.sys_log_roll_interval);
@@ -234,9 +234,9 @@ public class Log4jConfig extends XmlConfiguration {
String auditRollMaxSize = String.valueOf(Config.log_roll_size_mb);
String auditDeleteAge = String.valueOf(Config.audit_log_delete_age);
boolean compressAuditLog = Config.audit_log_enable_compress;
- if (Config.audit_log_roll_interval.equals("HOUR")) {
+ if (Config.audit_log_roll_interval.equalsIgnoreCase("HOUR")) {
auditLogRollPattern = "%d{yyyyMMddHH}";
- } else if (Config.audit_log_roll_interval.equals("DAY")) {
+ } else if (Config.audit_log_roll_interval.equalsIgnoreCase("DAY")) {
auditLogRollPattern = "%d{yyyyMMdd}";
} else {
throw new IOException("audit_log_roll_interval config error: " +
Config.audit_log_roll_interval);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
index ab6d444cad2..22c24b69551 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
@@ -1158,7 +1158,8 @@ public class PropertyAnalyzer {
}
public static TCompressionType stringToCompressionType(String
compressionType) throws AnalysisException {
- if (compressionType.equalsIgnoreCase("no_compression")) {
+ if (compressionType.equalsIgnoreCase("no_compression")
+ || compressionType.equalsIgnoreCase("none")) {
return TCompressionType.NO_COMPRESSION;
} else if (compressionType.equalsIgnoreCase("lz4")) {
return TCompressionType.LZ4;
@@ -1174,7 +1175,7 @@ public class PropertyAnalyzer {
return TCompressionType.SNAPPY;
} else if (compressionType.equalsIgnoreCase("default_compression")
&&
!Config.default_compression_type.equalsIgnoreCase("default_compression")) {
- return TCompressionType.valueOf(Config.default_compression_type);
+ return stringToCompressionType(Config.default_compression_type);
} else if (compressionType.equalsIgnoreCase("default_compression")) {
return TCompressionType.LZ4F;
} else {
@@ -1182,6 +1183,16 @@ public class PropertyAnalyzer {
}
}
+ public static TCompressionType getDefaultCompressionType() {
+ try {
+ return stringToCompressionType(Config.default_compression_type);
+ } catch (AnalysisException e) {
+ LOG.warn("Invalid Config.default_compression_type: {}, fallback to
LZ4F",
+ Config.default_compression_type, e);
+ return TCompressionType.LZ4F;
+ }
+ }
+
// analyzeCompressionType will parse the compression type from properties
public static TCompressionType
getCompressionTypeFromProperties(Map<String, String> properties)
throws AnalysisException {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
index a6412c42f70..00865bbb4ef 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
@@ -101,6 +101,7 @@ import org.apache.doris.qe.cache.CacheAnalyzer;
import org.apache.doris.statistics.query.QueryStatsRecorder;
import org.apache.doris.statistics.util.StatisticsUtil;
import org.apache.doris.thrift.TQueryCacheParam;
+import org.apache.doris.thrift.TSerdeDialect;
import org.apache.doris.tso.MasterTsoProvider;
import com.google.common.annotations.VisibleForTesting;
@@ -1608,15 +1609,20 @@ public class NereidsPlanner extends Planner {
private void setFormatOptions() {
ConnectContext ctx = statementContext.getConnectContext();
SessionVariable sessionVariable = ctx.getSessionVariable();
- switch (sessionVariable.serdeDialect) {
- case "presto":
- case "trino":
+ TSerdeDialect serdeDialect;
+ try {
+ serdeDialect = sessionVariable.getSerdeDialect();
+ } catch (IllegalArgumentException e) {
+ throw new AnalysisException("Unsupported serde dialect: " +
sessionVariable.serdeDialect, e);
+ }
+ switch (serdeDialect) {
+ case PRESTO:
statementContext.setFormatOptions(FormatOptions.getForPresto());
break;
- case "hive":
+ case HIVE:
statementContext.setFormatOptions(FormatOptions.getForHive());
break;
- case "doris":
+ case DORIS:
statementContext.setFormatOptions(FormatOptions.getDefault());
break;
default:
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesCryptoFunction.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesCryptoFunction.java
index 4d9eb16679c..d36430e7fac 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesCryptoFunction.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/AesCryptoFunction.java
@@ -25,6 +25,7 @@ import
org.apache.doris.nereids.trees.expressions.literal.StringLiteral;
import com.google.common.collect.ImmutableSet;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
/** AesCryptoFunction */
@@ -96,7 +97,7 @@ public abstract class AesCryptoFunction extends
CryptoFunction {
@Override
public void checkLegalityAfterRewrite() {
if (arity() >= 4 && child(3) instanceof StringLikeLiteral) {
- String mode = ((StringLikeLiteral)
child(3)).getValue().toUpperCase();
+ String mode = ((StringLikeLiteral)
child(3)).getValue().toUpperCase(Locale.ROOT);
if (!AES_MODES.contains(mode)) {
throw new AnalysisException("mode " + mode + " is not
supported");
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CryptoFunction.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CryptoFunction.java
index 09d540c9c28..929b269a3f8 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CryptoFunction.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CryptoFunction.java
@@ -28,6 +28,7 @@ import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
+import java.util.Locale;
/** CryptoFunction */
public abstract class CryptoFunction extends ScalarFunction
@@ -86,6 +87,6 @@ public abstract class CryptoFunction extends ScalarFunction
if (StringUtils.isAllBlank(blockEncryptionMode)) {
blockEncryptionMode = defaultMode;
}
- return new StringLiteral(blockEncryptionMode);
+ return new StringLiteral(blockEncryptionMode.toUpperCase(Locale.ROOT));
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index c4171d63467..77ab42815ae 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -49,6 +49,7 @@ import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils;
@@ -1850,7 +1851,9 @@ public class SessionVariable implements Serializable,
Writable {
@VarAttrDef.VarAttr(name = ENABLE_REWRITE_ELEMENT_AT_TO_SLOT, fuzzy = true)
private boolean enableRewriteElementAtToSlot = true;
- @VarAttrDef.VarAttr(name = FORCE_SORT_ALGORITHM, needForward = true,
description = "Force the sort algorithm of "
+ @VarAttrDef.VarAttr(name = FORCE_SORT_ALGORITHM, needForward = true,
+ stringCase = VarAttrDef.StringCase.LOWER,
+ description = "Force the sort algorithm of "
+ "SortNode to be specified")
public String forceSortAlgorithm = "";
@@ -1909,7 +1912,8 @@ public class SessionVariable implements Serializable,
Writable {
description = "set the number of sort phases 1 or 2. if set other
value, let cbo decide the sort type")
public int sortPhaseNum = 0;
- @VarAttrDef.VarAttr(name = HIVE_TEXT_COMPRESSION, fuzzy = true,
needForward = true)
+ @VarAttrDef.VarAttr(name = HIVE_TEXT_COMPRESSION, fuzzy = true,
needForward = true,
+ stringCase = VarAttrDef.StringCase.LOWER)
private String hiveTextCompression = "plain";
@VarAttrDef.VarAttr(name = READ_CSV_EMPTY_LINE_AS_NULL, needForward = true,
@@ -2075,7 +2079,8 @@ public class SessionVariable implements Serializable,
Writable {
@VarAttrDef.VarAttr(name = RETURN_OBJECT_DATA_AS_BINARY,
affectQueryResultInExecution = true)
private boolean returnObjectDataAsBinary = false;
- @VarAttrDef.VarAttr(name = BLOCK_ENCRYPTION_MODE, affectQueryResultInPlan
= true)
+ @VarAttrDef.VarAttr(name = BLOCK_ENCRYPTION_MODE, affectQueryResultInPlan
= true,
+ stringCase = VarAttrDef.StringCase.UPPER)
private String blockEncryptionMode = "";
@VarAttrDef.VarAttr(name = ENABLE_PROJECTION)
@@ -2463,7 +2468,8 @@ public class SessionVariable implements Serializable,
Writable {
public boolean enableQueryReadAhead = false;
// Specify base path for file cache, or chose a random path.
- @VarAttrDef.VarAttr(name = FILE_CACHE_BASE_PATH, needForward = true,
description = "Specify the storage path of "
+ @VarAttrDef.VarAttr(name = FILE_CACHE_BASE_PATH, needForward = true,
setter = "setFileCacheBasePath",
+ description = "Specify the storage path of "
+ "the block file cache on BE, default 'random', "
+ "and randomly select the storage path configured by BE.")
public String fileCacheBasePath = "random";
@@ -2909,7 +2915,7 @@ public class SessionVariable implements Serializable,
Writable {
@VarAttrDef.VarAttr(name = LOAD_STREAM_PER_NODE, checker =
"checkLoadStreamPerNode")
public int loadStreamPerNode = 2;
- @VarAttrDef.VarAttr(name = GROUP_COMMIT, needForward = true)
+ @VarAttrDef.VarAttr(name = GROUP_COMMIT, needForward = true, stringCase =
VarAttrDef.StringCase.LOWER)
public String groupCommit = "off_mode";
@VarAttrDef.VarAttr(name = ENABLE_PREPARED_STMT_AUDIT_LOG, needForward =
true)
@@ -2941,6 +2947,7 @@ public class SessionVariable implements Serializable,
Writable {
public boolean invertedIndexCompatibleRead = false;
@VarAttrDef.VarAttr(name = SQL_DIALECT, needForward = true, checker =
"checkSqlDialect",
+ stringCase = VarAttrDef.StringCase.LOWER,
description = "The dialect used to parse sql.",
affectQueryResultInPlan = true
)
@@ -2951,8 +2958,9 @@ public class SessionVariable implements Serializable,
Writable {
public boolean retryOriginSqlOnConvertFail = false;
@VarAttrDef.VarAttr(name = SERDE_DIALECT, needForward = true, checker =
"checkSerdeDialect",
+ stringCase = VarAttrDef.StringCase.LOWER,
description = "The output format dialect of each data type
returned to the MySQL client.",
- options = {"doris", "presto", "trino"},
+ options = {"doris", "presto", "trino", "hive"},
affectQueryResultInPlan = true, affectQueryResultInExecution = true
)
public String serdeDialect = "doris";
@@ -3059,6 +3067,7 @@ public class SessionVariable implements Serializable,
Writable {
public boolean enableMaterializedViewRewrite = true;
@VarAttrDef.VarAttr(name = PRE_MATERIALIZED_VIEW_REWRITE_STRATEGY,
needForward = true, fuzzy = true,
+ stringCase = VarAttrDef.StringCase.UPPER,
description = "Whether to enable pre materialized view rewriting
based on struct info,"
+ "FORCE_IN_RBO : Force transparent rewriting in the RBO
phase,"
+ "TRY_IN_RBO : Attempt transparent rewriting in the RBO
phase "
@@ -3157,6 +3166,7 @@ public class SessionVariable implements Serializable,
Writable {
public String mongodbReadPreference = "inherit";
@VarAttrDef.VarAttr(name = MONGODB_READ_CONCERN, needForward = true,
+ stringCase = VarAttrDef.StringCase.LOWER,
checker = "checkMongoDBReadConcern", affectQueryResultInExecution
= true,
options = {"inherit", "local", "majority", "available",
"snapshot"},
description = "MongoDB data-read visibility for this session or
SET_VAR statement. "
@@ -3435,7 +3445,8 @@ public class SessionVariable implements Serializable,
Writable {
public static final String ENABLE_SEGMENT_CACHE = "enable_segment_cache";
public Set<String> getIgnoreShapePlanNodes() {
- return
Arrays.stream(ignoreShapePlanNodes.split(",[\\s]*")).collect(ImmutableSet.toImmutableSet());
+ return Arrays.stream(ignoreShapePlanNodes.split(",[\\s]*"))
+
.collect(ImmutableSortedSet.toImmutableSortedSet(String.CASE_INSENSITIVE_ORDER));
}
public void setIgnoreShapePlanNodes(String ignoreShapePlanNodes) {
@@ -3462,7 +3473,7 @@ public class SessionVariable implements Serializable,
Writable {
public void setDetailShapePlanNodes(String detailShapePlanNodes) {
this.detailShapePlanNodesSet =
Arrays.stream(detailShapePlanNodes.split(",[\\s]*"))
- .collect(ImmutableSet.toImmutableSet());
+
.collect(ImmutableSortedSet.toImmutableSortedSet(String.CASE_INSENSITIVE_ORDER));
this.detailShapePlanNodes = detailShapePlanNodes;
}
@@ -3717,6 +3728,7 @@ public class SessionVariable implements Serializable,
Writable {
public boolean enableTextValidateUtf8 = true;
@VarAttrDef.VarAttr(name = ENABLE_SQL_CONVERTOR_FEATURES, needForward =
true,
+ stringCase = VarAttrDef.StringCase.LOWER,
checker = "checkSqlConvertorFeatures",
description = "enable SQL convertor features. Multiple features
are separated by commas")
public String enableSqlConvertorFeatures = "";
@@ -4227,7 +4239,11 @@ public class SessionVariable implements Serializable,
Writable {
}
public void setBlockEncryptionMode(String blockEncryptionMode) {
- this.blockEncryptionMode = blockEncryptionMode;
+ this.blockEncryptionMode = blockEncryptionMode == null ? null :
blockEncryptionMode.toUpperCase(Locale.ROOT);
+ }
+
+ public void setGroupCommit(String groupCommit) {
+ this.groupCommit = groupCommit == null ? null :
groupCommit.toLowerCase(Locale.ROOT);
}
public void setRewriteOrToInPredicateThreshold(int threshold) {
@@ -5340,7 +5356,7 @@ public class SessionVariable implements Serializable,
Writable {
}
public void setSqlDialect(String sqlDialect) {
- this.sqlDialect = sqlDialect == null ? null : sqlDialect.toLowerCase();
+ this.sqlDialect = sqlDialect == null ? null :
sqlDialect.toLowerCase(Locale.ROOT);
}
/**
@@ -5816,7 +5832,12 @@ public class SessionVariable implements Serializable,
Writable {
}
public void setFileCacheBasePath(String basePath) {
- this.fileCacheBasePath = basePath;
+ // "random" is a keyword compared case-insensitively; any other value
is a directory path whose case matters.
+ if (basePath != null && basePath.equalsIgnoreCase("random")) {
+ this.fileCacheBasePath = "random";
+ } else {
+ this.fileCacheBasePath = basePath;
+ }
}
public boolean isEnableInvertedIndexQuery() {
@@ -6229,7 +6250,8 @@ public class SessionVariable implements Serializable,
Writable {
field.set(this, root.get(attr.name()));
break;
case "String":
- field.set(this, root.get(attr.name()));
+ field.set(this,
VarAttrDef.normalizeString(attr.stringCase(),
+ (String) root.get(attr.name())));
break;
default:
// Unsupported type variable.
@@ -6284,7 +6306,8 @@ public class SessionVariable implements Serializable,
Writable {
field.set(this,
Double.valueOf(sessionVarMap.get(attr.name())));
break;
case "String":
- field.set(this, sessionVarMap.get(attr.name()));
+ field.set(this,
VarAttrDef.normalizeString(attr.stringCase(),
+ sessionVarMap.get(attr.name())));
break;
default:
// Unsupported type variable.
@@ -6435,7 +6458,7 @@ public class SessionVariable implements Serializable,
Writable {
if (innerParts.length != 2) {
continue;
}
- if (innerParts[0].equals("trace_id")) {
+ if (innerParts[0].equalsIgnoreCase("trace_id")) {
return innerParts[1];
}
}
@@ -6552,7 +6575,8 @@ public class SessionVariable implements Serializable,
Writable {
}
public void setHiveTextCompression(String hiveTextCompression) {
- this.hiveTextCompression = hiveTextCompression;
+ this.hiveTextCompression = hiveTextCompression == null
+ ? null : hiveTextCompression.toLowerCase(Locale.ROOT);
}
public boolean enableSyncRuntimeFilterSize() {
@@ -6812,7 +6836,8 @@ public class SessionVariable implements Serializable,
Writable {
}
public void setPreMaterializedViewRewriteStrategy(String
preMaterializedViewRewriteStrategy) {
- this.preMaterializedViewRewriteStrategy =
preMaterializedViewRewriteStrategy;
+ this.preMaterializedViewRewriteStrategy =
preMaterializedViewRewriteStrategy == null
+ ? null :
preMaterializedViewRewriteStrategy.toUpperCase(Locale.ROOT);
}
public boolean isEnableDmlMaterializedViewRewrite() {
@@ -6951,7 +6976,8 @@ public class SessionVariable implements Serializable,
Writable {
}
public TSerdeDialect getSerdeDialect() {
- switch (serdeDialect) {
+ String normalized = serdeDialect == null ? "" :
serdeDialect.toLowerCase(Locale.ROOT);
+ switch (normalized) {
case "doris":
return TSerdeDialect.DORIS;
case "presto":
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
index 9d0e33b68b6..607101e596f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
@@ -241,6 +241,7 @@ public class VariableMgr {
ErrorReport.reportDdlException(ErrorCode.ERR_INVALID_VALUE,
value, attr.name(), e.getMessage());
}
}
+ value = VarAttrDef.normalizeString(attr.stringCase(), value);
// If the session variable has specified the setter, then not use
reflect
if (!attr.setter().equals("")) {
Preconditions.checkArgument(obj instanceof SessionVariable);
@@ -303,7 +304,8 @@ public class VariableMgr {
field.setDouble(obj, Double.parseDouble(value));
break;
case "String":
- field.set(obj, value);
+ VarAttrDef.VarAttr attr =
field.getAnnotation(VarAttrDef.VarAttr.class);
+ field.set(obj, attr == null ? value :
VarAttrDef.normalizeString(attr.stringCase(), value));
break;
default:
// Unsupported type variable.
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableVarCallbacks.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableVarCallbacks.java
index f1dc5e69c3c..5b8d22933b0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableVarCallbacks.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableVarCallbacks.java
@@ -63,7 +63,7 @@ public class VariableVarCallbacks {
if (innerParts.length != 2) {
continue;
}
- if (innerParts[0].equals("trace_id")) {
+ if (innerParts[0].equalsIgnoreCase("trace_id")) {
ConnectContext.get().setTraceId(innerParts[1]);
break;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/resource/Tag.java
b/fe/fe-core/src/main/java/org/apache/doris/resource/Tag.java
index 17b7db694ef..9f549eee32f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/resource/Tag.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/resource/Tag.java
@@ -29,6 +29,7 @@ import com.google.gson.annotations.SerializedName;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
+import java.util.Locale;
import java.util.Map;
import java.util.Objects;
@@ -125,6 +126,9 @@ public class Tag implements Writable {
} else if (!value.matches(TAG_VALUE_REGEX)) {
throw new AnalysisException("Invalid tag value format: " + value);
}
+ if (TYPE_ROLE.equals(type) && validNodeRoleTag(value)) {
+ value = value.toLowerCase(Locale.ROOT);
+ }
return new Tag(type, value);
}
@@ -134,7 +138,7 @@ public class Tag implements Writable {
// only support be and cn node role tag for be.
public static boolean validNodeRoleTag(String value) {
- return value != null && (value.equals(VALUE_MIX) ||
value.equals(VALUE_COMPUTATION));
+ return value != null && (VALUE_MIX.equalsIgnoreCase(value) ||
VALUE_COMPUTATION.equalsIgnoreCase(value));
}
public String toKey() {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
index 31ef6f54ec1..bbf06686aa9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
@@ -3294,7 +3294,7 @@ public class FrontendServiceImpl implements
FrontendService.Iface {
} else {
ctx.getSessionVariable().enableMemtableOnSinkNode =
Config.stream_load_default_memtable_on_sink_node;
}
- ctx.getSessionVariable().groupCommit = request.getGroupCommitMode();
+ ctx.getSessionVariable().setGroupCommit(request.getGroupCommitMode());
ctx.getSessionVariable().setEnableInsertStrict(false);
if (request.isSetPartialUpdate() && !request.isPartialUpdate()) {
ctx.getSessionVariable().setEnableUniqueKeyPartialUpdate(false);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/system/Backend.java
b/fe/fe-core/src/main/java/org/apache/doris/system/Backend.java
index 0f5e0505620..5cb0e76e47c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/system/Backend.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/system/Backend.java
@@ -56,6 +56,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -942,10 +943,11 @@ public class Backend implements Writable {
this.backendStatus.isShutdown = hbResponse.isShutDown();
}
- if (!this.getNodeRoleTag().value.equals(hbResponse.getNodeRole())
&& Tag.validNodeRoleTag(
- hbResponse.getNodeRole())) {
+ String hbNodeRole = hbResponse.getNodeRole() == null
+ ? null : hbResponse.getNodeRole().toLowerCase(Locale.ROOT);
+ if (!this.getNodeRoleTag().value.equals(hbNodeRole) &&
Tag.validNodeRoleTag(hbNodeRole)) {
isChanged = true;
- this.nodeRoleTag = Tag.createNotCheck(Tag.TYPE_ROLE,
hbResponse.getNodeRole());
+ this.nodeRoleTag = Tag.createNotCheck(Tag.TYPE_ROLE,
hbNodeRole);
}
if (this.beMemory != hbResponse.getBeMemory()) {
isChanged = true;
@@ -1107,20 +1109,23 @@ public class Backend implements Writable {
}
public boolean isMixNode() {
- return nodeRoleTag.value.equals(Tag.VALUE_MIX);
+ return nodeRoleTag.value.equalsIgnoreCase(Tag.VALUE_MIX);
}
public boolean isComputeNode() {
- return nodeRoleTag.value.equals(Tag.VALUE_COMPUTATION);
+ return nodeRoleTag.value.equalsIgnoreCase(Tag.VALUE_COMPUTATION);
}
public void setTagMap(Map<String, String> tagMap) {
Preconditions.checkState(tagMap.containsKey(Tag.TYPE_LOCATION));
- this.tagMap = tagMap;
- this.locationTag = Tag.createNotCheck(Tag.TYPE_LOCATION,
tagMap.get(Tag.TYPE_LOCATION));
- if (tagMap.containsKey(Tag.TYPE_ROLE) &&
Tag.validNodeRoleTag(tagMap.get(Tag.TYPE_ROLE))) {
- this.nodeRoleTag = Tag.createNotCheck(Tag.TYPE_ROLE,
tagMap.get(Tag.TYPE_ROLE));
+ Map<String, String> normalizedMap = Maps.newHashMap(tagMap);
+ if (normalizedMap.containsKey(Tag.TYPE_ROLE) &&
Tag.validNodeRoleTag(normalizedMap.get(Tag.TYPE_ROLE))) {
+ String normalizedRole =
normalizedMap.get(Tag.TYPE_ROLE).toLowerCase(Locale.ROOT);
+ normalizedMap.put(Tag.TYPE_ROLE, normalizedRole);
+ this.nodeRoleTag = Tag.createNotCheck(Tag.TYPE_ROLE,
normalizedRole);
}
+ this.tagMap = normalizedMap;
+ this.locationTag = Tag.createNotCheck(Tag.TYPE_LOCATION,
normalizedMap.get(Tag.TYPE_LOCATION));
}
public Map<String, String> getTagMap() {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/system/HeartbeatMgr.java
b/fe/fe-core/src/main/java/org/apache/doris/system/HeartbeatMgr.java
index 31330c78724..b63d7e299a6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/system/HeartbeatMgr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/system/HeartbeatMgr.java
@@ -64,6 +64,7 @@ import org.apache.logging.log4j.Logger;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -447,7 +448,7 @@ public class HeartbeatMgr extends MasterDaemon {
long beStartTime = tBackendInfo.getBeStartTime();
String nodeRole = Tag.VALUE_MIX;
if (tBackendInfo.isSetBeNodeRole()) {
- nodeRole = tBackendInfo.getBeNodeRole();
+ nodeRole =
tBackendInfo.getBeNodeRole().toLowerCase(Locale.ROOT);
}
long fragmentNum =
tBackendInfo.getFragmentExecutingCount();
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java
b/fe/fe-core/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java
index d9732c1ad69..f2dbf2db5ca 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java
@@ -34,6 +34,7 @@ import org.apache.doris.common.util.PropertyAnalyzer;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.qe.SessionVariable;
import org.apache.doris.resource.Tag;
+import org.apache.doris.thrift.TCompressionType;
import org.apache.doris.thrift.TInvertedIndexFileStorageFormat;
import org.apache.doris.thrift.TStorageFormat;
import org.apache.doris.thrift.TStorageMedium;
@@ -1149,4 +1150,30 @@ public class PropertyAnalyzerTest {
() ->
PropertyAnalyzer.validateVariantStoragePath("parent." + invalid));
}
}
+
+ @Test
+ public void testCompressionTypeCaseAndDefaultResolution() throws Exception
{
+ String original = Config.default_compression_type;
+ try {
+ Config.default_compression_type = "default_compression";
+ Assertions.assertEquals(TCompressionType.LZ4F,
+ PropertyAnalyzer.getDefaultCompressionType());
+ Assertions.assertEquals(TCompressionType.LZ4F,
+
PropertyAnalyzer.stringToCompressionType("DEFAULT_COMPRESSION"));
+
+ Config.default_compression_type = "none";
+ Assertions.assertEquals(TCompressionType.NO_COMPRESSION,
+ PropertyAnalyzer.getDefaultCompressionType());
+ Assertions.assertEquals(TCompressionType.NO_COMPRESSION,
+
PropertyAnalyzer.stringToCompressionType("default_compression"));
+
+ Config.default_compression_type = "zstd";
+ Assertions.assertEquals(TCompressionType.ZSTD,
+ PropertyAnalyzer.getDefaultCompressionType());
+ Assertions.assertEquals(TCompressionType.ZSTD,
+
PropertyAnalyzer.stringToCompressionType("DEFAULT_COMPRESSION"));
+ } finally {
+ Config.default_compression_type = original;
+ }
+ }
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/qe/SessionVariableCaseInsensitiveTest.java
b/fe/fe-core/src/test/java/org/apache/doris/qe/SessionVariableCaseInsensitiveTest.java
new file mode 100644
index 00000000000..24808237469
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/qe/SessionVariableCaseInsensitiveTest.java
@@ -0,0 +1,217 @@
+// 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.SetType;
+import org.apache.doris.analysis.SetVar;
+import org.apache.doris.analysis.StringLiteral;
+import org.apache.doris.common.Config;
+import org.apache.doris.common.util.PropertyAnalyzer;
+import
org.apache.doris.nereids.rules.exploration.mv.PreMaterializedViewRewriter.PreRewriteStrategy;
+import
org.apache.doris.nereids.trees.expressions.functions.scalar.AesCryptoFunction;
+import org.apache.doris.resource.Tag;
+import org.apache.doris.system.Backend;
+import org.apache.doris.thrift.TCompressionType;
+import org.apache.doris.thrift.TSerdeDialect;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+class SessionVariableCaseInsensitiveTest {
+ private static void set(SessionVariable variables, String name, String
value) throws Exception {
+ VariableMgr.setVar(variables, new SetVar(SetType.SESSION, name, new
StringLiteral(value)));
+ }
+
+ @Test
+ void serdeDialectAcceptsAnyLetterCase() throws Exception {
+ SessionVariable variables = new SessionVariable();
+ set(variables, "serde_dialect", "PRESTO");
+ Assertions.assertEquals(TSerdeDialect.PRESTO,
variables.getSerdeDialect());
+ set(variables, "serde_dialect", "Hive");
+ Assertions.assertEquals(TSerdeDialect.HIVE,
variables.getSerdeDialect());
+ set(variables, "serde_dialect", "DORIS");
+ Assertions.assertEquals(TSerdeDialect.DORIS,
variables.getSerdeDialect());
+ }
+
+ @Test
+ void sqlDialectIsStoredInLowerCase() throws Exception {
+ SessionVariable variables = new SessionVariable();
+ set(variables, "sql_dialect", "DORIS");
+ Assertions.assertEquals("doris", variables.getSqlDialect());
+ }
+
+ @Test
+ void blockEncryptionModeIsUsedByCryptoFunctionsInAnyLetterCase() throws
Exception {
+ ConnectContext context = new ConnectContext();
+ context.setThreadLocalInfo();
+ try {
+ set(context.getSessionVariable(), "block_encryption_mode",
"aes_256_cbc");
+ Assertions.assertEquals("AES_256_CBC",
AesCryptoFunction.getDefaultBlockEncryptionMode().getValue());
+ } finally {
+ ConnectContext.remove();
+ }
+ }
+
+ @Test
+ void preMaterializedViewRewriteStrategyAcceptsAnyLetterCase() throws
Exception {
+ SessionVariable variables = new SessionVariable();
+ set(variables, "pre_materialized_view_rewrite_strategy", "not_in_rbo");
+ Assertions.assertEquals(PreRewriteStrategy.NOT_IN_RBO,
+
PreRewriteStrategy.getEnum(variables.getPreMaterializedViewRewriteStrategy()));
+ }
+
+ @Test
+ void forceSortAlgorithmIsStoredInLowerCase() throws Exception {
+ SessionVariable variables = new SessionVariable();
+ set(variables, "force_sort_algorithm", "HEAP");
+ Assertions.assertEquals("heap", variables.forceSortAlgorithm);
+ }
+
+ @Test
+ void fileCacheBasePathNormalizesOnlyTheRandomKeyword() throws Exception {
+ SessionVariable variables = new SessionVariable();
+ set(variables, "file_cache_base_path", "RANDOM");
+ Assertions.assertEquals("random", variables.getFileCacheBasePath());
+ set(variables, "file_cache_base_path", "/Data/MixedCaseCache");
+ Assertions.assertEquals("/Data/MixedCaseCache",
variables.getFileCacheBasePath());
+ }
+
+ @Test
+ void hiveTextCompressionIsNormalized() throws Exception {
+ SessionVariable variables = new SessionVariable();
+ set(variables, "hive_text_compression", "UNCOMPRESSED");
+ Assertions.assertEquals("plain", variables.hiveTextCompression());
+ set(variables, "hive_text_compression", "ZSTD");
+ Assertions.assertEquals("zstd", variables.hiveTextCompression());
+ }
+
+ @Test
+ void sqlConvertorFeaturesAreSentInLowerCase() throws Exception {
+ SessionVariable variables = new SessionVariable();
+ set(variables, "enable_sql_convertor_features",
"CTAS,DELETE_ALL_COMMENT");
+ Assertions.assertEquals(Arrays.asList("ctas", "delete_all_comment"),
+ Arrays.asList(variables.getSqlConvertorFeatures()));
+ }
+
+ @Test
+ void mongodbReadConcernHashDoesNotDependOnLetterCase() throws Exception {
+ SessionVariable upper = new SessionVariable();
+ SessionVariable lower = new SessionVariable();
+ set(upper, "mongodb_read_concern", "LOCAL");
+ set(lower, "mongodb_read_concern", "local");
+ Assertions.assertEquals(lower.getAffectQueryResultVariableHashCode(),
+ upper.getAffectQueryResultVariableHashCode());
+ }
+
+ @Test
+ void traceIdKeyIsCaseInsensitiveAndValueKeepsItsCase() throws Exception {
+ ConnectContext context = new ConnectContext();
+ context.setThreadLocalInfo();
+ try {
+ SessionVariable variables = context.getSessionVariable();
+ set(variables, "session_context", "TRACE_ID:AbCdEf");
+ Assertions.assertEquals("AbCdEf", variables.getTraceId());
+ Assertions.assertEquals("AbCdEf", context.traceId());
+ } finally {
+ ConnectContext.remove();
+ }
+ }
+
+ @Test
+ void shapeNodeNamesMatchInAnyLetterCase() throws Exception {
+ SessionVariable variables = new SessionVariable();
+ set(variables, "ignore_shape_nodes", "physicaldistribute,
PHYSICALPROJECT");
+
Assertions.assertTrue(variables.getIgnoreShapePlanNodes().contains("PhysicalDistribute"));
+
Assertions.assertTrue(variables.getIgnoreShapePlanNodes().contains("PhysicalProject"));
+ set(variables, "detail_shape_nodes", "physicalhashjoin,
PHYSICALFILTER");
+
Assertions.assertTrue(variables.getDetailShapePlanNodesSet().contains("PhysicalHashJoin"));
+
Assertions.assertTrue(variables.getDetailShapePlanNodesSet().contains("PhysicalFilter"));
+ }
+
+ @Test
+ void groupCommitIsStoredInLowerCase() throws Exception {
+ SessionVariable variables = new SessionVariable();
+ set(variables, "group_commit", "ASYNC_MODE");
+ Assertions.assertEquals("async_mode", variables.getGroupCommit());
+ }
+
+ @Test
+ void nodeRoleTagIsValidInAnyLetterCase() {
+ Assertions.assertTrue(Tag.validNodeRoleTag("COMPUTATION"));
+ Assertions.assertTrue(Tag.validNodeRoleTag("Mix"));
+ Assertions.assertFalse(Tag.validNodeRoleTag("unknown"));
+ Backend backend = new Backend(1L, "127.0.0.1", 9050);
+ backend.setTagMap(ImmutableMap.of(Tag.TYPE_LOCATION,
Tag.VALUE_DEFAULT_TAG,
+ Tag.TYPE_ROLE, "COMPUTATION"));
+ Assertions.assertTrue(backend.isComputeNode());
+ Assertions.assertEquals(Tag.VALUE_COMPUTATION,
backend.getTagMap().get(Tag.TYPE_ROLE));
+ }
+
+ @Test
+ void defaultCompressionResolvesDefaultAndExplicitTypes() throws Exception {
+ String original = Config.default_compression_type;
+ try {
+ Config.default_compression_type = "default_compression";
+ Assertions.assertEquals(TCompressionType.LZ4F,
PropertyAnalyzer.getDefaultCompressionType());
+ Assertions.assertEquals(TCompressionType.LZ4F,
+ PropertyAnalyzer.getCompressionTypeFromProperties(
+
Collections.singletonMap(PropertyAnalyzer.PROPERTIES_COMPRESSION,
+ "DEFAULT_COMPRESSION")));
+ Config.default_compression_type = "NONE";
+ Assertions.assertEquals(TCompressionType.NO_COMPRESSION,
PropertyAnalyzer.getDefaultCompressionType());
+ Assertions.assertEquals(TCompressionType.NO_COMPRESSION,
+ PropertyAnalyzer.getCompressionTypeFromProperties(
+
Collections.singletonMap(PropertyAnalyzer.PROPERTIES_COMPRESSION,
+ "default_compression")));
+ Config.default_compression_type = "zstd";
+ Assertions.assertEquals(TCompressionType.ZSTD,
PropertyAnalyzer.getDefaultCompressionType());
+ Assertions.assertEquals(TCompressionType.ZSTD,
+ PropertyAnalyzer.getCompressionTypeFromProperties(
+
Collections.singletonMap(PropertyAnalyzer.PROPERTIES_COMPRESSION,
+ "default_compression")));
+ } finally {
+ Config.default_compression_type = original;
+ }
+ }
+
+ @Test
+ void readFromJsonAndMapNormalizeStringCaseVariables() throws Exception {
+ SessionVariable fromJson = new SessionVariable();
+
fromJson.readFromJson("{\"serde_dialect\":\"PRESTO\",\"block_encryption_mode\":\"aes_256_cbc\","
+ +
"\"force_sort_algorithm\":\"HEAP\",\"group_commit\":\"ASYNC_MODE\"}");
+ Assertions.assertEquals("presto", fromJson.serdeDialect);
+ Assertions.assertEquals("AES_256_CBC",
fromJson.getBlockEncryptionMode());
+ Assertions.assertEquals("heap", fromJson.forceSortAlgorithm);
+ Assertions.assertEquals("async_mode", fromJson.getGroupCommit());
+
+ SessionVariable fromMap = new SessionVariable();
+ fromMap.readFromMap(ImmutableMap.of(
+ "serde_dialect", "HIVE",
+ "block_encryption_mode", "sm4_128_cbc",
+ "pre_materialized_view_rewrite_strategy", "not_in_rbo",
+ "hive_text_compression", "ZSTD"));
+ Assertions.assertEquals("hive", fromMap.serdeDialect);
+ Assertions.assertEquals("SM4_128_CBC",
fromMap.getBlockEncryptionMode());
+ Assertions.assertEquals("NOT_IN_RBO",
fromMap.getPreMaterializedViewRewriteStrategy());
+ Assertions.assertEquals("zstd", fromMap.hiveTextCompression());
+ }
+}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/qe/SessionVariableMongoReadPolicyTest.java
b/fe/fe-core/src/test/java/org/apache/doris/qe/SessionVariableMongoReadPolicyTest.java
index aaded237612..992d7d79c96 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/qe/SessionVariableMongoReadPolicyTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/qe/SessionVariableMongoReadPolicyTest.java
@@ -28,6 +28,7 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
class SessionVariableMongoReadPolicyTest {
@@ -59,13 +60,15 @@ class SessionVariableMongoReadPolicyTest {
set(variables, "mongodb_read_preference", value);
Assertions.assertEquals(value,
VariableMgr.toMap(variables).get("mongodb_read_preference"));
}
- for (String value : List.of("inherit", "local", "majority",
"available", "snapshot", "SNAPSHOT", "LOCAL", "INHERIT")) {
+ for (String value : List.of("inherit", "local", "majority",
"available", "snapshot",
+ "SNAPSHOT", "LOCAL", "INHERIT")) {
set(variables, "mongodb_read_concern", value);
- Assertions.assertEquals(value,
VariableMgr.toMap(variables).get("mongodb_read_concern"));
+ Assertions.assertEquals(value.toLowerCase(Locale.ROOT),
+ VariableMgr.toMap(variables).get("mongodb_read_concern"));
}
Map<String, String> forwarded = variables.getForwardVariables();
Assertions.assertEquals("INHERIT",
forwarded.get("mongodb_read_preference"));
- Assertions.assertEquals("INHERIT",
forwarded.get("mongodb_read_concern"));
+ Assertions.assertEquals("inherit",
forwarded.get("mongodb_read_concern"));
}
@Test
diff --git a/regression-test/data/datatype_p0/serde/test_serde_dialect.out
b/regression-test/data/datatype_p0/serde/test_serde_dialect.out
index bb404123113..ca6877394cc 100644
--- a/regression-test/data/datatype_p0/serde/test_serde_dialect.out
+++ b/regression-test/data/datatype_p0/serde/test_serde_dialect.out
@@ -5,3 +5,9 @@
-- !sql01 --
1 2 3 4 5 1.1 2 123456.123456789
2024-06-30 2024-06-30T10:10:11 2024-06-30T10:10:11.123456
59.50.185.152 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff this is a string with ,
and " abc ef 123ndedwdw true [1,2,3,4,5] [1, 2, 3, NULL, 5]
[1.1, 2.1, 3.1, NULL, 5] [1.10000, 2.10000, 3.00000, NULL, 5.12345]
[abc, de, f", NULL, ] [{k1=v1, k2=NULL, k3=, k4=a , "a}, {k1=v1, k2=NULL, k3
, "abc=, k4=a , "a}] [[abc, de, f", NULL, ], [], NULL] \N \N
{k1=v1, k2=NULL, k3=, k4=a , "a} {k1=[[abc, de, f", NULL [...]
+-- !sql_upper_presto --
+1 2 3 4 5 1.1 2 123456.123456789
2024-06-30 2024-06-30T10:10:11 2024-06-30T10:10:11.123456
59.50.185.152 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff this is a string with ,
and " abc ef 123ndedwdw true [1,2,3,4,5] [1, 2, 3, NULL, 5]
[1.1, 2.1, 3.1, NULL, 5] [1.10000, 2.10000, 3.00000, NULL, 5.12345]
[abc, de, f", NULL, ] [{k1=v1, k2=NULL, k3=, k4=a , "a}, {k1=v1, k2=NULL, k3
, "abc=, k4=a , "a}] [[abc, de, f", NULL, ], [], NULL] \N \N
{k1=v1, k2=NULL, k3=, k4=a , "a} {k1=[[abc, de, f", NULL [...]
+
+-- !sql_mixed_doris --
+1 2 3 4 5 1.1 2 123456.123456789
2024-06-30 2024-06-30T10:10:11 2024-06-30T10:10:11.123456
59.50.185.152 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff this is a string with ,
and " abc ef 123ndedwdw true [1,2,3,4,5] [1, 2, 3, null, 5]
[1.1, 2.1, 3.1, null, 5] [1.10000, 2.10000, 3.00000, null, 5.12345]
["abc", "de, f"", null, ""] [{"k1":"v1", "k2":null, "k3":"", "k4":"a ,
"a"}, {"k1":"v1", "k2":null, "k3 , "abc":"", "k4":"a , "a"}] [["abc", "de, f"",
null, ""], [], null] \N \N {"k1":"v1", "k2" [...]
+
diff --git
a/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out
b/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out
index 9e847d7910b..4bad6c0373b 100644
---
a/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out
+++
b/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out
@@ -316,3 +316,18 @@ zhang
-- !sql57 --
\N
+-- !sql58 --
+3dym0E7/+1zbrLIaBVNHSw==
+
+-- !sql59 --
+text
+
+-- !sql60 --
+FSYstvOmH2cXy7B/072Mug==
+
+-- !sql61 --
+text
+
+-- !sql62 --
+text
+
diff --git a/regression-test/suites/datatype_p0/serde/test_serde_dialect.groovy
b/regression-test/suites/datatype_p0/serde/test_serde_dialect.groovy
index 2005296af3f..e59110d9b58 100644
--- a/regression-test/suites/datatype_p0/serde/test_serde_dialect.groovy
+++ b/regression-test/suites/datatype_p0/serde/test_serde_dialect.groovy
@@ -108,4 +108,10 @@ suite("test_serde_dialect", "p0") {
sql """set serde_dialect="invalid""""
exception "sqlDialect value is invalid"
}
+
+ // the dialect name is accepted in any letter case and takes effect
+ sql """set serde_dialect="PRESTO";"""
+ order_qt_sql_upper_presto """select * from test_serde_dialect_tbl"""
+ sql """set serde_dialect="Doris";"""
+ order_qt_sql_mixed_doris """select * from test_serde_dialect_tbl"""
}
diff --git
a/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy
b/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy
index c909f5eba2c..e8282d51945 100644
---
a/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy
+++
b/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy
@@ -300,4 +300,14 @@ suite("test_encryption_function") {
//four arg (column/const) with wrong mode
qt_sql57 """ select sm4_decrypt(sm4_encrypt(k,"doris","abcdefghij",
"SM4_128_CBC"),"doris","abcdefghij","SM4_555_CBC") from quantile_table2; """
+
+ // the session variable accepts the mode name in any letter case
+ sql "set block_encryption_mode=\"aes_256_cbc\";"
+ order_qt_sql58 "SELECT
TO_BASE64(AES_ENCRYPT('text','F3229A0B371ED2D9441B830D21A390C3'));"
+ order_qt_sql59 "SELECT
AES_DECRYPT(FROM_BASE64('3dym0E7/+1zbrLIaBVNHSw=='),'F3229A0B371ED2D9441B830D21A390C3');"
+ sql "set block_encryption_mode=\"sm4_128_cbc\";"
+ order_qt_sql60 "SELECT
TO_BASE64(SM4_ENCRYPT('text','F3229A0B371ED2D9441B830D21A390C3'));"
+ order_qt_sql61 "SELECT
SM4_DECRYPT(FROM_BASE64('FSYstvOmH2cXy7B/072Mug=='),'F3229A0B371ED2D9441B830D21A390C3');"
+ sql "set block_encryption_mode=\"\";"
+ order_qt_sql62 "SELECT AES_DECRYPT(AES_ENCRYPT('text', 'doris',
'0123456789abcdef', 'aes_256_cfb'), 'doris', '0123456789abcdef',
'Aes_256_Cfb');"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]