Oracle GoldenGate (a.k.a ogg) is a comprehensive software package for real-time data capture and replication in heterogeneous IT environments. The product set enables high availability solutions, real-time data integration, transactional change data capture, data replication, transformations, and verification between operational and analytical enterprise systems. Ogg provides a format schema for changelog and supports to serialize messages using JSON.
Flink supports to interpret Ogg JSON as INSERT/UPDATE/DELETE messages into Flink SQL system. This is useful in many cases to leverage this feature, such as:
Flink also supports to encode the INSERT/UPDATE/DELETE messages in Flink SQL as Ogg JSON, and emit to external systems like Kafka. However, currently Flink cannot combine UPDATE_BEFORE and UPDATE_AFTER into a single UPDATE message. Therefore, Flink encodes UPDATE_BEFORE and UPDATE_AFTER as DELETE and INSERT Ogg messages.
Parameter |
Mandatory |
Default Value |
Data Type |
Description |
|---|---|---|---|---|
format |
Yes |
(none) |
String |
Specify what format to use, here should be ogg-json. |
ogg-json.ignore-parse-errors |
No |
false |
Boolean |
Whether fields and rows with parse errors will be skipped or failed. The default value is false, indicating that an error will be thrown. Fields are set to null in case of errors. |
debezium-json.timestamp-format.standard |
No |
'SQL' |
String |
Input and output timestamp formats. Currently supported values are SQL and ISO-8601:
|
ogg-json.map-null-key.mode |
No |
'FAIL' |
String |
Handling mode when serializing null keys for map data. Currently supported values are FAIL, DROP, and LITERAL:
|
ogg-json.map-null-key.literal |
No |
'null' |
String |
Specify string literal to replace null key when ogg-json.map-null-key.mode is LITERAL. |
Key |
Data Type |
Description |
|---|---|---|
table |
STRING NULL |
Contains fully qualified table name. The format of the fully qualified table name is CATALOG NAME.SCHEMA NAME.TABLE NAME. |
primary-keys |
ARRAY<STRING> NULL |
An array variable holding the column names of the primary keys of the source table. The primary-keys field is only included in the JSON output if the includePrimaryKeys configuration property is set to true. |
ingestion-timestamp |
TIMESTAMP_LTZ(6) NULL |
The timestamp at which the connector processed the event. Corresponds to the current_ts field in the Ogg record. |
event-timestamp |
TIMESTAMP_LTZ(6) NULL |
The timestamp at which the source system created the event. Corresponds to the op_ts field in the Ogg record. |
The following example shows how to access Canal metadata fields in Kafka:
CREATE TABLE KafkaTable ( origin_ts TIMESTAMP(3) METADATA FROM 'value.ingestion-timestamp' VIRTUAL, event_time TIMESTAMP(3) METADATA FROM 'value.event-timestamp' VIRTUAL, origin_table STRING METADATA FROM 'value.table' VIRTUAL, primary_keys ARRAY<STRING> METADATA FROM 'value.primary_keys' VIRTUAL, user_id BIGINT, item_id BIGINT, behavior STRING ) WITH ( 'connector' = 'kafka', 'topic' = 'kafkaTopic', 'properties.bootstrap.servers' = 'KafkaAddress1:KafkaPort,KafkaAddress2:KafkaPort', 'properties.group.id' = 'GroupId', 'scan.startup.mode' = 'earliest-offset', 'value.format' = 'ogg-json' );
Use ogg-json to read Ogg records in Kafka and output them to Print.
CREATE TABLE kafkaSource ( id bigint, name string, description string, weight DECIMAL(10, 2) ) WITH ( 'connector' = 'kafka', 'topic' = 'kafkaTopic', 'properties.bootstrap.servers' = 'KafkaAddress1:KafkaPort,KafkaAddress2:KafkaPort', 'properties.group.id' = 'GroupId', 'scan.startup.mode' = 'latest-offset', 'format' = 'ogg-json' ); CREATE TABLE printSink ( id bigint, name string, description string, weight DECIMAL(10, 2) ) WITH ( 'connector' = 'print' ); insert into printSink select * from kafkaSource;
{
"before": {
"id": 111,
"name": "scooter",
"description": "Big 2-wheel scooter",
"weight": 5.18
},
"after": {
"id": 111,
"name": "scooter",
"description": "Big 2-wheel scooter",
"weight": 5.15
},
"op_type": "U",
"op_ts": "2020-05-13 15:40:06.000000",
"current_ts": "2020-05-13 15:40:07.000000",
"primary_keys": [
"id"
],
"pos": "00000000000000000000143",
"table": "PRODUCTS"
}
-U[111, scooter, Big 2-wheel scooter, 5.18] +U[111, scooter, Big 2-wheel scooter, 5.15]