Hei, I am trying to create a table from connector ...
# troubleshooting
o
Hei, I am trying to create a table from connector kafka like this:
Copy code
CREATE TEMPORARY TABLE IF NOT EXISTS devices
(
    deviceId STRING PRIMARY KEY NOT ENFORCED,
    userId STRING,
    status STRING,
    pairedOn TIMESTAMP,
    eventTime TIMESTAMP
 )WITH (
      'connector' = 'kafka',
      'topic' = 'devices',
      'format' = 'json',
      'properties.bootstrap.servers' = 'kafka-rt:9093',
      'properties.group.id' = 'ethanol-test',
      'scan.startup.mode' = 'earliest-offset'
      );
but when running the select query I get the following error: org.apache.flink.table.api.ValidationException: The Kafka table 'default_catalog.default_database.devices' with 'json' format doesn't support defining PRIMARY KEY constraint on the table, because it can't guarantee the semantic of primary key.
m
That's an error on a different table definition
payments
in your DDL,
devices
in your error message
o
ah yes, I copied a different table definition my bad but the error still stands
m
Are you sure? Because this definition doesn't have a PRIMARY KEY defined in it?
o
this is the table definition for devices
Copy code
CREATE TEMPORARY TABLE IF NOT EXISTS devices
(
    deviceId STRING PRIMARY KEY NOT ENFORCED,
    userId STRING,
    status STRING,
    pairedOn TIMESTAMP,
    eventTime TIMESTAMP
 )WITH (
      'connector' = 'kafka',
      'topic' = 'devices',
      'format' = 'json',
      'properties.bootstrap.servers' = 'kafka-rt:9093',
      'properties.group.id' = 'ethanol-test',
      'scan.startup.mode' = 'earliest-offset'
      );
now you can see πŸ™‚
m
Ah
You are defining a primary key
but you can't do that in the combination of Kafka and JSON as format
o
oh really!
I saw some posts where they do that
m
Primary key is only possible with upsert-kafka
o
ok
thanks, that did the trick πŸ™‚
πŸ‘ 1