Configuring FlinkServer to Interconnect with Paimon
Scenarios
This section describes how to use FlinkServer to develop Flink SQL statements for Paimon integration. Paimon tables can be a sink table, source table, or dimension table.
Prerequisites
- The HDFS, ZooKeeper, YARN, Flink, and Hive components have been installed in the cluster.
- You have created a user, for example, flink_admin and assigned the FlinkServer administrator permission to the user by referring to Creating a FlinkServer Role for accessing the Flink web UI.
- You have created a Paimon catalog (for example, paimon_catalog) by following the instructions in Managing FlinkServer Catalogs.
- Flink and Hive components can be deployed in the same cluster. Multiple Hive services are not supported.
Mapping Between Flink SQL and Paimon Data Types
| Flink SQL Data Type | Paimon Data Type |
|---|---|
| BOOLEAN | BOOLEAN |
| TINYINT | TINYINT |
| SMALLINT | SMALLINT |
| INTEGER | INTEGER |
| BIGINT | BIGINT |
| FLOAT | FLOAT |
| DOUBLE | DOUBLE |
| CHAR(n) | CHAR(n) |
| VARCHAR(n) | VARCHAR(n) |
| STRING | STRING |
| BINARY(n) | BINARY(n) |
| VARBINARY(n) | VARBINARY(n) |
| BYTES | BYTES |
| DECIMAL(p, s) | DECIMAL(p, s) |
| DATE | DATE |
| TIME(p) | TIME(p) |
| TIMESTAMP(p) | TIMESTAMP(p) |
| TIMESTAMP(p) WITH LOCAL TIME ZONE | TIMESTAMP WITH LOCAL TIME ZONE |
| ARRAY<t> | ARRAY<t> |
| MAP<kt, vt> | MAP<kt, vt> |
| MULTISET<t> | MULTISET<t> |
| ROW<n0 t0 'd0', n1 t1 'd1', ...> | ROW<n0 t0 'd0', n1 t1 'd1', ...> |
Paimon as a Sink Table
- Log in to MRS Manager as user flink_admin and choose Cluster > Services > Flink. On the displayed page, click the link next to Flink Web UI to access the Flink web UI.
- Create a Paimon table, for example, paimon_catalog.`default`.paimon_table. For details, see Managing FlinkServer Data. A complete example is as follows:
CREATE TABLE if not exists paimon_catalog.`default`.paimon_table ( user_id BIGINT, item_id BIGINT, behavior STRING, dt STRING, hh STRING, PRIMARY KEY (dt, hh, user_id) NOT ENFORCED );
- Create a streaming Flink SQL job by referring to Creating a Job. On the job development page, configure the job parameters as follows and start the job. Select Enable CheckPoint in the Basic Parameter tab and configure the checkpoint interval based on service requirements.
CREATE TABLE datagen ( user_id BIGINT, item_id BIGINT, behavior STRING, dt STRING, hh STRING ) with ('connector' = 'datagen', 'rows-per-second' = '5'); insert into paimon_catalog.`default`.paimon_table select * from datagen;
Paimon as a Source Table
- Log in to MRS Manager as user flink_admin and choose Cluster > Services > Flink. On the displayed page, click the link next to Flink Web UI to access the Flink web UI.
- Create a streaming Flink SQL job by referring to Creating a Job. On the job development page, configure the job parameters as follows and start the job.
CREATE TABLE print ( user_id BIGINT, item_id BIGINT, behavior STRING, dt STRING, hh STRING ) with ('connector' = 'print'); insert into print select * from paimon_catalog.`default`.paimon_table;
Paimon as a Dimension Table
- Log in to MRS Manager as user flink_admin and choose Cluster > Services > Flink. On the displayed page, click the link next to Flink Web UI to access the Flink web UI.
- Create a streaming Flink SQL job by referring to Creating a Job. On the job development page, configure the job parameters as follows and start the job.
CREATE TABLE datagen ( user_id BIGINT, item_id BIGINT, behavior STRING, dt STRING, hh STRING ) with ('connector' = 'datagen', 'rows-per-second' = '5'); CREATE TABLE print ( user_id BIGINT, item_id BIGINT, behavior STRING, dt STRING, hh STRING ) with ('connector' = 'print'); insert into print select o.user_id, c.item_id, c.behavior, c.dt, c.hh from datagen AS o left join paimon_catalog.`default`.paimon_table FOR SYSTEM_TIME AS OF PROCTIME() AS c ON o.user_id = c.user_id;
Flink Paimon Connector Configuration Options
| Configuration Key | Default Value | Type | Description |
|---|---|---|---|
| changelog.precommit-compact.thread-num | (None) | Integer | Maximum number of threads to copy bytes from small changelog files. The default value is the number of processors available to the Java virtual machine. |
| end-input.watermark | (None) | Long | Optional endInput watermark used in case of batch mode or bounded stream. |
| lookup.async | false | Boolean | Whether to enable asynchronous lookup join. |
| lookup.async-thread-number | 16 | Integer | The number of threads for asynchronous lookup. |
| lookup.bootstrap-parallelism | 4 | Integer | Parallelism for bootstrap in a single task for lookup join. |
| lookup.cache | AUTO | Enum | Cache mode of lookup join. Possible values: "AUTO", "FULL", and "MEMORY" |
| lookup.dynamic-partition.refresh-interval | 1 h | Duration | Specific dynamic partition refresh interval for lookup. The system scans all partitions and obtains the corresponding partition. |
| lookup.refresh.async | false | Boolean | Whether to refresh lookup table in an asynchronous thread. |
| lookup.refresh.async.pending-snapshot-count | 5 | Integer | If the pending snapshot count exceeds the threshold, lookup operator will refresh the table synchronously. |
| lookup.refresh.time-periods-blacklist | (None) | String | The blacklist contains several time periods. During these time periods, the lookup table's cache refreshing is forbidden. Blacklist format is start1->end1,start2->end2... , and the time format is yyyy-MM-dd HH:mm. This option is used only when lookup table is in FULL cache mode. |
| partition.idle-time-to-done | (None) | Duration | Set a duration so that when a partition receives no new data for that period, it is marked as 'done' to indicate that the data is ready. |
| partition.mark-done-action.mode | process-time | Enum | How to trigger partition mark done action. Possible values: process-time: Based on the machine's local time. The partition is marked "done" once the processing time exceeds the sum of the partition period and the configured delay. watermark: Based on the input data's watermark. The partition is marked "done" once the watermark exceeds the sum of the partition period and the configured delay. |
| partition.mark-done.recover-from-state | true | Boolean | Whether to trigger a partition 'done' mark during recovery from a state. |
| partition.time-interval | (None) | Duration | Time interval for partitions, for example, daily partition is '1 d', hourly partition is '1 h'. |
| postpone.default-bucket-num | 1 | Integer | Number of buckets for the partitions compacted for the first time in postpone bucket tables. |
| precommit-compact | false | Boolean | If this option is set to true, a compact coordinator and worker operator are added after the writer operator. These operators consolidate multiple changelog files (for primary key tables) or new data files (for unaware-bucket tables) within the same partition into larger files, reducing the overall small-file count. |
| read.shuffle-bucket-with-partition | true | Boolean | Whether to shuffle data by partition and bucket during the read operation. |
| scan.bounded | (None) | Boolean | Bounded mode for Paimon consumer. By default, Paimon automatically selects the bounded mode based on the mode of the Flink job. |
| scan.dedicated-split-generation | false | Boolean | If this option is set to true, the split generation process is performed during runtime on a Flink task, rather than on the JobManager during the initialization phase. |
| scan.infer-parallelism | true | Boolean | If this option is set to false, parallelism of source are set by the global parallelism. Otherwise, source parallelism is inferred from the number of splits (batch mode) or the number of buckets (streaming mode). |
| scan.infer-parallelism.max | 1024 | Integer | If scan.infer-parallelism is true, use this option to limit the parallelism of source. |
| scan.max-snapshot.count | -1 | Integer | Maximum number of snapshots to scan during each checkpoint. When this option is set to a negative value, no limit is applied. |
| scan.parallelism | (None) | Integer | Custom parallelism for the scan source. By default, if this option is not defined, the planner will derive the parallelism for each statement individually by also considering the global configuration. If you enable scan.infer-parallelism, the planner will derive the parallelism by inferred parallelism. |
| scan.partitions | (None) | String | Partitions to scan. Partitions should be given in the form of key1=value1,key2=value2. Partition keys not specified will be filled with the value of partition.default-name. Multiple partitions should be separated by semicolon (;). This option can support normal source tables and lookup join tables. For lookup joins, two special values max_pt() and max_two_pt() are also supported to specify the (two) partitions with the largest partition value. |
| scan.remove-normalize | false | Boolean | Whether to force the removal of the normalize node during the streaming read operation. Note: This is a high-risk operation. If the downstream system performs aggregations and the input is not a complete changelog, data errors are likely to occur. |
| scan.split-enumerator.batch-size | 10 | Integer | Number of splits assigned to subtasks per batch in StaticFileStoreSplitEnumerator to avoid exceeding the akka.framesize limit. |
| scan.split-enumerator.mode | fair | Enum | Mode used by StaticFileStoreSplitEnumerator to assign splits. Possible values: fair: The system distributes splits evenly during batch reading to prevent a few tasks from reading all. preemptive: The system distributes splits preemptively according to the consumption speed of the task. |
| scan.watermark.alignment.group | (None) | String | A group of sources to align watermarks. |
| scan.watermark.alignment.max-drift | (None) | Duration | Maximum allowable drift for watermark alignment before pausing consumption from the source, task, or partition. |
| scan.watermark.alignment.update-interval | 1 s | Duration | How often tasks should notify coordinator about the current watermark and how often the coordinator should announce the maximal aligned watermark. |
| scan.watermark.emit.strategy | on-event | Enum | Emit strategy for watermark generation. Possible values: on-periodic: The system emits watermarks periodically. The interval is controlled by Flink pipeline.auto-watermark-interval. on-event: The system emits watermarks for every record. |
| scan.watermark.idle-timeout | (None) | Duration | If no records flow in a partition of a stream for that amount of time, then that partition is considered 'idle' and will not hold back the progress of watermarks in downstream operators. |
| sink.clustering.by-columns | (None) | String | Column names used for comparison during range partitioning, in the format columnName1,columnName2. If this option is not set or set to an empty string, it indicates that the range partitioning feature is not enabled. This option will be effective only for bucket-unaware tables without primary keys and the batch execution mode. |
| sink.clustering.sample-factor | 100 | Integer | Sample factor. Let S represent the total number of samples, F represent the sample factor, and P represent the sink parallelism, then S=F×P. The minimum allowed sample factor is 20. |
| sink.clustering.sort-in-cluster | true | Boolean | Whether to further sort data belonged to each sink task after range partitioning. |
| sink.clustering.strategy | "auto" | String | Comparison algorithm used for range partitioning, including 'zorder', 'hilbert', and 'order', corresponding to the z-order curve algorithm, hilbert curve algorithm, and basic type comparison algorithm, respectively. When not configured, this option will automatically determine the algorithm based on the number of columns in sink.clustering.by-columns. order is used for one column, zorder for less than five columns, and hilbert for 5 or more columns. |
| sink.committer-cpu | 1.0 | Double | Sink committer CPU, which controls the number of CPU cores of the global committer. |
| sink.committer-memory | (None) | MemorySize | Sink committer memory, which controls heap memory of the global committer. |
| sink.committer-operator-chaining | true | Boolean | Whether to allow the sink committer and writer operator to be chained together. |
| sink.cross-partition.managed-memory | 256 mb | MemorySize | Weight of managed memory for RocksDB in cross-partition update. Flink will compute the memory size according to the weight. The actual memory used depends on the running environment. |
| sink.managed.writer-buffer-memory | 256 mb | MemorySize | Weight of writer buffer in managed memory. Flink will compute the memory size for the writer according to the weight. The actual memory used depends on the running environment. |
| sink.operator-uid.suffix | (None) | String | Set the UID suffix for the writer, dynamic bucket assigner and committer operators. The UID format is {UID_PREFIX}_ {TABLE_NAME}_ $ {USER_UID_SUFFIX}. If the UID suffix is not set, Flink will automatically generate the operator UID, which may be incompatible when the topology changes. |
| sink.parallelism | (None) | Integer | Custom parallelism for the sink. By default, if this option is not defined, the planner will derive the parallelism for each statement individually by also considering the global configuration. |
| sink.savepoint.auto-tag | false | Boolean | If this option is set to true, a tag will be automatically created for the snapshot created by the Flink savepoint. |
| sink.use-managed-memory-allocator | false | Boolean | If this option is set to true, the Flink sink will use managed memory for the merge tree. Otherwise, it will create an independent memory allocator. |
| sink.writer-cpu | 1.0 | Double | Sink writer CPU, which controls the number of CPU cores of the writer. |
| sink.writer-memory | (None) | MemorySize | Sink writer memory, which controls heap memory of the writer. |
| source.checkpoint-align.enabled | false | Boolean | Whether to align the Flink checkpoint with the snapshot of the Paimon table. If this option is set to true, a checkpoint will only be made if a snapshot is consumed. |
| source.checkpoint-align.timeout | 30 s | Duration | If the new snapshot has not been generated when the checkpoint starts to trigger, the enumerator will block the checkpoint and wait for the new snapshot. Set the maximum waiting time to avoid infinite waiting. If a timeout occurs, the checkpoint will fail. Note that it should be set to a value smaller than the checkpoint timeout. |
| source.operator-uid.suffix | (None) | String | UID suffix for the source operators. After this option is set, the UID format is {UID_PREFIX}_ {TABLE_NAME}_ $ {USER_UID_SUFFIX}. If the UID suffix is not set, Flink will automatically generate the operator UID, which may be incompatible when the topology changes. |
| unaware-bucket.compaction.parallelism | (None) | Integer | Custom parallelism for the unaware-bucket table compaction job. By default, if this option is not defined, the planner will derive the parallelism for each statement individually by also considering the global configuration. |
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot