You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by la...@apache.org on 2022/06/20 18:50:16 UTC

[impala] 03/05: IMPALA-11367: Fix some formatting bugs when DESCRIBE FORMATTED for Iceberg tables

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

laszlog pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 75ccdc6aecdee3918fa36cae507e4fc74c6078b5
Author: LPL <li...@sensorsdata.cn>
AuthorDate: Fri Jun 17 19:07:02 2022 +0800

    IMPALA-11367: Fix some formatting bugs when DESCRIBE FORMATTED for Iceberg tables
    
    Fix some formatting bugs when DESCRIBE FORMATTED for Iceberg tables:
     - 'LINE_DELIM' is missing on '# Partition Transform Information'
     - The partition transform columns header should be
     'col_name,transform_type,NULL'
    
    Testing:
     - Existing tests
    
    Change-Id: I991644cefb34decc843a5542b47eaec11d7b6e42
    Reviewed-on: http://gerrit.cloudera.org:8080/18634
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 .../apache/impala/util/HiveMetadataFormatUtils.java    | 18 ++++++++++++++++--
 .../queries/QueryTest/iceberg-create.test              |  7 +++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/fe/src/main/java/org/apache/impala/util/HiveMetadataFormatUtils.java b/fe/src/main/java/org/apache/impala/util/HiveMetadataFormatUtils.java
index c18789e3c..6af28b2c5 100644
--- a/fe/src/main/java/org/apache/impala/util/HiveMetadataFormatUtils.java
+++ b/fe/src/main/java/org/apache/impala/util/HiveMetadataFormatUtils.java
@@ -107,8 +107,9 @@ public class HiveMetadataFormatUtils {
   public static String getPartitionTransformInformation(List<FieldSchema> partCols) {
     StringBuilder info = new StringBuilder(DEFAULT_STRINGBUILDER_SIZE);
     if (partCols == null || partCols.isEmpty()) return info.toString();
-    info.append("# Partition Transform Information").append(LINE_DELIM);
-    formatColumnsHeader(info, null);
+    info.append(LINE_DELIM).append("# Partition Transform Information")
+        .append(LINE_DELIM);
+    formatPartitionTransformColumnsHeader(info);
     formatAllFields(info, partCols, false, null);
     return info.toString();
   }
@@ -120,6 +121,13 @@ public class HiveMetadataFormatUtils {
     columnInformation.append(LINE_DELIM);
   }
 
+  private static void formatPartitionTransformColumnsHeader(
+      StringBuilder columnInformation) {
+    columnInformation.append("# "); // Easy for shell scripts to ignore
+    formatOutput(getPartitionTransformColumnsHeader(), columnInformation, false, true);
+    columnInformation.append(LINE_DELIM);
+  }
+
   /**
    * Prints a row with the given fields into the builder The last field could be a
    * multiline field, and the extra lines should be padded
@@ -167,6 +175,8 @@ public class HiveMetadataFormatUtils {
   private static final String colStatsSchema = "col_name,data_type,min,max,num_nulls,"
       + "distinct_count,avg_col_len,max_col_len,num_trues,num_falses,comment"
       + "#string:string:string:string:string:string:string:string:string:string:string";
+  private static final String partitionTransformSchema =
+      "col_name,transform_type#string:string";
 
   public static String[] getColumnsHeader(List<ColumnStatisticsObj> colStats) {
     String colSchema = schema;
@@ -176,6 +186,10 @@ public class HiveMetadataFormatUtils {
     return colSchema.split("#")[0].split(",");
   }
 
+  public static String[] getPartitionTransformColumnsHeader() {
+    return partitionTransformSchema.split("#")[0].split(",");
+  }
+
   /**
    * Write formatted column information into given StringBuilder
    *
diff --git a/testdata/workloads/functional-query/queries/QueryTest/iceberg-create.test b/testdata/workloads/functional-query/queries/QueryTest/iceberg-create.test
index 9cf268530..cf083af47 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/iceberg-create.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/iceberg-create.test
@@ -497,7 +497,9 @@ create table ice_part_hadoop_tbl (
 ---- QUERY
 describe formatted ice_part_hadoop_tbl;
 ---- RESULTS: VERIFY_IS_SUBSET
+'','NULL','NULL'
 '# Partition Transform Information','NULL','NULL'
+'# col_name            ','transform_type      ','NULL'
 'col_year','YEAR','NULL'
 'col_month','MONTH','NULL'
 'col_day','DAY','NULL'
@@ -535,7 +537,9 @@ create table ice_part_hadoop_catalog (
 ---- QUERY
 describe formatted ice_part_hadoop_catalog;
 ---- RESULTS: VERIFY_IS_SUBSET
+'','NULL','NULL'
 '# Partition Transform Information','NULL','NULL'
+'# col_name            ','transform_type      ','NULL'
 'col_year','YEAR','NULL'
 'col_month','MONTH','NULL'
 'col_day','DAY','NULL'
@@ -570,7 +574,9 @@ create table ice_part_catalogs (
 ---- QUERY
 describe formatted ice_part_catalogs;
 ---- RESULTS: VERIFY_IS_SUBSET
+'','NULL','NULL'
 '# Partition Transform Information','NULL','NULL'
+'# col_name            ','transform_type      ','NULL'
 'col_year','YEAR','NULL'
 'col_month','MONTH','NULL'
 'col_day','DAY','NULL'
@@ -590,6 +596,7 @@ create table ice_non_partition (i int, s string, ts timestamp, d date) stored as
 describe formatted ice_non_partition;
 ---- RESULTS: VERIFY_IS_NOT_IN
 '# Partition Transform Information','NULL','NULL'
+'# col_name            ','transform_type      ','NULL'
 ---- TYPES
 string, string, string
 ====