JingsongLi commented on code in PR #126:
URL: https://github.com/apache/flink-table-store/pull/126#discussion_r876939966


##########
flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/FileStoreTableITCase.java:
##########
@@ -58,4 +63,18 @@ private void prepareEnv(TableEnvironment env, String path) {
     }
 
     protected abstract List<String> ddl();
+
+    protected List<Row> sql(String query, Object... args) {
+        return sql(true, query, args);
+    }
+
+    protected List<Row> sql(boolean batch, String query, Object... args) {

Review Comment:
   `boolean batch`?
   I prefer to rename this method to `executeBatchSql`



##########
flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/TableStoreFactoryOptions.java:
##########
@@ -57,6 +59,27 @@ public class TableStoreFactoryOptions {
                     .noDefaultValue()
                     .withDescription("The log system used to keep changes of 
the table.");
 
+    public static final ConfigOption<WriteMode> WRITE_MODE =
+            ConfigOptions.key("write-mode")
+                    .enumType(WriteMode.class)
+                    .defaultValue(WriteMode.CHANGE_LOG)
+                    .withDescription(
+                            Description.builder()
+                                    .text("Specify the write mode for table.")
+                                    .linebreak()
+                                    .text(
+                                            String.format(
+                                                    "%s: %s",
+                                                    WriteMode.APPEND_ONLY,

Review Comment:
   Can you just use `DescribedEnum` just like `LogOptions.LogStartupMode`?



##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/operation/FileStoreReadImpl.java:
##########
@@ -83,6 +89,34 @@ public FileStoreRead withValueProjection(int[][] 
projectedFields) {
     @Override
     public RecordReader createReader(BinaryRowData partition, int bucket, 
List<DataFileMeta> files)
             throws IOException {
+        switch (writeMode) {
+            case APPEND_ONLY:
+                return createAppendOnlyReader(partition, bucket, files);
+
+            case CHANGE_LOG:
+                return createLSMReader(partition, bucket, files);

Review Comment:
   NIT: `createMergeTreeReader`



##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/operation/FileStoreReadImpl.java:
##########
@@ -83,6 +89,34 @@ public FileStoreRead withValueProjection(int[][] 
projectedFields) {
     @Override
     public RecordReader createReader(BinaryRowData partition, int bucket, 
List<DataFileMeta> files)
             throws IOException {
+        switch (writeMode) {
+            case APPEND_ONLY:
+                return createAppendOnlyReader(partition, bucket, files);
+
+            case CHANGE_LOG:
+                return createLSMReader(partition, bucket, files);
+
+            default:
+                throw new UnsupportedOperationException("Unknown write mode: " 
+ writeMode);
+        }
+    }
+
+    private RecordReader createAppendOnlyReader(
+            BinaryRowData partition, int bucket, List<DataFileMeta> files) 
throws IOException {
+        Preconditions.checkArgument(

Review Comment:
   We can assert in `withDropDelete`.



##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/FileStoreImpl.java:
##########
@@ -179,6 +184,25 @@ public RowType partitionType() {
         return partitionType;
     }
 
+    public static FileStoreImpl createWithAppendOnly(
+            String tablePath,
+            long schemaId,
+            FileStoreOptions options,
+            String user,
+            RowType partitionType,
+            RowType rowType) {
+        return new FileStoreImpl(
+                tablePath,
+                schemaId,
+                options,
+                WriteMode.APPEND_ONLY,
+                user,
+                partitionType,
+                RowType.of(),
+                rowType,
+                null);

Review Comment:
   Add nullable annotation to all `MergeFunction`s.



##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/WriteMode.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.flink.table.store.file;
+
+/** Defines the write mode for flink table store. */
+public enum WriteMode {
+    APPEND_ONLY(
+            "append-only",
+            "The table can only accept append-only insert operations. All rows 
will be "
+                    + "inserted into the table store without any deduplication 
or primary/unique key constraint."),

Review Comment:
   here is `or` or `and`?



##########
flink-table-store-connector/src/test/java/org/apache/flink/table/store/connector/source/TestDataReadWrite.java:
##########
@@ -48,7 +49,6 @@
 
 /** Util class to read and write data for source tests. */
 public class TestDataReadWrite {
-

Review Comment:
   Revert this, left an empty line is a habit of flink.



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

Reply via email to