You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "leaves12138 (via GitHub)" <gi...@apache.org> on 2025/02/13 11:23:17 UTC

[PR] [core][fix] Partial update should not return empty row with non-null column type exist [paimon]

leaves12138 opened a new pull request, #5077:
URL: https://github.com/apache/paimon/pull/5077

   
   <!-- Please specify the module before the PR name: [core] ... or [flink] ... -->
   
   ### Purpose
   
   <!-- Linking this pull request to the issue -->
   Linked issue: close #xxx
   
   <!-- What is the purpose of the change -->
   
   ### Tests
   
   <!-- List UT and IT cases to verify this change -->
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   


-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] [fix] Partial update should not return empty row with non-null column type exist [paimon]

Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on code in PR #5077:
URL: https://github.com/apache/paimon/pull/5077#discussion_r1955651131


##########
paimon-format/src/main/java/org/apache/paimon/format/parquet/writer/ParquetRowDataWriter.java:
##########
@@ -526,6 +587,13 @@ public void write(InternalRow row) {
                     recordConsumer.startField(fieldName, i);
                     writer.write(row, i);
                     recordConsumer.endField(fieldName, i);
+                } else {
+                    if (!fieldWriters[i].isNullable()) {
+                        throw new IllegalArgumentException(
+                                format(
+                                        "Parquet does not support null values in non-nullable fields. Field name : %s expected not null but found null",

Review Comment:
   If the field in parquet file in not nullable, then row.isNullAt(i) must be false. Otherwise, we throw exception out.



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] [fix] Partial update should not return empty row with non-null column type exist [paimon]

Posted by "tsreaper (via GitHub)" <gi...@apache.org>.
tsreaper commented on code in PR #5077:
URL: https://github.com/apache/paimon/pull/5077#discussion_r1957910723


##########
paimon-core/src/main/java/org/apache/paimon/mergetree/compact/PartialUpdateMergeFunction.java:
##########
@@ -140,13 +153,15 @@ public void add(KeyValue kv) {
                             "3. Configure 'sequence-group's to retract partial columns.");
 
             throw new IllegalArgumentException(msg);
-        }
-
-        latestSequenceNumber = kv.sequenceNumber();
-        if (fieldSeqComparators.isEmpty()) {
-            updateNonNullFields(kv);
         } else {
-            updateWithSequenceGroup(kv);
+            latestSequenceNumber = kv.sequenceNumber();

Review Comment:
   Why not update sequence number when value type is retract?



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] [fix] Partial update should not return empty row with non-null column type exist [paimon]

Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on code in PR #5077:
URL: https://github.com/apache/paimon/pull/5077#discussion_r1955648267


##########
paimon-core/src/test/java/org/apache/paimon/table/PartialUpdateTableTest.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.paimon.table;
+
+import org.apache.paimon.catalog.Catalog;
+import org.apache.paimon.catalog.CatalogContext;
+import org.apache.paimon.catalog.CatalogFactory;
+import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.data.BinaryString;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.disk.IOManagerImpl;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.options.CatalogOptions;
+import org.apache.paimon.options.Options;
+import org.apache.paimon.reader.RecordReader;
+import org.apache.paimon.schema.Schema;
+import org.apache.paimon.table.sink.StreamTableCommit;
+import org.apache.paimon.table.sink.StreamTableWrite;
+import org.apache.paimon.table.sink.StreamWriteBuilder;
+import org.apache.paimon.table.source.ReadBuilder;
+import org.apache.paimon.table.source.TableScan;
+import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.types.RowKind;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.paimon.types.DataTypesTest.assertThat;
+
+/** Test partial update table. */
+public class PartialUpdateTableTest {
+
+    @TempDir public static java.nio.file.Path tempDir;
+    private Catalog catalog;
+    private final Identifier identifier = Identifier.create("my_db", "my_table");
+
+    @BeforeEach
+    public void before() throws Exception {
+        Options options = new Options();
+        options.set(CatalogOptions.WAREHOUSE, new Path(path()).toUri().toString());
+        catalog = CatalogFactory.createCatalog(CatalogContext.create(options));
+        catalog.createDatabase("my_db", true);
+        catalog.createTable(identifier, schema(), true);
+    }
+
+    public static String path() {
+        return tempDir.toString() + "/" + PartialUpdateTableTest.class.getSimpleName();
+    }
+
+    private static Schema schema() {
+        Schema.Builder schemaBuilder = Schema.newBuilder();
+        schemaBuilder.column("biz_no", DataTypes.INT());
+        schemaBuilder.column("customer_id", DataTypes.STRING());
+        schemaBuilder.column("payable_amount", DataTypes.INT());
+        schemaBuilder.column("g1", DataTypes.INT());
+        schemaBuilder.primaryKey("biz_no");
+        schemaBuilder.option("bucket", "1");
+        schemaBuilder.option("file.format", "parquet");
+        schemaBuilder.option("merge-engine", "partial-update");
+        schemaBuilder.option("fields.g1.sequence-group", "payable_amount");
+        schemaBuilder.option("fields.payable_amount.aggregation-function", "sum");
+        schemaBuilder.option("deletion-vectors.enabled", "true");
+        schemaBuilder.option("write-buffer-spillable", "true");
+        return schemaBuilder.build();
+    }
+
+    @Test
+    public void testWriteDeleteRecordWithNoInsertData() throws Exception {
+        Table table = catalog.getTable(identifier);
+        StreamWriteBuilder writeBuilder = table.newStreamWriteBuilder();
+        try (StreamTableCommit commit = writeBuilder.newCommit();
+                StreamTableWrite write = writeBuilder.newWrite()) {
+            write.withIOManager(new IOManagerImpl(tempDir.toString()));
+            for (int snapshotId = 0; snapshotId < 100; snapshotId++) {
+                int bizNo = snapshotId;

Review Comment:
   Just for more clear
   



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] [fix] Partial update should not return empty row with non-null column type exist [paimon]

Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on code in PR #5077:
URL: https://github.com/apache/paimon/pull/5077#discussion_r1955648267


##########
paimon-core/src/test/java/org/apache/paimon/table/PartialUpdateTableTest.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.paimon.table;
+
+import org.apache.paimon.catalog.Catalog;
+import org.apache.paimon.catalog.CatalogContext;
+import org.apache.paimon.catalog.CatalogFactory;
+import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.data.BinaryString;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.disk.IOManagerImpl;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.options.CatalogOptions;
+import org.apache.paimon.options.Options;
+import org.apache.paimon.reader.RecordReader;
+import org.apache.paimon.schema.Schema;
+import org.apache.paimon.table.sink.StreamTableCommit;
+import org.apache.paimon.table.sink.StreamTableWrite;
+import org.apache.paimon.table.sink.StreamWriteBuilder;
+import org.apache.paimon.table.source.ReadBuilder;
+import org.apache.paimon.table.source.TableScan;
+import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.types.RowKind;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.paimon.types.DataTypesTest.assertThat;
+
+/** Test partial update table. */
+public class PartialUpdateTableTest {
+
+    @TempDir public static java.nio.file.Path tempDir;
+    private Catalog catalog;
+    private final Identifier identifier = Identifier.create("my_db", "my_table");
+
+    @BeforeEach
+    public void before() throws Exception {
+        Options options = new Options();
+        options.set(CatalogOptions.WAREHOUSE, new Path(path()).toUri().toString());
+        catalog = CatalogFactory.createCatalog(CatalogContext.create(options));
+        catalog.createDatabase("my_db", true);
+        catalog.createTable(identifier, schema(), true);
+    }
+
+    public static String path() {
+        return tempDir.toString() + "/" + PartialUpdateTableTest.class.getSimpleName();
+    }
+
+    private static Schema schema() {
+        Schema.Builder schemaBuilder = Schema.newBuilder();
+        schemaBuilder.column("biz_no", DataTypes.INT());
+        schemaBuilder.column("customer_id", DataTypes.STRING());
+        schemaBuilder.column("payable_amount", DataTypes.INT());
+        schemaBuilder.column("g1", DataTypes.INT());
+        schemaBuilder.primaryKey("biz_no");
+        schemaBuilder.option("bucket", "1");
+        schemaBuilder.option("file.format", "parquet");
+        schemaBuilder.option("merge-engine", "partial-update");
+        schemaBuilder.option("fields.g1.sequence-group", "payable_amount");
+        schemaBuilder.option("fields.payable_amount.aggregation-function", "sum");
+        schemaBuilder.option("deletion-vectors.enabled", "true");
+        schemaBuilder.option("write-buffer-spillable", "true");
+        return schemaBuilder.build();
+    }
+
+    @Test
+    public void testWriteDeleteRecordWithNoInsertData() throws Exception {
+        Table table = catalog.getTable(identifier);
+        StreamWriteBuilder writeBuilder = table.newStreamWriteBuilder();
+        try (StreamTableCommit commit = writeBuilder.newCommit();
+                StreamTableWrite write = writeBuilder.newWrite()) {
+            write.withIOManager(new IOManagerImpl(tempDir.toString()));
+            for (int snapshotId = 0; snapshotId < 100; snapshotId++) {
+                int bizNo = snapshotId;

Review Comment:
   Just for more clear
   



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] [fix] Partial update should not return empty row with non-null column type exist [paimon]

Posted by "wwj6591812 (via GitHub)" <gi...@apache.org>.
wwj6591812 commented on code in PR #5077:
URL: https://github.com/apache/paimon/pull/5077#discussion_r1955501825


##########
paimon-core/src/test/java/org/apache/paimon/table/PartialUpdateTableTest.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.paimon.table;
+
+import org.apache.paimon.catalog.Catalog;
+import org.apache.paimon.catalog.CatalogContext;
+import org.apache.paimon.catalog.CatalogFactory;
+import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.data.BinaryString;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.disk.IOManagerImpl;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.options.CatalogOptions;
+import org.apache.paimon.options.Options;
+import org.apache.paimon.reader.RecordReader;
+import org.apache.paimon.schema.Schema;
+import org.apache.paimon.table.sink.StreamTableCommit;
+import org.apache.paimon.table.sink.StreamTableWrite;
+import org.apache.paimon.table.sink.StreamWriteBuilder;
+import org.apache.paimon.table.source.ReadBuilder;
+import org.apache.paimon.table.source.TableScan;
+import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.types.RowKind;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.paimon.types.DataTypesTest.assertThat;
+
+/** Test partial update table. */
+public class PartialUpdateTableTest {
+
+    @TempDir public static java.nio.file.Path tempDir;
+    private Catalog catalog;
+    private final Identifier identifier = Identifier.create("my_db", "my_table");
+
+    @BeforeEach
+    public void before() throws Exception {
+        Options options = new Options();
+        options.set(CatalogOptions.WAREHOUSE, new Path(path()).toUri().toString());
+        catalog = CatalogFactory.createCatalog(CatalogContext.create(options));
+        catalog.createDatabase("my_db", true);
+        catalog.createTable(identifier, schema(), true);
+    }
+
+    public static String path() {
+        return tempDir.toString() + "/" + PartialUpdateTableTest.class.getSimpleName();
+    }
+
+    private static Schema schema() {
+        Schema.Builder schemaBuilder = Schema.newBuilder();
+        schemaBuilder.column("biz_no", DataTypes.INT());
+        schemaBuilder.column("customer_id", DataTypes.STRING());
+        schemaBuilder.column("payable_amount", DataTypes.INT());
+        schemaBuilder.column("g1", DataTypes.INT());
+        schemaBuilder.primaryKey("biz_no");
+        schemaBuilder.option("bucket", "1");
+        schemaBuilder.option("file.format", "parquet");
+        schemaBuilder.option("merge-engine", "partial-update");
+        schemaBuilder.option("fields.g1.sequence-group", "payable_amount");
+        schemaBuilder.option("fields.payable_amount.aggregation-function", "sum");
+        schemaBuilder.option("deletion-vectors.enabled", "true");
+        schemaBuilder.option("write-buffer-spillable", "true");
+        return schemaBuilder.build();
+    }
+
+    @Test
+    public void testWriteDeleteRecordWithNoInsertData() throws Exception {
+        Table table = catalog.getTable(identifier);
+        StreamWriteBuilder writeBuilder = table.newStreamWriteBuilder();
+        try (StreamTableCommit commit = writeBuilder.newCommit();
+                StreamTableWrite write = writeBuilder.newWrite()) {
+            write.withIOManager(new IOManagerImpl(tempDir.toString()));
+            for (int snapshotId = 0; snapshotId < 100; snapshotId++) {
+                int bizNo = snapshotId;

Review Comment:
   Local variable 'bizNo' 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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] [fix] Partial update should not return empty row with non-null column type exist [paimon]

Posted by "wwj6591812 (via GitHub)" <gi...@apache.org>.
wwj6591812 commented on code in PR #5077:
URL: https://github.com/apache/paimon/pull/5077#discussion_r1955487386


##########
paimon-core/src/main/java/org/apache/paimon/mergetree/compact/PartialUpdateMergeFunction.java:
##########
@@ -263,13 +283,26 @@ private void retractWithSequenceGroup(KeyValue kv) {
         }
     }
 
+    private void initRow(GenericRow row, InternalRow value) {
+        for (int i = 0; i < getters.length; i++) {
+            Object field = getters[i].getFieldOrNull(value);
+            if (!nullables[i]) {
+                if (field != null) {
+                    row.setField(i, getters[i].getFieldOrNull(value));
+                } else {
+                    throw new IllegalArgumentException("Field " + i + " can not be null");

Review Comment:
   May be RuntimeException is better here?



##########
paimon-core/src/test/java/org/apache/paimon/table/PartialUpdateTableTest.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.paimon.table;
+
+import org.apache.paimon.catalog.Catalog;
+import org.apache.paimon.catalog.CatalogContext;
+import org.apache.paimon.catalog.CatalogFactory;
+import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.data.BinaryString;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.disk.IOManagerImpl;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.options.CatalogOptions;
+import org.apache.paimon.options.Options;
+import org.apache.paimon.reader.RecordReader;
+import org.apache.paimon.schema.Schema;
+import org.apache.paimon.table.sink.StreamTableCommit;
+import org.apache.paimon.table.sink.StreamTableWrite;
+import org.apache.paimon.table.sink.StreamWriteBuilder;
+import org.apache.paimon.table.source.ReadBuilder;
+import org.apache.paimon.table.source.TableScan;
+import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.types.RowKind;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.paimon.types.DataTypesTest.assertThat;
+
+/** Test partial update table. */
+public class PartialUpdateTableTest {
+
+    @TempDir public static java.nio.file.Path tempDir;
+    private Catalog catalog;
+    private final Identifier identifier = Identifier.create("my_db", "my_table");
+
+    @BeforeEach
+    public void before() throws Exception {
+        Options options = new Options();
+        options.set(CatalogOptions.WAREHOUSE, new Path(path()).toUri().toString());
+        catalog = CatalogFactory.createCatalog(CatalogContext.create(options));
+        catalog.createDatabase("my_db", true);
+        catalog.createTable(identifier, schema(), true);
+    }
+
+    public static String path() {
+        return tempDir.toString() + "/" + PartialUpdateTableTest.class.getSimpleName();
+    }
+
+    private static Schema schema() {
+        Schema.Builder schemaBuilder = Schema.newBuilder();
+        schemaBuilder.column("biz_no", DataTypes.INT());
+        schemaBuilder.column("customer_id", DataTypes.STRING());
+        schemaBuilder.column("payable_amount", DataTypes.INT());
+        schemaBuilder.column("g1", DataTypes.INT());
+        schemaBuilder.primaryKey("biz_no");
+        schemaBuilder.option("bucket", "1");
+        schemaBuilder.option("file.format", "parquet");
+        schemaBuilder.option("merge-engine", "partial-update");
+        schemaBuilder.option("fields.g1.sequence-group", "payable_amount");
+        schemaBuilder.option("fields.payable_amount.aggregation-function", "sum");
+        schemaBuilder.option("deletion-vectors.enabled", "true");
+        schemaBuilder.option("write-buffer-spillable", "true");
+        return schemaBuilder.build();
+    }
+
+    @Test
+    public void testWriteDeleteRecordWithNoInsertData() throws Exception {
+        Table table = catalog.getTable(identifier);
+        StreamWriteBuilder writeBuilder = table.newStreamWriteBuilder();
+        try (StreamTableCommit commit = writeBuilder.newCommit();
+                StreamTableWrite write = writeBuilder.newWrite()) {
+            write.withIOManager(new IOManagerImpl(tempDir.toString()));
+            for (int snapshotId = 0; snapshotId < 100; snapshotId++) {
+                int bizNo = snapshotId;

Review Comment:
   Local variable 'bizNo' is redundant 



##########
paimon-core/src/main/java/org/apache/paimon/mergetree/compact/PartialUpdateMergeFunction.java:
##########
@@ -263,13 +283,26 @@ private void retractWithSequenceGroup(KeyValue kv) {
         }
     }
 
+    private void initRow(GenericRow row, InternalRow value) {
+        for (int i = 0; i < getters.length; i++) {
+            Object field = getters[i].getFieldOrNull(value);
+            if (!nullables[i]) {
+                if (field != null) {
+                    row.setField(i, getters[i].getFieldOrNull(value));

Review Comment:
   row.setField(i, field);



##########
paimon-format/src/main/java/org/apache/paimon/format/parquet/writer/ParquetRowDataWriter.java:
##########
@@ -526,6 +587,13 @@ public void write(InternalRow row) {
                     recordConsumer.startField(fieldName, i);
                     writer.write(row, i);
                     recordConsumer.endField(fieldName, i);
+                } else {
+                    if (!fieldWriters[i].isNullable()) {
+                        throw new IllegalArgumentException(
+                                format(
+                                        "Parquet does not support null values in non-nullable fields. Field name : %s expected not null but found null",

Review Comment:
   I have a question here:
   Why all fields in parquet format is non-nullable fields?



##########
paimon-core/src/test/java/org/apache/paimon/table/PartialUpdateTableTest.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.paimon.table;
+
+import org.apache.paimon.catalog.Catalog;
+import org.apache.paimon.catalog.CatalogContext;
+import org.apache.paimon.catalog.CatalogFactory;
+import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.data.BinaryString;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.disk.IOManagerImpl;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.options.CatalogOptions;
+import org.apache.paimon.options.Options;
+import org.apache.paimon.reader.RecordReader;
+import org.apache.paimon.schema.Schema;
+import org.apache.paimon.table.sink.StreamTableCommit;
+import org.apache.paimon.table.sink.StreamTableWrite;
+import org.apache.paimon.table.sink.StreamWriteBuilder;
+import org.apache.paimon.table.source.ReadBuilder;
+import org.apache.paimon.table.source.TableScan;
+import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.types.RowKind;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.paimon.types.DataTypesTest.assertThat;
+
+/** Test partial update table. */
+public class PartialUpdateTableTest {
+
+    @TempDir public static java.nio.file.Path tempDir;
+    private Catalog catalog;
+    private final Identifier identifier = Identifier.create("my_db", "my_table");
+
+    @BeforeEach
+    public void before() throws Exception {
+        Options options = new Options();
+        options.set(CatalogOptions.WAREHOUSE, new Path(path()).toUri().toString());
+        catalog = CatalogFactory.createCatalog(CatalogContext.create(options));
+        catalog.createDatabase("my_db", true);
+        catalog.createTable(identifier, schema(), true);
+    }
+
+    public static String path() {

Review Comment:
   private



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] [fix] Partial update should not return empty row with non-null column type exist [paimon]

Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on code in PR #5077:
URL: https://github.com/apache/paimon/pull/5077#discussion_r1958985463


##########
paimon-core/src/main/java/org/apache/paimon/mergetree/compact/PartialUpdateMergeFunction.java:
##########
@@ -263,13 +283,26 @@ private void retractWithSequenceGroup(KeyValue kv) {
         }
     }
 
+    private void initRow(GenericRow row, InternalRow value) {
+        for (int i = 0; i < getters.length; i++) {
+            Object field = getters[i].getFieldOrNull(value);
+            if (!nullables[i]) {
+                if (field != null) {
+                    row.setField(i, getters[i].getFieldOrNull(value));
+                } else {
+                    throw new IllegalArgumentException("Field " + i + " can not be null");

Review Comment:
   Maybe we can build a new Exception System (PaimonException(ErrorCode, msg).



##########
paimon-core/src/test/java/org/apache/paimon/table/PartialUpdateTableTest.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.paimon.table;
+
+import org.apache.paimon.catalog.Catalog;
+import org.apache.paimon.catalog.CatalogContext;
+import org.apache.paimon.catalog.CatalogFactory;
+import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.data.BinaryString;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.disk.IOManagerImpl;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.options.CatalogOptions;
+import org.apache.paimon.options.Options;
+import org.apache.paimon.reader.RecordReader;
+import org.apache.paimon.schema.Schema;
+import org.apache.paimon.table.sink.StreamTableCommit;
+import org.apache.paimon.table.sink.StreamTableWrite;
+import org.apache.paimon.table.sink.StreamWriteBuilder;
+import org.apache.paimon.table.source.ReadBuilder;
+import org.apache.paimon.table.source.TableScan;
+import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.types.RowKind;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.paimon.types.DataTypesTest.assertThat;
+
+/** Test partial update table. */
+public class PartialUpdateTableTest {
+
+    @TempDir public static java.nio.file.Path tempDir;
+    private Catalog catalog;
+    private final Identifier identifier = Identifier.create("my_db", "my_table");
+
+    @BeforeEach
+    public void before() throws Exception {
+        Options options = new Options();
+        options.set(CatalogOptions.WAREHOUSE, new Path(path()).toUri().toString());
+        catalog = CatalogFactory.createCatalog(CatalogContext.create(options));
+        catalog.createDatabase("my_db", true);
+        catalog.createTable(identifier, schema(), true);
+    }
+
+    public static String path() {

Review Comment:
   Thanks



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] [fix] Partial update should not return empty row with non-null column type exist [paimon]

Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on code in PR #5077:
URL: https://github.com/apache/paimon/pull/5077#discussion_r1958985008


##########
paimon-core/src/main/java/org/apache/paimon/mergetree/compact/PartialUpdateMergeFunction.java:
##########
@@ -263,13 +283,26 @@ private void retractWithSequenceGroup(KeyValue kv) {
         }
     }
 
+    private void initRow(GenericRow row, InternalRow value) {
+        for (int i = 0; i < getters.length; i++) {
+            Object field = getters[i].getFieldOrNull(value);
+            if (!nullables[i]) {
+                if (field != null) {
+                    row.setField(i, getters[i].getFieldOrNull(value));

Review Comment:
   Thanks



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] [fix] Partial update should not return empty row with non-null column type exist [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #5077:
URL: https://github.com/apache/paimon/pull/5077#discussion_r1955751280


##########
paimon-core/src/main/java/org/apache/paimon/mergetree/compact/PartialUpdateMergeFunction.java:
##########
@@ -87,19 +90,23 @@ protected PartialUpdateMergeFunction(
             Map<Integer, FieldAggregator> fieldAggregators,
             boolean fieldSequenceEnabled,
             boolean removeRecordOnDelete,
-            Set<Integer> sequenceGroupPartialDelete) {
+            Set<Integer> sequenceGroupPartialDelete,
+            Boolean[] nullables) {

Review Comment:
   Why using Boolean[] instead of boolean[]?



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] [fix] Partial update should not return empty row with non-null column type exist [paimon]

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


-- 
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: issues-unsubscribe@paimon.apache.org

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