You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "jonvex (via GitHub)" <gi...@apache.org> on 2024/10/24 20:21:01 UTC

[PR] [HUDI-8192] test streaming with custom merger [hudi]

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

   ### Change Logs
   
   Ensure that custom merger can be used with spark streaming
   
   ### Impact
   
   testing!!!
   
   ### Risk level (write none, low medium or high below)
   
   none
   
   ### Documentation Update
   
   N/A
   
   ### 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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 69421594f72fbff7b735b17340ceccc6e36f6a98 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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1400",
       "triggerID" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 69421594f72fbff7b735b17340ceccc6e36f6a98 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1400) 
   
   <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


Re: [PR] [HUDI-8192] Add tests of custom merger in Spark structured streaming [hudi]

Posted by "yihua (via GitHub)" <gi...@apache.org>.
yihua merged PR #12161:
URL: https://github.com/apache/hudi/pull/12161


-- 
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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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


##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/HoodieSparkDeleteRecordMerger.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.hudi.testutils;
+
+import org.apache.hudi.HoodieSparkRecordMerger;
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.collection.Pair;
+
+import org.apache.avro.Schema;
+
+import java.io.IOException;
+
+/**
+ * Instead of merging, it will just delete the record. Use for testing
+ *
+ */
+public class HoodieSparkDeleteRecordMerger extends HoodieSparkRecordMerger {
+  public static final String DELETE_MERGER_STRATEGY = "aea2e14e-19a2-4e33-bc37-f8871d55bd5b";
+
+  @Override
+  public Option<Pair<HoodieRecord, Schema>> merge(HoodieRecord older, Schema oldSchema, HoodieRecord newer, Schema newSchema, TypedProperties props) throws IOException {
+    return Option.empty();

Review Comment:
   I think this is fine



-- 
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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1400",
       "triggerID" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b58f86f404a6a7c622d0ba3f5ab47e2daf51b588",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1870",
       "triggerID" : "b58f86f404a6a7c622d0ba3f5ab47e2daf51b588",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 69421594f72fbff7b735b17340ceccc6e36f6a98 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1400) 
   * b58f86f404a6a7c622d0ba3f5ab47e2daf51b588 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1870) 
   
   <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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1400",
       "triggerID" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b58f86f404a6a7c622d0ba3f5ab47e2daf51b588",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1870",
       "triggerID" : "b58f86f404a6a7c622d0ba3f5ab47e2daf51b588",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b58f86f404a6a7c622d0ba3f5ab47e2daf51b588 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1870) 
   
   <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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1400",
       "triggerID" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b58f86f404a6a7c622d0ba3f5ab47e2daf51b588",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1870",
       "triggerID" : "b58f86f404a6a7c622d0ba3f5ab47e2daf51b588",
       "triggerType" : "PUSH"
     }, {
       "hash" : "134da4aac53b056ccee987535336105ae57cab8a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "134da4aac53b056ccee987535336105ae57cab8a",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b58f86f404a6a7c622d0ba3f5ab47e2daf51b588 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1870) 
   * 134da4aac53b056ccee987535336105ae57cab8a 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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1400",
       "triggerID" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 69421594f72fbff7b735b17340ceccc6e36f6a98 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1400) 
   
   <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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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

   > We have lots of tests for merge mode. This test is just to make sure configs are propagating correctly for streaming. Using a custom merger proves that the configs are actually being used. So I think adding more to this testing is redundant
   
   Understood, but this functional test tests the merge modes with structured streaming specifically.  So we should add the two other modes with smoke checks.


-- 
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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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


##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/HoodieSparkDeleteRecordMerger.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.hudi.testutils;
+
+import org.apache.hudi.HoodieSparkRecordMerger;
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.collection.Pair;
+
+import org.apache.avro.Schema;
+
+import java.io.IOException;
+
+/**
+ * Instead of merging, it will just delete the record. Use for testing
+ *
+ */
+public class HoodieSparkDeleteRecordMerger extends HoodieSparkRecordMerger {
+  public static final String DELETE_MERGER_STRATEGY = "aea2e14e-19a2-4e33-bc37-f8871d55bd5b";
+
+  @Override
+  public Option<Pair<HoodieRecord, Schema>> merge(HoodieRecord older, Schema oldSchema, HoodieRecord newer, Schema newSchema, TypedProperties props) throws IOException {
+    return Option.empty();

Review Comment:
   Could we test something more complex by summing up a field or doing conditional deletes instead of blindly returning empty record for all cases?



##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestStructuredStreaming.scala:
##########
@@ -496,15 +496,52 @@ class TestStructuredStreaming extends HoodieSparkClientTestBase {
     val inputDF1 = spark.read.json(spark.sparkContext.parallelize(records1, 2))
     inputDF1.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
     val opts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> HoodieTableType.MERGE_ON_READ.name()) + (DataSourceWriteOptions.STREAMING_DISABLE_COMPACTION.key -> "true")
-    streamingWrite(inputDF1.schema, sourcePath, destPath, opts, "000")
+    streamingWrite(inputDF1.schema, sourcePath, destPath, opts)
     for (i <- 1 to 24) {
       val id = String.format("%03d", new Integer(i))
       val records = recordsToStrings(dataGen.generateUpdates(id, 10)).asScala.toList
       val inputDF = spark.read.json(spark.sparkContext.parallelize(records, 2))
       inputDF.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
-      streamingWrite(inputDF.schema, sourcePath, destPath, opts, id)
+      streamingWrite(inputDF.schema, sourcePath, destPath, opts)
     }
-    val metaClient = HoodieTestUtils.createMetaClient(storage, destPath);
+    val metaClient = HoodieTestUtils.createMetaClient(storage, destPath)
     assertTrue(metaClient.getActiveTimeline.getCommitAndReplaceTimeline.empty())
+    assertEquals(25, metaClient.getActiveTimeline.countInstants())
+  }
+
+  @ParameterizedTest
+  @ValueSource(booleans = Array(true, false))
+  def testStructuredStreamingWithMergeMode(isCow: Boolean): Unit = {
+    val (sourcePath, destPath) = initStreamingSourceAndDestPath("source", "dest")
+    // First chunk of data
+    val records1 = recordsToStrings(dataGen.generateInserts("000", 10)).asScala.toList
+    val inputDF1 = spark.read.json(spark.sparkContext.parallelize(records1, 2))
+    inputDF1.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
+    val tableType = if (isCow) {
+      "COPY_ON_WRITE"
+    } else {
+      "MERGE_ON_READ"
+    }
+    val opts = commonOpts ++ Map(DataSourceWriteOptions.OPERATION.key -> UPSERT_OPERATION_OPT_VAL,
+      DataSourceWriteOptions.TABLE_TYPE.key() -> tableType,
+      DataSourceWriteOptions.RECORD_MERGE_MODE.key() -> RecordMergeMode.CUSTOM.name(),

Review Comment:
   Could we test all three merge modes here?



-- 
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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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

   We have lots of tests for merge mode. This test is just to make sure configs are propagating correctly for streaming. Using a custom merger proves that the configs are actually being used. So I think adding more to this testing is redundant 


-- 
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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1400",
       "triggerID" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b58f86f404a6a7c622d0ba3f5ab47e2daf51b588",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "b58f86f404a6a7c622d0ba3f5ab47e2daf51b588",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 69421594f72fbff7b735b17340ceccc6e36f6a98 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1400) 
   * b58f86f404a6a7c622d0ba3f5ab47e2daf51b588 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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1400",
       "triggerID" : "69421594f72fbff7b735b17340ceccc6e36f6a98",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b58f86f404a6a7c622d0ba3f5ab47e2daf51b588",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1870",
       "triggerID" : "b58f86f404a6a7c622d0ba3f5ab47e2daf51b588",
       "triggerType" : "PUSH"
     }, {
       "hash" : "134da4aac53b056ccee987535336105ae57cab8a",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1940",
       "triggerID" : "134da4aac53b056ccee987535336105ae57cab8a",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 134da4aac53b056ccee987535336105ae57cab8a Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=1940) 
   
   <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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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


##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestStructuredStreaming.scala:
##########
@@ -498,15 +498,77 @@ class TestStructuredStreaming extends HoodieSparkClientTestBase {
     val inputDF1 = spark.read.json(spark.sparkContext.parallelize(records1, 2))
     inputDF1.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
     val opts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> HoodieTableType.MERGE_ON_READ.name()) + (DataSourceWriteOptions.STREAMING_DISABLE_COMPACTION.key -> "true")
-    streamingWrite(inputDF1.schema, sourcePath, destPath, opts, "000")
+    streamingWrite(inputDF1.schema, sourcePath, destPath, opts)
     for (i <- 1 to 24) {
       val id = String.format("%03d", new Integer(i))
       val records = recordsToStrings(dataGen.generateUpdates(id, 10)).asScala.toList
       val inputDF = spark.read.json(spark.sparkContext.parallelize(records, 2))
       inputDF.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
-      streamingWrite(inputDF.schema, sourcePath, destPath, opts, id)
+      streamingWrite(inputDF.schema, sourcePath, destPath, opts)
     }
-    val metaClient = HoodieTestUtils.createMetaClient(storage, destPath);
+    val metaClient = HoodieTestUtils.createMetaClient(storage, destPath)
     assertTrue(metaClient.getActiveTimeline.getCommitAndReplaceTimeline.empty())
+    assertEquals(25, metaClient.getActiveTimeline.countInstants())
+  }
+
+  @ParameterizedTest
+  @CsvSource(Array(
+    "COPY_ON_WRITE,EVENT_TIME_ORDERING",
+    "MERGE_ON_READ,EVENT_TIME_ORDERING",
+    "COPY_ON_WRITE,COMMIT_TIME_ORDERING",
+    "MERGE_ON_READ,COMMIT_TIME_ORDERING",
+    "COPY_ON_WRITE,CUSTOM",
+    "MERGE_ON_READ,CUSTOM"))
+  def testStructuredStreamingWithMergeMode(tableType: String, mergerType: String): Unit = {
+    val (sourcePath, destPath) = initStreamingSourceAndDestPath("source", "dest")
+    // First chunk of data
+    val records1 = recordsToStrings(dataGen.generateInserts("000", 10)).asScala.toList
+    val inputDF1 = spark.read.json(spark.sparkContext.parallelize(records1, 2))
+    inputDF1.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
+    var opts = commonOpts ++ Map(DataSourceWriteOptions.OPERATION.key -> UPSERT_OPERATION_OPT_VAL,
+      DataSourceWriteOptions.TABLE_TYPE.key() -> tableType,
+      DataSourceWriteOptions.RECORD_MERGE_MODE.key() -> mergerType,
+      HoodieStorageConfig.LOGFILE_DATA_BLOCK_FORMAT.key() -> "parquet",
+      DataSourceWriteOptions.PRECOMBINE_FIELD.key -> "weight")
+    if (mergerType == "CUSTOM") {
+      opts = opts ++ Map(DataSourceWriteOptions.RECORD_MERGE_STRATEGY_ID.key() -> HoodieSparkDeleteRecordMerger.DELETE_MERGER_STRATEGY,
+        DataSourceWriteOptions.RECORD_MERGE_IMPL_CLASSES.key() -> classOf[HoodieSparkDeleteRecordMerger].getName)
+    }
+    streamingWrite(inputDF1.schema, sourcePath, destPath, opts)
+
+
+    val records2 = recordsToStrings(dataGen.generateUniqueUpdates("001", 5)).asScala.toList

Review Comment:
   I increased the size 100 inserts then 50 updates. So I think the chance of not having any updates will be 1 / 2^50



-- 
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


Re: [PR] [HUDI-8192] test streaming with custom merger [hudi]

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


##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestStructuredStreaming.scala:
##########
@@ -498,15 +498,77 @@ class TestStructuredStreaming extends HoodieSparkClientTestBase {
     val inputDF1 = spark.read.json(spark.sparkContext.parallelize(records1, 2))
     inputDF1.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
     val opts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> HoodieTableType.MERGE_ON_READ.name()) + (DataSourceWriteOptions.STREAMING_DISABLE_COMPACTION.key -> "true")
-    streamingWrite(inputDF1.schema, sourcePath, destPath, opts, "000")
+    streamingWrite(inputDF1.schema, sourcePath, destPath, opts)
     for (i <- 1 to 24) {
       val id = String.format("%03d", new Integer(i))
       val records = recordsToStrings(dataGen.generateUpdates(id, 10)).asScala.toList
       val inputDF = spark.read.json(spark.sparkContext.parallelize(records, 2))
       inputDF.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
-      streamingWrite(inputDF.schema, sourcePath, destPath, opts, id)
+      streamingWrite(inputDF.schema, sourcePath, destPath, opts)
     }
-    val metaClient = HoodieTestUtils.createMetaClient(storage, destPath);
+    val metaClient = HoodieTestUtils.createMetaClient(storage, destPath)
     assertTrue(metaClient.getActiveTimeline.getCommitAndReplaceTimeline.empty())
+    assertEquals(25, metaClient.getActiveTimeline.countInstants())
+  }
+
+  @ParameterizedTest
+  @CsvSource(Array(
+    "COPY_ON_WRITE,EVENT_TIME_ORDERING",
+    "MERGE_ON_READ,EVENT_TIME_ORDERING",
+    "COPY_ON_WRITE,COMMIT_TIME_ORDERING",
+    "MERGE_ON_READ,COMMIT_TIME_ORDERING",
+    "COPY_ON_WRITE,CUSTOM",
+    "MERGE_ON_READ,CUSTOM"))
+  def testStructuredStreamingWithMergeMode(tableType: String, mergerType: String): Unit = {
+    val (sourcePath, destPath) = initStreamingSourceAndDestPath("source", "dest")
+    // First chunk of data
+    val records1 = recordsToStrings(dataGen.generateInserts("000", 10)).asScala.toList
+    val inputDF1 = spark.read.json(spark.sparkContext.parallelize(records1, 2))
+    inputDF1.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
+    var opts = commonOpts ++ Map(DataSourceWriteOptions.OPERATION.key -> UPSERT_OPERATION_OPT_VAL,
+      DataSourceWriteOptions.TABLE_TYPE.key() -> tableType,
+      DataSourceWriteOptions.RECORD_MERGE_MODE.key() -> mergerType,
+      HoodieStorageConfig.LOGFILE_DATA_BLOCK_FORMAT.key() -> "parquet",
+      DataSourceWriteOptions.PRECOMBINE_FIELD.key -> "weight")
+    if (mergerType == "CUSTOM") {
+      opts = opts ++ Map(DataSourceWriteOptions.RECORD_MERGE_STRATEGY_ID.key() -> HoodieSparkDeleteRecordMerger.DELETE_MERGER_STRATEGY,
+        DataSourceWriteOptions.RECORD_MERGE_IMPL_CLASSES.key() -> classOf[HoodieSparkDeleteRecordMerger].getName)
+    }
+    streamingWrite(inputDF1.schema, sourcePath, destPath, opts)
+

Review Comment:
   ```suggestion
   ```



##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestStructuredStreaming.scala:
##########
@@ -498,15 +498,77 @@ class TestStructuredStreaming extends HoodieSparkClientTestBase {
     val inputDF1 = spark.read.json(spark.sparkContext.parallelize(records1, 2))
     inputDF1.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
     val opts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> HoodieTableType.MERGE_ON_READ.name()) + (DataSourceWriteOptions.STREAMING_DISABLE_COMPACTION.key -> "true")
-    streamingWrite(inputDF1.schema, sourcePath, destPath, opts, "000")
+    streamingWrite(inputDF1.schema, sourcePath, destPath, opts)
     for (i <- 1 to 24) {
       val id = String.format("%03d", new Integer(i))
       val records = recordsToStrings(dataGen.generateUpdates(id, 10)).asScala.toList
       val inputDF = spark.read.json(spark.sparkContext.parallelize(records, 2))
       inputDF.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
-      streamingWrite(inputDF.schema, sourcePath, destPath, opts, id)
+      streamingWrite(inputDF.schema, sourcePath, destPath, opts)
     }
-    val metaClient = HoodieTestUtils.createMetaClient(storage, destPath);
+    val metaClient = HoodieTestUtils.createMetaClient(storage, destPath)
     assertTrue(metaClient.getActiveTimeline.getCommitAndReplaceTimeline.empty())
+    assertEquals(25, metaClient.getActiveTimeline.countInstants())
+  }
+
+  @ParameterizedTest
+  @CsvSource(Array(
+    "COPY_ON_WRITE,EVENT_TIME_ORDERING",
+    "MERGE_ON_READ,EVENT_TIME_ORDERING",
+    "COPY_ON_WRITE,COMMIT_TIME_ORDERING",
+    "MERGE_ON_READ,COMMIT_TIME_ORDERING",
+    "COPY_ON_WRITE,CUSTOM",
+    "MERGE_ON_READ,CUSTOM"))
+  def testStructuredStreamingWithMergeMode(tableType: String, mergerType: String): Unit = {
+    val (sourcePath, destPath) = initStreamingSourceAndDestPath("source", "dest")
+    // First chunk of data
+    val records1 = recordsToStrings(dataGen.generateInserts("000", 10)).asScala.toList
+    val inputDF1 = spark.read.json(spark.sparkContext.parallelize(records1, 2))
+    inputDF1.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
+    var opts = commonOpts ++ Map(DataSourceWriteOptions.OPERATION.key -> UPSERT_OPERATION_OPT_VAL,
+      DataSourceWriteOptions.TABLE_TYPE.key() -> tableType,
+      DataSourceWriteOptions.RECORD_MERGE_MODE.key() -> mergerType,
+      HoodieStorageConfig.LOGFILE_DATA_BLOCK_FORMAT.key() -> "parquet",
+      DataSourceWriteOptions.PRECOMBINE_FIELD.key -> "weight")
+    if (mergerType == "CUSTOM") {
+      opts = opts ++ Map(DataSourceWriteOptions.RECORD_MERGE_STRATEGY_ID.key() -> HoodieSparkDeleteRecordMerger.DELETE_MERGER_STRATEGY,
+        DataSourceWriteOptions.RECORD_MERGE_IMPL_CLASSES.key() -> classOf[HoodieSparkDeleteRecordMerger].getName)
+    }
+    streamingWrite(inputDF1.schema, sourcePath, destPath, opts)
+
+
+    val records2 = recordsToStrings(dataGen.generateUniqueUpdates("001", 5)).asScala.toList

Review Comment:
   Could we explicitly generate records that have both smaller and higher weight values in the updates so the results are different between `EVENT_TIME_ORDERING` and `COMMIT_TIME_ORDERING` merge modes?



##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestStructuredStreaming.scala:
##########
@@ -498,15 +498,77 @@ class TestStructuredStreaming extends HoodieSparkClientTestBase {
     val inputDF1 = spark.read.json(spark.sparkContext.parallelize(records1, 2))
     inputDF1.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
     val opts = commonOpts + (DataSourceWriteOptions.TABLE_TYPE.key -> HoodieTableType.MERGE_ON_READ.name()) + (DataSourceWriteOptions.STREAMING_DISABLE_COMPACTION.key -> "true")
-    streamingWrite(inputDF1.schema, sourcePath, destPath, opts, "000")
+    streamingWrite(inputDF1.schema, sourcePath, destPath, opts)
     for (i <- 1 to 24) {
       val id = String.format("%03d", new Integer(i))
       val records = recordsToStrings(dataGen.generateUpdates(id, 10)).asScala.toList
       val inputDF = spark.read.json(spark.sparkContext.parallelize(records, 2))
       inputDF.coalesce(1).write.mode(SaveMode.Append).json(sourcePath)
-      streamingWrite(inputDF.schema, sourcePath, destPath, opts, id)
+      streamingWrite(inputDF.schema, sourcePath, destPath, opts)
     }
-    val metaClient = HoodieTestUtils.createMetaClient(storage, destPath);
+    val metaClient = HoodieTestUtils.createMetaClient(storage, destPath)
     assertTrue(metaClient.getActiveTimeline.getCommitAndReplaceTimeline.empty())
+    assertEquals(25, metaClient.getActiveTimeline.countInstants())
+  }
+
+  @ParameterizedTest
+  @CsvSource(Array(
+    "COPY_ON_WRITE,EVENT_TIME_ORDERING",
+    "MERGE_ON_READ,EVENT_TIME_ORDERING",
+    "COPY_ON_WRITE,COMMIT_TIME_ORDERING",
+    "MERGE_ON_READ,COMMIT_TIME_ORDERING",
+    "COPY_ON_WRITE,CUSTOM",
+    "MERGE_ON_READ,CUSTOM"))
+  def testStructuredStreamingWithMergeMode(tableType: String, mergerType: String): Unit = {

Review Comment:
   ```suggestion
     def testStructuredStreamingWithMergeMode(tableType: String, mergerMode: String): Unit = {
   ```



-- 
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