JingsongLi commented on code in PR #1838:
URL: https://github.com/apache/incubator-paimon/pull/1838#discussion_r1299529337
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlSyncDatabaseActionFactory.java:
##########
@@ -81,7 +86,8 @@ public void printHelp() {
+ "[--table-suffix <paimon-table-suffix>] "
+ "[--including-tables
<mysql-table-name|name-regular-expr>] "
+ "[--excluding-tables
<mysql-table-name|name-regular-expr>] "
- + "[--mode <sync-mode>] "
+ + "[--sink-mode <sink-mode>] "
+ + "[--data-type-map-mode <map-mode>] "
Review Comment:
modify
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlSyncTableActionFactory.java:
##########
@@ -80,6 +86,7 @@ public void printHelp() {
+ "--table <table-name> "
+ "[--partition-keys <partition-keys>] "
+ "[--primary-keys <primary-keys>] "
+ + "[--data-type-map-mode] <map-mode> "
Review Comment:
modify
##########
docs/content/how-to/cdc-ingestion.md:
##########
@@ -64,6 +64,7 @@ To use this feature through `flink run`, run the following
shell command.
--table <table-name> \
[--partition-keys <partition-keys>] \
[--primary-keys <primary-keys>] \
+ [--data-type-options <option1,optionw2...>] \
Review Comment:
optionw2?
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/cdc/DataTypeOptions.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.flink.action.cdc;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static
org.apache.paimon.flink.action.cdc.DataTypeOptions.DataTypeMapMode.ALL_TO_STRING;
+import static
org.apache.paimon.flink.action.cdc.DataTypeOptions.DataTypeMapMode.IDENTITY;
+import static org.apache.paimon.utils.Preconditions.checkArgument;
+
+/** Utility that holds data type conversion options. */
+public class DataTypeOptions implements Serializable {
Review Comment:
Modify class name.
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/cdc/DataTypeOptions.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.flink.action.cdc;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static
org.apache.paimon.flink.action.cdc.DataTypeOptions.DataTypeMapMode.ALL_TO_STRING;
+import static
org.apache.paimon.flink.action.cdc.DataTypeOptions.DataTypeMapMode.IDENTITY;
+import static org.apache.paimon.utils.Preconditions.checkArgument;
+
+/** Utility that holds data type conversion options. */
+public class DataTypeOptions implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private final DataTypeMapMode dataTypeMapMode;
+ private final boolean tinyint1NotBool;
+ private final boolean ignoreNotNull;
+
+ public DataTypeOptions(
+ DataTypeMapMode dataTypeMapMode, boolean tinyint1NotBool, boolean
ignoreNotNull) {
Review Comment:
only one `List<TypeMappingMode>`?
##########
docs/layouts/shortcodes/generated/mysql_sync_database.html:
##########
@@ -58,8 +58,23 @@
<td>It is used to specify which source tables are not to be
synchronized. The usage is same as "--including-tables". "--excluding-tables"
has higher priority than "--including-tables" if you specified both.</td>
</tr>
<tr>
- <td><h5>--mode</h5></td>
- <td>It is used to specify synchronization mode.<br />Possible
values:<ul><li>"divided" (the default mode if you haven't specified one): start
a sink for each table, the synchronization of the new table requires restarting
the job.</li><li>"combined": start a single combined sink for all tables, the
new table will be automatically synchronized.</li></ul></td>
+ <td><h5>--sink-mode</h5></td>
+ <td>It is used to specify sink mode.<br />Possible
values:<ul><li>"divided" (the default mode if you haven't specified one): start
a sink for each table, the synchronization of the new table requires restarting
the job.</li><li>"combined": start a single combined sink for all tables, the
new table will be automatically synchronized.</li></ul></td>
+ </tr>
+ <tr>
+ <td><h5>--data-type-options</h5></td>
+ <td>It is used to specify how to map MySQL data type to Paimon
type.<br />
+ Supported options:
+ <ul>
+ <li>"tinyint1-not-bool": MySQL TINYINT(1) will be
considered as Paimon TINYINT instead of BOOLEAN.</li>
+ <li>"ignore-not-null": all NOT NULL constraints (except
primary keys) will be ignored.
+ This is used to solve the problem that Flink cannot
accept the MySQL 'ALTER TABLE ADD COLUMN column NOT NULL DEFAULT x' operation.
+ </li>
+ <li>"identity": data type map mode that keeps the original
data types (default mode).</li>
Review Comment:
identity? remove this.
##########
docs/layouts/shortcodes/generated/mysql_sync_database.html:
##########
@@ -58,8 +58,23 @@
<td>It is used to specify which source tables are not to be
synchronized. The usage is same as "--including-tables". "--excluding-tables"
has higher priority than "--including-tables" if you specified both.</td>
</tr>
<tr>
- <td><h5>--mode</h5></td>
- <td>It is used to specify synchronization mode.<br />Possible
values:<ul><li>"divided" (the default mode if you haven't specified one): start
a sink for each table, the synchronization of the new table requires restarting
the job.</li><li>"combined": start a single combined sink for all tables, the
new table will be automatically synchronized.</li></ul></td>
+ <td><h5>--sink-mode</h5></td>
+ <td>It is used to specify sink mode.<br />Possible
values:<ul><li>"divided" (the default mode if you haven't specified one): start
a sink for each table, the synchronization of the new table requires restarting
the job.</li><li>"combined": start a single combined sink for all tables, the
new table will be automatically synchronized.</li></ul></td>
+ </tr>
+ <tr>
+ <td><h5>--data-type-options</h5></td>
+ <td>It is used to specify how to map MySQL data type to Paimon
type.<br />
+ Supported options:
+ <ul>
+ <li>"tinyint1-not-bool": MySQL TINYINT(1) will be
considered as Paimon TINYINT instead of BOOLEAN.</li>
+ <li>"ignore-not-null": all NOT NULL constraints (except
primary keys) will be ignored.
Review Comment:
to-nullable
##########
docs/layouts/shortcodes/generated/mysql_sync_database.html:
##########
@@ -58,8 +58,23 @@
<td>It is used to specify which source tables are not to be
synchronized. The usage is same as "--including-tables". "--excluding-tables"
has higher priority than "--including-tables" if you specified both.</td>
</tr>
<tr>
- <td><h5>--mode</h5></td>
- <td>It is used to specify synchronization mode.<br />Possible
values:<ul><li>"divided" (the default mode if you haven't specified one): start
a sink for each table, the synchronization of the new table requires restarting
the job.</li><li>"combined": start a single combined sink for all tables, the
new table will be automatically synchronized.</li></ul></td>
+ <td><h5>--sink-mode</h5></td>
+ <td>It is used to specify sink mode.<br />Possible
values:<ul><li>"divided" (the default mode if you haven't specified one): start
a sink for each table, the synchronization of the new table requires restarting
the job.</li><li>"combined": start a single combined sink for all tables, the
new table will be automatically synchronized.</li></ul></td>
+ </tr>
+ <tr>
+ <td><h5>--data-type-options</h5></td>
Review Comment:
type-mapping
##########
docs/content/how-to/cdc-ingestion.md:
##########
@@ -147,7 +148,8 @@ To use this feature through `flink run`, run the following
shell command.
[--table-suffix <paimon-table-suffix>] \
[--including-tables <mysql-table-name|name-regular-expr>] \
[--excluding-tables <mysql-table-name|name-regular-expr>] \
- [--mode <sync-mode>] \
+ [--sink-mode <sink-mode>] \
+ [--data-type-options <option1,optionw2...>] \
Review Comment:
optionw2
##########
paimon-common/src/main/java/org/apache/paimon/utils/DateTimeUtils.java:
##########
@@ -154,7 +154,7 @@ public static String formatLocalDateTime(LocalDateTime
localDateTime, int precis
String nano = fraction.substring(0, precision);
if (nano.length() > 0) {
- ymdhms.append(".").append(fraction);
+ ymdhms.append(".").append(nano);
Review Comment:
add ut case for `formatLocalDateTime`.
##########
docs/layouts/shortcodes/generated/mysql_sync_database.html:
##########
@@ -58,8 +58,23 @@
<td>It is used to specify which source tables are not to be
synchronized. The usage is same as "--including-tables". "--excluding-tables"
has higher priority than "--including-tables" if you specified both.</td>
</tr>
<tr>
- <td><h5>--mode</h5></td>
- <td>It is used to specify synchronization mode.<br />Possible
values:<ul><li>"divided" (the default mode if you haven't specified one): start
a sink for each table, the synchronization of the new table requires restarting
the job.</li><li>"combined": start a single combined sink for all tables, the
new table will be automatically synchronized.</li></ul></td>
+ <td><h5>--sink-mode</h5></td>
+ <td>It is used to specify sink mode.<br />Possible
values:<ul><li>"divided" (the default mode if you haven't specified one): start
a sink for each table, the synchronization of the new table requires restarting
the job.</li><li>"combined": start a single combined sink for all tables, the
new table will be automatically synchronized.</li></ul></td>
+ </tr>
+ <tr>
+ <td><h5>--data-type-options</h5></td>
+ <td>It is used to specify how to map MySQL data type to Paimon
type.<br />
+ Supported options:
+ <ul>
+ <li>"tinyint1-not-bool": MySQL TINYINT(1) will be
considered as Paimon TINYINT instead of BOOLEAN.</li>
+ <li>"ignore-not-null": all NOT NULL constraints (except
primary keys) will be ignored.
+ This is used to solve the problem that Flink cannot
accept the MySQL 'ALTER TABLE ADD COLUMN column NOT NULL DEFAULT x' operation.
+ </li>
+ <li>"identity": data type map mode that keeps the original
data types (default mode).</li>
+ <li>"all-to-string": data type map mode that maps all
MySQL data types to STRING.</li>
Review Comment:
to-string
##########
docs/content/how-to/cdc-ingestion.md:
##########
@@ -147,7 +148,8 @@ To use this feature through `flink run`, run the following
shell command.
[--table-suffix <paimon-table-suffix>] \
[--including-tables <mysql-table-name|name-regular-expr>] \
[--excluding-tables <mysql-table-name|name-regular-expr>] \
- [--mode <sync-mode>] \
Review Comment:
revert this.
--
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]