You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "waywtdcc (via GitHub)" <gi...@apache.org> on 2023/02/27 05:28:49 UTC

[GitHub] [hudi] waywtdcc opened a new pull request, #8054: [HUDI-5854]Support flink table column comment

waywtdcc opened a new pull request, #8054:
URL: https://github.com/apache/hudi/pull/8054

   ### Change Logs
   
   Support flink table column comment
   
   ### Impact
   
   _Describe any public API or user-facing feature change or any performance impact._
   
   ### Risk level (write none, low medium or high below)
   no
   
   ### Documentation Update
   
   _Describe any necessary documentation update if there is any new feature, config, or user-facing change_
   
   - _The config description must be updated if new configs are added or the default value of the configs are changed_
   - _Any new feature or user-facing change requires updating the Hudi website. Please create a Jira ticket, attach the
     ticket number here and follow the [instruction](https://hudi.apache.org/contribute/developer-setup#website) to make
     changes to the website._
   
   ### Contributor's checklist
   
   - [ ] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [ ] Change Logs and Impact were stated clearly
   - [ ] Adequate tests were added if applicable
   - [ ] CI passed
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hudi] hudi-bot commented on pull request #8054: [HUDI-5854]Support flink table column comment

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #8054:
URL: https://github.com/apache/hudi/pull/8054#issuecomment-1445785347

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "aa427720b60b9f60929dbc64af598d1b1d77d91a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "aa427720b60b9f60929dbc64af598d1b1d77d91a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "1c7aea45b09d188365e908b5f62bba41a5be02a8",
       "status" : "CANCELED",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=15425",
       "triggerID" : "1c7aea45b09d188365e908b5f62bba41a5be02a8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "6187dc06f1ea42201f32ace89947c9fd8da941d7",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "6187dc06f1ea42201f32ace89947c9fd8da941d7",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * aa427720b60b9f60929dbc64af598d1b1d77d91a UNKNOWN
   * 1c7aea45b09d188365e908b5f62bba41a5be02a8 Azure: [CANCELED](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=15425) 
   * 6187dc06f1ea42201f32ace89947c9fd8da941d7 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hudi] danny0405 commented on a diff in pull request #8054: [HUDI-5854]Support flink table column comment

Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #8054:
URL: https://github.com/apache/hudi/pull/8054#discussion_r1118454738


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/catalog/HiveSchemaUtils.java:
##########
@@ -251,4 +213,44 @@ public static Pair<List<FieldSchema>, List<FieldSchema>> splitSchemaByPartitionK
     }
     return Pair.of(regularColumns, partitionColumns);
   }
+
+  /**
+   * Create Hive field schemas from Flink table schema including the hoodie metadata fields.
+   */
+  public static List<FieldSchema> toHiveFieldSchemaWithResolved(ResolvedSchema schema, boolean withOperationField) {
+    List<FieldSchema> columns = new ArrayList<>();
+    Collection<String> metaFields = new ArrayList<>(HoodieRecord.HOODIE_META_COLUMNS);
+    if (withOperationField) {
+      metaFields.add(HoodieRecord.OPERATION_METADATA_FIELD);
+    }
+
+    for (String metaField : metaFields) {
+      columns.add(new FieldSchema(metaField, "string", null));
+    }
+    columns.addAll(createHiveColumnsWithResolved(schema));
+    return columns;
+  }
+
+  /**
+   * Create Hive columns from Flink table schema.
+   */
+  private static List<FieldSchema> createHiveColumnsWithResolved(ResolvedSchema schema) {
+    final DataType dataType = schema.toPhysicalRowDataType();
+    List<Column> sourceColumns = schema.getColumns();
+    final RowType rowType = (RowType) dataType.getLogicalType();
+    final String[] fieldNames = rowType.getFieldNames().toArray(new String[0]);
+    final DataType[] fieldTypes = dataType.getChildren().toArray(new DataType[0]);
+
+    List<FieldSchema> columns = new ArrayList<>(fieldNames.length);
+
+    for (int i = 0; i < fieldNames.length; i++) {
+      columns.add(

Review Comment:
   Why just move these methods around?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hudi] danny0405 commented on a diff in pull request #8054: [HUDI-5854]Support flink table column comment

Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #8054:
URL: https://github.com/apache/hudi/pull/8054#discussion_r1257693948


##########
hudi-sync/hudi-sync-common/src/main/java/org/apache/hudi/sync/common/util/SparkDataSourceTableUtils.java:
##########
@@ -34,13 +35,21 @@
 import static org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.BINARY;
 
 public class SparkDataSourceTableUtils {
+
+  public static Map<String, String> getSparkTableProperties(List<String> partitionNames, String sparkVersion,
+                                                            int schemaLengthThreshold, MessageType schema) {
+    return getSparkTableProperties(partitionNames, sparkVersion, schemaLengthThreshold, schema, Collections.emptyMap());
+  }
+
   /**
    * Get Spark Sql related table properties. This is used for spark datasource table.
-   * @param schema  The schema to write to the table.
+   *
+   * @param schema The schema to write to the table.
    * @return A new parameters added the spark's table properties.
    */
   public static Map<String, String> getSparkTableProperties(List<String> partitionNames, String sparkVersion,
-                                                            int schemaLengthThreshold, MessageType schema) {
+                                                            int schemaLengthThreshold, MessageType schema,
+                                                            Map<String, String> commentMap) {

Review Comment:
   Where does the new method be used?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hudi] danny0405 commented on a diff in pull request #8054: [HUDI-5854]Support flink table column comment

Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #8054:
URL: https://github.com/apache/hudi/pull/8054#discussion_r1257693688


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/catalog/HiveSchemaUtils.java:
##########
@@ -176,45 +177,6 @@ private static DataType toFlinkPrimitiveType(PrimitiveTypeInfo hiveType) {
     }
   }
 
-  /**
-   * Create Hive field schemas from Flink table schema including the hoodie metadata fields.
-   */
-  public static List<FieldSchema> toHiveFieldSchema(TableSchema schema, boolean withOperationField) {
-    List<FieldSchema> columns = new ArrayList<>();

Review Comment:
   Can we modify directly on these methods instead of removing and adding new one?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hudi] danny0405 commented on a diff in pull request #8054: [HUDI-5854]Support flink table column comment

Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #8054:
URL: https://github.com/apache/hudi/pull/8054#discussion_r1118459723


##########
hudi-sync/hudi-sync-common/src/main/java/org/apache/hudi/sync/common/util/Parquet2SparkSchemaUtils.java:
##########
@@ -34,25 +38,43 @@
 public class Parquet2SparkSchemaUtils {
 
   public static String convertToSparkSchemaJson(GroupType parquetSchema) {
+    return convertToSparkSchemaJson(parquetSchema, Collections.emptyMap());
+  }
+
+  public static String convertToSparkSchemaJson(GroupType parquetSchema, Map<String, String> commentMap) {
     String fieldsJsonString = parquetSchema.getFields().stream().map(field -> {
       switch (field.getRepetition()) {
         case OPTIONAL:
           return "{\"name\":\"" + field.getName() + "\",\"type\":" + convertFieldType(field)
-                  + ",\"nullable\":true,\"metadata\":{}}";
+              + ",\"nullable\":true,\"metadata\":{" + getCommentStr(commentMap.get(field.getName())) + "}}";
         case REQUIRED:
           return "{\"name\":\"" + field.getName() + "\",\"type\":" + convertFieldType(field)
-                  + ",\"nullable\":false,\"metadata\":{}}";
+              + ",\"nullable\":false,\"metadata\":{" + getCommentStr(commentMap.get(field.getName())) + "}}";
         case REPEATED:
           String arrayType = arrayType(field, false);
           return "{\"name\":\"" + field.getName() + "\",\"type\":" + arrayType
-                  + ",\"nullable\":false,\"metadata\":{}}";
+              + ",\"nullable\":false,\"metadata\":{" + getCommentStr(commentMap.get(field.getName())) + "}}";
         default:
           throw new UnsupportedOperationException("Unsupport convert " + field + " to spark sql type");
       }
     }).reduce((a, b) -> a + "," + b).orElse("");
     return "{\"type\":\"struct\",\"fields\":[" + fieldsJsonString + "]}";
   }
 
+  /**
+   * get comment
+   *
+   * @param comment
+   * @return
+   */
+  private static String getCommentStr(String comment) {
+    String result = "";

Review Comment:
   What are these spark changes used for?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hudi] hudi-bot commented on pull request #8054: [HUDI-5854]Support flink table column comment

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #8054:
URL: https://github.com/apache/hudi/pull/8054#issuecomment-1446160496

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "aa427720b60b9f60929dbc64af598d1b1d77d91a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "aa427720b60b9f60929dbc64af598d1b1d77d91a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "1c7aea45b09d188365e908b5f62bba41a5be02a8",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=15425",
       "triggerID" : "1c7aea45b09d188365e908b5f62bba41a5be02a8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "6187dc06f1ea42201f32ace89947c9fd8da941d7",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=15427",
       "triggerID" : "6187dc06f1ea42201f32ace89947c9fd8da941d7",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * aa427720b60b9f60929dbc64af598d1b1d77d91a UNKNOWN
   * 6187dc06f1ea42201f32ace89947c9fd8da941d7 Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=15427) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hudi] hudi-bot commented on pull request #8054: [HUDI-5854]Support flink table column comment

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #8054:
URL: https://github.com/apache/hudi/pull/8054#issuecomment-1445738530

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "aa427720b60b9f60929dbc64af598d1b1d77d91a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "aa427720b60b9f60929dbc64af598d1b1d77d91a",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * aa427720b60b9f60929dbc64af598d1b1d77d91a UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hudi] danny0405 commented on pull request #8054: [HUDI-5854]Support flink table column comment

Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on PR #8054:
URL: https://github.com/apache/hudi/pull/8054#issuecomment-1623461063

   Hi @waywtdcc , is the patch ready for review now, the review comments are not addressed yet.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hudi] hudi-bot commented on pull request #8054: [HUDI-5854]Support flink table column comment

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #8054:
URL: https://github.com/apache/hudi/pull/8054#issuecomment-1445829896

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "aa427720b60b9f60929dbc64af598d1b1d77d91a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "aa427720b60b9f60929dbc64af598d1b1d77d91a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "1c7aea45b09d188365e908b5f62bba41a5be02a8",
       "status" : "CANCELED",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=15425",
       "triggerID" : "1c7aea45b09d188365e908b5f62bba41a5be02a8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "6187dc06f1ea42201f32ace89947c9fd8da941d7",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=15427",
       "triggerID" : "6187dc06f1ea42201f32ace89947c9fd8da941d7",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * aa427720b60b9f60929dbc64af598d1b1d77d91a UNKNOWN
   * 1c7aea45b09d188365e908b5f62bba41a5be02a8 Azure: [CANCELED](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=15425) 
   * 6187dc06f1ea42201f32ace89947c9fd8da941d7 Azure: [PENDING](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=15427) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hudi] hudi-bot commented on pull request #8054: [HUDI-5854]Support flink table column comment

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #8054:
URL: https://github.com/apache/hudi/pull/8054#issuecomment-1445779305

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "aa427720b60b9f60929dbc64af598d1b1d77d91a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "aa427720b60b9f60929dbc64af598d1b1d77d91a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "1c7aea45b09d188365e908b5f62bba41a5be02a8",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=15425",
       "triggerID" : "1c7aea45b09d188365e908b5f62bba41a5be02a8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "6187dc06f1ea42201f32ace89947c9fd8da941d7",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "6187dc06f1ea42201f32ace89947c9fd8da941d7",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * aa427720b60b9f60929dbc64af598d1b1d77d91a UNKNOWN
   * 1c7aea45b09d188365e908b5f62bba41a5be02a8 Azure: [PENDING](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=15425) 
   * 6187dc06f1ea42201f32ace89947c9fd8da941d7 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [hudi] waywtdcc commented on pull request #8054: [HUDI-5854]Support flink table column comment

Posted by "waywtdcc (via GitHub)" <gi...@apache.org>.
waywtdcc commented on PR #8054:
URL: https://github.com/apache/hudi/pull/8054#issuecomment-1624769554

   > Hi @waywtdcc , is the patch ready for review now, the review comments are not addressed yet.
   
   Review comments and questions have been dealt with


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org