George Leonard
07/16/2024, 5:14 PMFlink SQL> CREATE TABLE unnested_salesxx (
> `store_id` STRING,
> `product` STRING,
> `brand` STRING,
> `saleValue` DOUBLE,
> `category` STRING,
> `saleDateTime_Ltz` STRING,
> `saleTimestamp_Epoc` STRING,
> `saleTimestamp_WM` AS TO_TIMESTAMP(FROM_UNIXTIME(CAST(`saleTimestamp_Epoc` AS BIGINT) / 1000)),
> WATERMARK FOR `saleTimestamp_WM` AS `saleTimestamp_WM`
> ) PARTITIONED BY (`store_id`)
> WITH (
> 'connector' = 'kafka',
> 'topic' = 'unnested_sales',
> 'properties.bootstrap.servers' = 'broker:29092',
> 'properties.group.id' = 'testGroup',
> 'scan.startup.mode' = 'earliest-offset',
> 'value.format' = 'avro-confluent',
> 'value.avro-confluent.url' = 'http://schema-registry:8081',
> 'value.fields-include' = 'ALL'
> );
[INFO] Execute statement succeed.
Insert
Flink SQL> insert into unnested_salesxx
> SELECT
> `store`.`id` as `store_id`,
> bi.`name` AS `product`,
> bi.`brand` AS `brand`,
> bi.`price` * bi.`quantity` AS `saleValue`,
> bi.`category` AS `category`,
> `saleDateTime_Ltz` as saleDateTime_Ltz,
> `saleTimestamp_Epoc` as saleTimestamp_Epoc
> FROM avro_salescompleted_x -- assuming avro_salescompleted_x is a table function
> CROSS JOIN UNNEST(`basketItems`) AS bi;
Error
[INFO] Submitting SQL update statement to the cluster...
[ERROR] Could not execute SQL statement. Reason:
org.apache.flink.table.api.TableException: Table 'default_catalog.default_database.unnested_salesxx' is a partitioned table, but the underlying DynamicTableSink doesn't implement the SupportsPartitioning interface.