When I was create table via Table API, my code looks like this:
Schema.Builder schemaBuilder = Schema.newBuilder();
schemaBuilder.column("id", DataTypes.BIGINT())
.column("value", DataTypes.STRING())
.primaryKey("id");
then I get an exception like this:
Exception in thread "main" org.apache.flink.table.api.ValidationException: Invalid primary key 'PK_id'. Column 'id' is nullable.
Yes, I know primary key can not be null, but how to set it? I have no idea right now.
Thank you guys.
I have to find document on Flink official website, but no result.
This should do the trick:
Schema.Builder schemaBuilder = Schema.newBuilder();
schemaBuilder.column("id", DataTypes.BIGINT().notNull())
.column("value", DataTypes.STRING())
.primaryKey("id");