This is an automated email from the ASF dual-hosted git repository.

dataroaring 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 173e2489fe1 [feat](table) let compress type be configable (#56074)
173e2489fe1 is described below

commit 173e2489fe17e8a35928ab4d3618600cbe957f3e
Author: Yongqiang YANG <[email protected]>
AuthorDate: Wed Sep 17 11:07:12 2025 +0800

    [feat](table) let compress type be configable (#56074)
---
 .../main/java/org/apache/doris/common/Config.java  |  9 ++++++
 .../org/apache/doris/catalog/TableProperty.java    |  8 +++--
 .../apache/doris/common/util/PropertyAnalyzer.java | 34 +++++++++++++++-------
 .../query_p0/system/test_table_properties.groovy   |  3 ++
 4 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java 
b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
index 9e351b07850..d6e883f1171 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
@@ -1749,6 +1749,9 @@ public class Config extends ConfigBase {
     @ConfField(masterOnly = true)
     public static int lower_case_table_names = 0;
 
+    /**
+     * Used to limit the length of table name.
+     */
     @ConfField(mutable = true, masterOnly = true)
     public static int table_name_length_limit = 64;
 
@@ -1758,6 +1761,12 @@ public class Config extends ConfigBase {
                     + "If the existing column comment is too long, it will be 
truncated when displayed."})
     public static int column_comment_length_limit = -1;
 
+    @ConfField(mutable = true, description = {
+            "内部表的默认压缩类型。支持的值有: LZ4, LZ4F, LZ4HC, ZLIB, ZSTD, SNAPPY, NONE。",
+            "Default compression type for internal tables. Supported values: 
LZ4, LZ4F, LZ4HC, ZLIB, ZSTD,"
+            + " SNAPPY, NONE."})
+    public static String default_compression_type = "LZ4F";
+
     /*
      * The job scheduling interval of the schema change handler.
      * The user should not set this parameter.
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java
index 013bdb52173..cdeba9021bc 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java
@@ -570,8 +570,12 @@ public class TableProperty implements GsonPostProcessable {
     }
 
     public TableProperty buildCompressionType() {
-        compressionType = 
TCompressionType.valueOf(properties.getOrDefault(PropertyAnalyzer.PROPERTIES_COMPRESSION,
-                TCompressionType.LZ4F.name()));
+        try {
+            compressionType = 
PropertyAnalyzer.getCompressionTypeFromProperties(properties);
+        } catch (AnalysisException e) {
+            LOG.error("failed to analyze compression type", e);
+            compressionType = TCompressionType.ZSTD;
+        }
         return this;
     }
 
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 634d5e23ead..3da280320f9 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
@@ -1055,16 +1055,7 @@ public class PropertyAnalyzer {
         return goalSizeMbytes;
     }
 
-    // analyzeCompressionType will parse the compression type from properties
-    public static TCompressionType analyzeCompressionType(Map<String, String> 
properties) throws AnalysisException {
-        String compressionType = "";
-        if (properties != null && 
properties.containsKey(PROPERTIES_COMPRESSION)) {
-            compressionType = properties.get(PROPERTIES_COMPRESSION);
-            properties.remove(PROPERTIES_COMPRESSION);
-        } else {
-            return TCompressionType.LZ4F;
-        }
-
+    public static TCompressionType stringToCompressionType(String 
compressionType) throws AnalysisException {
         if (compressionType.equalsIgnoreCase("no_compression")) {
             return TCompressionType.NO_COMPRESSION;
         } else if (compressionType.equalsIgnoreCase("lz4")) {
@@ -1079,6 +1070,9 @@ public class PropertyAnalyzer {
             return TCompressionType.ZSTD;
         } else if (compressionType.equalsIgnoreCase("snappy")) {
             return TCompressionType.SNAPPY;
+        } else if (compressionType.equalsIgnoreCase("default_compression")
+                && 
!Config.default_compression_type.equalsIgnoreCase("default_compression")) {
+            return TCompressionType.valueOf(Config.default_compression_type);
         } else if (compressionType.equalsIgnoreCase("default_compression")) {
             return TCompressionType.LZ4F;
         } else {
@@ -1086,6 +1080,26 @@ public class PropertyAnalyzer {
         }
     }
 
+    // analyzeCompressionType will parse the compression type from properties
+    public static TCompressionType 
getCompressionTypeFromProperties(Map<String, String> properties)
+            throws AnalysisException {
+        String compressionType = "";
+        if (properties != null && 
properties.containsKey(PROPERTIES_COMPRESSION)) {
+            compressionType = properties.get(PROPERTIES_COMPRESSION);
+        } else {
+            return stringToCompressionType(Config.default_compression_type);
+        }
+
+        return stringToCompressionType(compressionType);
+    }
+
+    // analyzeCompressionType will parse the compression type from properties
+    public static TCompressionType analyzeCompressionType(Map<String, String> 
properties) throws AnalysisException {
+        TCompressionType compressionType = 
getCompressionTypeFromProperties(properties);
+        properties.remove(PROPERTIES_COMPRESSION);
+        return compressionType;
+    }
+
     public static long alignTo4K(long size) {
         return (size + 4095) & ~4095;
     }
diff --git 
a/regression-test/suites/query_p0/system/test_table_properties.groovy 
b/regression-test/suites/query_p0/system/test_table_properties.groovy
index 766bcf86fe3..a656108f626 100644
--- a/regression-test/suites/query_p0/system/test_table_properties.groovy
+++ b/regression-test/suites/query_p0/system/test_table_properties.groovy
@@ -84,6 +84,9 @@ suite("test_table_properties") {
        );
     """
 
+    def compression_count = sql """ select count(*) from 
information_schema.table_properties where table_schema=\"${dbName}\" and 
PROPERTY_NAME=\"compression\" """;
+    assert compression_count.first()[0] == 3;
+
     qt_select_check_1 """select count(*) from 
information_schema.table_properties where table_schema=\"${dbName}\"; """
     qt_select_check_2 """select * from information_schema.table_properties 
where table_schema=\"${dbName}\" and PROPERTY_NAME != 
"default.replication_allocation" ORDER BY 
TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PROPERTY_NAME,PROPERTY_VALUE"""
     sql """


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to