Hi! I have a nested table declaration using the T...
# troubleshooting
a
Hi! I have a nested table declaration using the TableAPI and I'd like to use a nested field as a primary-key, when doing that I get an error of column not found.
Copy code
// Caused by: org.apache.flink.table.api.ValidationException: Invalid primary key
// 'PK_data.abc_event__id'. Column 'data.abc_event__id' does not
// exist.
The code snippet for the table declaration is the following:
Copy code
private static final DataType abcTransferOutRequestRow =
                DataTypes.ROW(
                        DataTypes.FIELD("abc_event__id", DataTypes.STRING()),
                        DataTypes.FIELD("abc_event__cancelled_at", DataTypes.TIMESTAMP_LTZ()),
                        DataTypes.FIELD("abc_event__created_at", DataTypes.TIMESTAMP_LTZ()),
                        DataTypes.FIELD("abc_event__e_2e_id", DataTypes.STRING()),
                        DataTypes.FIELD("abc_event__failed_at", DataTypes.TIMESTAMP_LTZ()),
                        DataTypes.FIELD("abc_event__initiation_type", DataTypes.STRING()),
                        DataTypes.FIELD("abc_event__message", DataTypes.STRING()),
                        DataTypes.FIELD("abc_event__transfer_in_id_to_refund", DataTypes.STRING()));

        public static final Schema schema =
                Schema.newBuilder()
                        .column("meta", EntitySnapshotPayload.metadataType)
                        .column("data", abcTransferOutRequestRow)
                        .primaryKey("data.abc_event__id")
                        .watermark("db__tx_instant", "db__tx_instant")
                        .build();
I tried to work around that by using a columnByExpression but I get an error related to the column not being physical. Any ideas for work arounds or is that just a limitation of the table api?
✅ 1
I fixed that by adding my nested column as a top level column as follows:
.column("data.abc_event__id", STRING().notNull()))