Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Added metadata_column parameter usage example in mysql cdc action #2480

Merged
merged 7 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/content/cdc-ingestion/mysql-cdc.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ To use this feature through `flink run`, run the following shell command.
[--primary_keys <primary-keys>] \
[--type_mapping <option1,option2...>] \
[--computed_column <'column-name=expr-name(args[, ...])'> [--computed_column ...]] \
[--metadata_column <metadata-column>] \
[--metadata_columns <metadata-columns>] \
[--mysql_conf <mysql-cdc-source-conf> [--mysql_conf <mysql-cdc-source-conf> ...]] \
[--catalog_conf <paimon-catalog-conf> [--catalog_conf <paimon-catalog-conf> ...]] \
[--table_conf <paimon-table-sink-conf> [--table_conf <paimon-table-sink-conf> ...]]
Expand Down Expand Up @@ -135,7 +135,7 @@ To use this feature through `flink run`, run the following shell command.
[--including_tables <mysql-table-name|name-regular-expr>] \
[--excluding_tables <mysql-table-name|name-regular-expr>] \
[--mode <sync-mode>] \
[--metadata_column <metadata-column>] \
[--metadata_columns <metadata-columns>] \
[--type_mapping <option1,option2...>] \
[--mysql_conf <mysql-cdc-source-conf> [--mysql_conf <mysql-cdc-source-conf> ...]] \
[--catalog_conf <paimon-catalog-conf> [--catalog_conf <paimon-catalog-conf> ...]] \
Expand Down
4 changes: 2 additions & 2 deletions docs/layouts/shortcodes/generated/mysql_sync_database.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
<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>
</tr>
<tr>
<td><h5>--metadata_column</h5></td>
<td>--metadata_column is used to specify which metadata columns to include in the output schema of the connector. Metadata columns provide additional information related to the source data, such as the `table_name`, `database_name`, and `op_ts`. Each configuration should be specified in the format "key=value". See its <a href="https://ververica.github.io/flink-cdc-connectors/master/content/connectors/mysql-cdc.html#available-metadata">document</a> for a complete list of available metadata.</td>
<td><h5>--metadata_columns</h5></td>
<td>--metadata_columns is used to specify which metadata columns to include in the output schema of the connector. Metadata columns provide additional information related to the source data, for example "table_name,database_name,op_ts". See its <a href="https://ververica.github.io/flink-cdc-connectors/master/content/connectors/mysql-cdc.html#available-metadata">document</a> for a complete list of available metadata.</td>
</tr>
<tr>
<td><h5>--type_mapping</h5></td>
Expand Down
4 changes: 2 additions & 2 deletions docs/layouts/shortcodes/generated/mysql_sync_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
<td>The definitions of computed columns. The argument field is from MySQL table field name. See <a href="../overview/#computed-functions">here</a> for a complete list of configurations. </td>
</tr>
<tr>
<td><h5>--metadata_column</h5></td>
<td>--metadata_column is used to specify which metadata columns to include in the output schema of the connector. Metadata columns provide additional information related to the source data, such as the `table_name`, `database_name`, and `op_ts`. Each configuration should be specified in the format "key=value". See its <a href="https://ververica.github.io/flink-cdc-connectors/master/content/connectors/mysql-cdc.html#available-metadata">document</a> for a complete list of available metadata.</td>
<td><h5>--metadata_columns</h5></td>
<td>--metadata_columns is used to specify which metadata columns to include in the output schema of the connector. Metadata columns provide additional information related to the source data, for example "table_name,database_name,op_ts". See its <a href="https://ververica.github.io/flink-cdc-connectors/master/content/connectors/mysql-cdc.html#available-metadata">document</a> for a complete list of available metadata.</td>
</tr>
<tr>
<td><h5>--mysql_conf</h5></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class CdcActionCommonUtils {
public static final String PARTITION_KEYS = "partition_keys";
public static final String PRIMARY_KEYS = "primary_keys";
public static final String COMPUTED_COLUMN = "computed_column";
public static final String METADATA_COLUMN = "metadata_column";
public static final String METADATA_COLUMNS = "metadata_columns";
zhuangchong marked this conversation as resolved.
Show resolved Hide resolved

public static void assertSchemaCompatible(
TableSchema paimonSchema, List<DataField> sourceTableFields) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.functions.source.SourceFunction;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -76,6 +77,10 @@ public SynchronizationActionBase withTypeMapping(TypeMapping typeMapping) {
return this;
}

public SynchronizationActionBase withMetadataColumns(String... metadataColumns) {
return withMetadataColumns(Arrays.asList(metadataColumns));
}

public SynchronizationActionBase withMetadataColumns(List<String> metadataColumns) {
this.metadataConverters =
metadataColumns.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
import org.apache.paimon.flink.action.MultipleParameterToolAdapter;
import org.apache.paimon.flink.action.cdc.TypeMapping;

import java.util.Arrays;
import java.util.Optional;

import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.EXCLUDING_TABLES;
import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.INCLUDING_TABLES;
import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.METADATA_COLUMN;
import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.METADATA_COLUMNS;
import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.MYSQL_CONF;
import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.TABLE_PREFIX;
import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.TABLE_SUFFIX;
Expand Down Expand Up @@ -69,8 +68,9 @@ public Optional<Action> create(MultipleParameterToolAdapter params) {
.includingTables(params.get(INCLUDING_TABLES))
.excludingTables(params.get(EXCLUDING_TABLES))
.withMode(MultiTablesSinkMode.fromString(params.get(MODE)));
if (params.has(METADATA_COLUMN)) {
action.withMetadataColumns(Arrays.asList(params.get(METADATA_COLUMN).split(",")));

if (params.has(METADATA_COLUMNS)) {
action.withMetadataColumns(params.get(METADATA_COLUMNS).split(","));
}

if (params.has(TYPE_MAPPING)) {
Expand Down Expand Up @@ -101,7 +101,7 @@ public void printHelp() {
+ "[--including_tables <mysql_table_name|name_regular_expr>] "
+ "[--excluding_tables <mysql_table_name|name_regular_expr>] "
+ "[--mode <sync_mode>] "
+ "[--metadata_column <metadata_column>] "
+ "[--metadata_columns <metadata_columns>] "
+ "[--type_mapping <option1,option2...>] "
+ "[--mysql_conf <mysql_cdc_source_conf> [--mysql_conf <mysql_cdc_source_conf> ...]] "
+ "[--catalog_conf <paimon_catalog_conf> [--catalog_conf <paimon_catalog_conf> ...]] "
Expand Down Expand Up @@ -147,7 +147,7 @@ public void printHelp() {
System.out.println();

System.out.println(
"--metadata_column is used to specify which metadata columns to include in the output schema of the connector. Please see the doc for usage.");
"--metadata_columns is used to specify which metadata columns to include in the output schema of the connector. Please see the doc for usage.");
System.out.println();

System.out.println(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.util.Optional;

import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.COMPUTED_COLUMN;
import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.METADATA_COLUMN;
import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.METADATA_COLUMNS;
import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.MYSQL_CONF;
import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.PARTITION_KEYS;
import static org.apache.paimon.flink.action.cdc.CdcActionCommonUtils.PRIMARY_KEYS;
Expand Down Expand Up @@ -73,8 +73,8 @@ public Optional<Action> create(MultipleParameterToolAdapter params) {
new ArrayList<>(params.getMultiParameter(COMPUTED_COLUMN)));
}

if (params.has(METADATA_COLUMN)) {
action.withMetadataColumns(new ArrayList<>(params.getMultiParameter(METADATA_COLUMN)));
if (params.has(METADATA_COLUMNS)) {
action.withMetadataColumns(params.get(METADATA_COLUMNS).split(","));
}

if (params.has(TYPE_MAPPING)) {
Expand All @@ -100,7 +100,7 @@ public void printHelp() {
+ "[--primary_keys <primary_keys>] "
+ "[--type_mapping <option1,option2...>] "
+ "[--computed_column <'column_name=expr_name(args[, ...])'> [--computed_column ...]] "
+ "[--metadata_column <metadata_column>] "
+ "[--metadata_columns <metadata_columns>] "
+ "[--mysql_conf <mysql_cdc_source_conf> [--mysql_conf <mysql_cdc_source_conf> ...]] "
+ "[--catalog_conf <paimon_catalog_conf> [--catalog_conf <paimon_catalog_conf> ...]] "
+ "[--table_conf <paimon_table_sink_conf> [--table_conf <paimon_table_sink_conf> ...]]");
Expand All @@ -126,7 +126,7 @@ public void printHelp() {
System.out.println();

System.out.println(
"--metadata_column is used to specify which metadata columns to include in the output schema of the connector. Please see the doc for usage.");
"--metadata_columns is used to specify which metadata columns to include in the output schema of the connector. Please see the doc for usage.");
System.out.println();

System.out.println("MySQL CDC source conf syntax:");
Expand Down
Loading