JingsongLi commented on code in PR #1196:
URL: https://github.com/apache/incubator-paimon/pull/1196#discussion_r1200520438
##########
paimon-core/src/main/java/org/apache/paimon/WriteMode.java:
##########
@@ -32,7 +32,11 @@ public enum WriteMode implements DescribedEnum {
"append-only",
"The table can only accept append-only insert operations. Neither
data deduplication nor any "
+ "primary key constraints will be done when inserting
rows into paimon."),
- CHANGE_LOG("change-log", "The table can accept insert/delete/update
operations.");
+ CHANGE_LOG("change-log", "The table can accept insert/delete/update
operations."),
+ TABLE(
+ "table",
+ "The table without bucket. Don't guarantee the order in the
table. "
Review Comment:
We can have streaming read too. But just no order guarantee.
`This table is used in the traditional sense of "table". It can act like a
Hive or Iceberg table. It can be written and read in a distributed manner
without the concept of a bucket. It can be streaming read but no order
guarantee.`
##########
paimon-core/src/main/java/org/apache/paimon/table/BatchFileStoreTable.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.CoreOptions;
+import org.apache.paimon.WriteMode;
+import org.apache.paimon.annotation.VisibleForTesting;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.fs.FileIO;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.manifest.ManifestCacheFilter;
+import org.apache.paimon.operation.AppendOnlyFileStoreWrite;
+import org.apache.paimon.schema.TableSchema;
+import org.apache.paimon.table.sink.InternalRowKeyAndBucketExtractor;
+import org.apache.paimon.table.sink.TableWriteImpl;
+import org.apache.paimon.types.RowKind;
+import org.apache.paimon.utils.Preconditions;
+
+/** {@link FileStoreTable} for {@link WriteMode#TABLE} write mode. */
+public class BatchFileStoreTable extends AppendOnlyFileStoreTable {
+
+ @VisibleForTesting private static final int batchTableBucket = 0;
+
+ BatchFileStoreTable(FileIO fileIO, Path path, TableSchema tableSchema) {
+ super(fileIO, path, tableSchema);
+ Preconditions.checkState(
+ tableSchema.options().get(CoreOptions.BUCKET_KEY.key()) ==
null,
Review Comment:
also check `bucket`?
##########
paimon-core/src/main/java/org/apache/paimon/table/BatchFileStoreTable.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.CoreOptions;
+import org.apache.paimon.WriteMode;
+import org.apache.paimon.annotation.VisibleForTesting;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.fs.FileIO;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.manifest.ManifestCacheFilter;
+import org.apache.paimon.operation.AppendOnlyFileStoreWrite;
+import org.apache.paimon.schema.TableSchema;
+import org.apache.paimon.table.sink.InternalRowKeyAndBucketExtractor;
+import org.apache.paimon.table.sink.TableWriteImpl;
+import org.apache.paimon.types.RowKind;
+import org.apache.paimon.utils.Preconditions;
+
+/** {@link FileStoreTable} for {@link WriteMode#TABLE} write mode. */
+public class BatchFileStoreTable extends AppendOnlyFileStoreTable {
+
+ @VisibleForTesting private static final int batchTableBucket = 0;
+
+ BatchFileStoreTable(FileIO fileIO, Path path, TableSchema tableSchema) {
+ super(fileIO, path, tableSchema);
+ Preconditions.checkState(
+ tableSchema.options().get(CoreOptions.BUCKET_KEY.key()) ==
null,
+ "\"Table mode could not set properties 'bucket_key' and
'bucket'");
+ }
+
+ @Override
+ public TableWriteImpl<InternalRow> newWrite(
+ String commitUser, ManifestCacheFilter manifestFilter) {
+ AppendOnlyFileStoreWrite writer = store().newWrite(commitUser);
+ writer.withOverwrite(true);
Review Comment:
Why with overwrite?
##########
paimon-core/src/main/java/org/apache/paimon/table/BatchFileStoreTable.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.CoreOptions;
+import org.apache.paimon.WriteMode;
+import org.apache.paimon.annotation.VisibleForTesting;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.fs.FileIO;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.manifest.ManifestCacheFilter;
+import org.apache.paimon.operation.AppendOnlyFileStoreWrite;
+import org.apache.paimon.schema.TableSchema;
+import org.apache.paimon.table.sink.InternalRowKeyAndBucketExtractor;
+import org.apache.paimon.table.sink.TableWriteImpl;
+import org.apache.paimon.types.RowKind;
+import org.apache.paimon.utils.Preconditions;
+
+/** {@link FileStoreTable} for {@link WriteMode#TABLE} write mode. */
+public class BatchFileStoreTable extends AppendOnlyFileStoreTable {
+
+ @VisibleForTesting private static final int batchTableBucket = 0;
Review Comment:
checkstyle.
Please `mvn clean install -DskipTests` in your local machine.
##########
paimon-core/src/main/java/org/apache/paimon/table/FileStoreTableFactory.java:
##########
@@ -83,6 +83,10 @@ public static FileStoreTable create(
}
if (writeMode == WriteMode.APPEND_ONLY) {
table = new AppendOnlyFileStoreTable(fileIO, tablePath,
tableSchema);
+ } else if (writeMode == WriteMode.TABLE) {
+ // BatchFileStoreTable need set write_only option to disable
compaction
+ dynamicOptions.set(CoreOptions.WRITE_ONLY.key(), "true");
Review Comment:
I prefer disable compaction for `AppendOnlyFileStoreWrite`. Or just create a
`BatchFileStoreWrite`.
--
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]