James Watkins
07/04/2023, 6:32 PMtableEnv.executeSql("INSERT INTO flink_catalogue.flink_demo.flink_iceberg_sink VALUES (1, 1, 'dummy_merchant1', 1, '2022-04-01 00:00:00'), (2, 2, 'dummy_merchant2', 2, '2022-04-02 00:00:00');")
but when I try and use the data stream from my Kafka source it’s not writing any data and there don’t seem to be any useful error messages in the stacktrace. Here is the INSERT INTO statement (note, flink_transaction is a kafka-backed Flink source table):
tableEnv.executeSql("""
INSERT INTO flink_catalogue.flink_demo.flink_iceberg_sink
SELECT
transaction_id
, transaction_amount
, merchant_name
, user_id
, created_at
FROM flink_transaction
""")
I also checked if the data stream is producing the data I need in the right format by removing the INSERT INTO statement and it did print the results that I was expecting.
Can anyone help me understand what I’m doing wrong here please? (I’ll add the full code in-thread)James Watkins
07/04/2023, 6:33 PMval env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment()
val tableEnv: StreamTableEnvironment = StreamTableEnvironment.create(env)
// register Flink source table
tableEnv.executeSql("""
CREATE TABLE flink_transaction (
transaction_id INT,
transaction_amount FLOAT,
merchant_name VARCHAR,
user_id INTEGER,
created_at VARCHAR
)
WITH (
'connector'= 'kafka',
'topic' = 'transaction',
'properties.bootstrap.servers' = 'localhost:29092',
'value.format' = 'avro-confluent',
'value.avro-confluent.url' = '<http://localhost:8083>',
'properties.group.id' = 'group-1',
'scan.startup.mode' = 'earliest-offset'
);
""")
// register Flink sink table
tableEnv.executeSql("""
CREATE TABLE flink_iceberg_sink (
transaction_id INT,
transaction_amount FLOAT,
merchant_name VARCHAR,
user_id INT,
created_at VARCHAR
)
WITH (
'connector' = 'iceberg',
'warehouse' = 's3://<s3_path>',
'catalog-impl' = 'org.apache.iceberg.aws.glue.GlueCatalog',
'lock-impl' = 'org.apache.iceberg.aws.glue.DynamoLockManager',
'lock.table' = 'FlinkGlue4IcebergLockTable'
);
""")
// create a Flink catalogue
tableEnv.executeSql(
"""
CREATE CATALOG flink_catalogue WITH (
'type'='iceberg',
'warehouse'='<s3_path>',
'catalog-impl'='org.apache.iceberg.aws.glue.GlueCatalog',
'io-impl'='org.apache.iceberg.aws.s3.S3FileIO',
'lock-impl'='org.apache.iceberg.aws.glue.DynamoLockManager',
'lock.table'='FlinkGlue4IcebergLockTable'
);
""")
tableEnv.executeSql("""
CREATE TABLE flink_catalogue.flink_demo.flink_iceberg_sink (
transaction_id INTEGER,
transaction_amount FLOAT,
merchant_name VARCHAR,
user_id INTEGER,
created_at VARCHAR
);
""")
tableEnv.executeSql("""
INSERT INTO flink_catalogue.flink_demo.flink_iceberg_sink
SELECT
transaction_id
, transaction_amount
, merchant_name
, user_id
, created_at
FROM flink_transaction
""")
The statements above are defined using KotlinMartijn Visser
07/04/2023, 6:44 PMJames Watkins
07/04/2023, 7:15 PMJames Watkins
07/04/2023, 7:34 PMMartijn Visser
07/04/2023, 8:16 PMMartijn Visser
07/04/2023, 8:17 PM