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

morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 29fb03f4180 branch-3.1: [feat](table) let compress type be configable 
#56074 (#56276)
29fb03f4180 is described below

commit 29fb03f4180f7b52fb77386b28bc7167cb11f4b2
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Sep 25 17:22:25 2025 +0800

    branch-3.1: [feat](table) let compress type be configable #56074 (#56276)
    
    Cherry-picked from #56074
    
    Co-authored-by: Yongqiang YANG <[email protected]>
---
 .../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 3f6577e3669..5276bf0d57a 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
@@ -1691,6 +1691,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;
 
@@ -1700,6 +1703,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 ba13a9d193d..576fe44a06c 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
@@ -586,8 +586,12 @@ public class TableProperty implements Writable, 
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 e50a40304be..bd1eddb0c9f 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
@@ -1056,16 +1056,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")) {
@@ -1080,6 +1071,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 {
@@ -1087,6 +1081,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