nsivabalan commented on a change in pull request #3740:
URL: https://github.com/apache/hudi/pull/3740#discussion_r721853559
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieMergeHandle.java
##########
@@ -257,6 +257,21 @@ private boolean writeUpdateRecord(HoodieRecord<T>
hoodieRecord, Option<IndexedRe
return writeRecord(hoodieRecord, indexedRecord);
}
+ protected boolean writeInsertRecord(HoodieRecord<T> hoodieRecord) throws
IOException {
+ Schema schema = useWriterSchema ? tableSchemaWithMetaFields : tableSchema;
+ Option<IndexedRecord> insertRecord =
hoodieRecord.getData().getInsertValue(schema, config.getProps());
+ // just skip the ignored record
+ if (insertRecord.isPresent() && insertRecord.get().equals(IGNORE_RECORD)) {
+ return false;
+ }
+ if (writeRecord(hoodieRecord, insertRecord)) {
+ insertRecordsWritten++;
Review comment:
this is a slight change in behavior compared to master.
insertRecordsWritten was incremented irrespective of whether writeRecord()
return true or false, but now we are changing it. This looks like the right
thing to do. Just wanted to clarify.
##########
File path:
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestCOWDataSourceConsistentInserts.scala
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.functional
+
+import org.apache.hudi.DataSourceWriteOptions
+import org.apache.hudi.config.{HoodieCompactionConfig, HoodieWriteConfig}
+import org.apache.hudi.hive.NonPartitionedExtractor
+import org.apache.hudi.keygen.NonpartitionedKeyGenerator
+import org.apache.hudi.testutils.SparkClientFunctionalTestHarness
+import org.apache.spark.sql.SaveMode.Append
+import org.apache.spark.sql.functions.col
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.{Tag, Test}
+
+
+@Tag("functional")
+class TestCOWDataSourceConsistentInserts extends
SparkClientFunctionalTestHarness {
Review comment:
curious as to why a new class just for this? Can't we add these tests to
existing classes ?
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieConcatHandle.java
##########
@@ -94,4 +104,22 @@ public void write(GenericRecord oldRecord) {
}
recordsWritten++;
}
+
+ @Override
+ public List<WriteStatus> close() {
+ try {
+ while (recordItr.hasNext()) {
+ HoodieRecord<T> record = recordItr.next();
+ if (needsUpdateLocation()) {
+ record.unseal();
+ record.setNewLocation(new HoodieRecordLocation(instantTime, fileId));
+ record.seal();
+ }
+ writeInsertRecord(record);
+ }
+ } catch (IOException e) {
+ throw new HoodieUpsertException("Failed to close UpdateHandle", e);
+ }
+ return super.close();
Review comment:
let's not call super.close(). lets add a protected method in MergeHandle
just for processing records within close. and here awe can just over-ride that
method alone. I am talking about lines 364 to 367 in MergeHandle.
##########
File path:
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestCOWDataSourceConsistentInserts.scala
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.functional
+
+import org.apache.hudi.DataSourceWriteOptions
+import org.apache.hudi.config.{HoodieCompactionConfig, HoodieWriteConfig}
+import org.apache.hudi.hive.NonPartitionedExtractor
+import org.apache.hudi.keygen.NonpartitionedKeyGenerator
+import org.apache.hudi.testutils.SparkClientFunctionalTestHarness
+import org.apache.spark.sql.SaveMode.Append
+import org.apache.spark.sql.functions.col
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.{Tag, Test}
+
+
+@Tag("functional")
+class TestCOWDataSourceConsistentInserts extends
SparkClientFunctionalTestHarness {
Review comment:
Also, lets see if we can write it at write client layer.
https://github.com/apache/hudi/blob/46808dcb1fe22491326a9e831dd4dde4c70796fb/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/client/functional/TestHoodieClientOnCopyOnWriteStorage.java#L656
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]