```21:31:41,939 ERROR dev.kameshs.demos.flink.iceb...
# troubleshooting
k
Copy code
21:31:41,939 ERROR dev.kameshs.demos.flink.iceberg                              [] - Error running job
java.lang.IllegalArgumentException: table should be resolved
	at [org.apache.iceberg.relocated.com](http://org.apache.iceberg.relocated.com).google.common.base.Preconditions.checkArgument(Preconditions.java:143) ~[iceberg-flink-runtime-1.20-1.7.1.jar:?]
	at org.apache.iceberg.flink.FlinkCatalog.createTable(FlinkCatalog.java:394) ~[iceberg-flink-runtime-1.20-1.7.1.jar:?]
	at dev.kameshs.demos.flink.iceberg.VehicleTelemetryProcessor.lambda$main$0(VehicleTelemetryProcessor.java:167) ~[main/:?]
	at java.util.Optional.ifPresent(Optional.java:178) ~[?:?]
	at dev.kameshs.demos.flink.iceberg.VehicleTelemetryProcessor.main(VehicleTelemetryProcessor.java:106) [main/:?]
@Gunnar Morling - any clue ?
p
In almost every case, the “table should be resolved” error from
FlinkCatalog.createTable()
means that the table identifier you are passing is either invalid, incomplete, or the catalog can’t figure out where the table is supposed to live. Most commonly, it’s because: 1. The database (namespace) is empty or invalid, e.g., an empty
catalogNamespace
. 2. The table name is empty or null, e.g., a missing
catalogTable
. 3. A required configuration (e.g., warehouse) or property is not present, causing Iceberg to fail resolving the path. I'd add a log every time you do
dotenv.get
(for both catalog namespace and catalog table) and make sure those configs are coming properly and not null/empty.
👀 1
k
thanks @Pedro Mázala, the table ID you mean the one I used to create with ObjectPath("db","table") right?
p
Yes
k
I see 1,2 is present but then I am trying to set the warehouse to
minio
s3 bucket I am using Nessie locally
but when I debug the code the catalog.createTable goes to FlinkCatalog
Copy code
public void createTable(ObjectPath tablePath, CatalogBaseTable table, boolean ignoreIfExists) throws CatalogException, TableAlreadyExistException {
        if (Objects.equals(table.getOptions().get("connector"), "iceberg")) {
            throw new IllegalArgumentException("Cannot create the table with 'connector'='iceberg' table property in an iceberg catalog, Please create table with 'connector'='iceberg' property in a non-iceberg catalog or create table without 'connector'='iceberg' related properties in an iceberg table.");
        } else {
            Preconditions.checkArgument(table instanceof ResolvedCatalogTable, "table should be resolved");
            this.createIcebergTable(tablePath, (ResolvedCatalogTable)table, ignoreIfExists);
        }
    }
where its trying to see if the table is instance of
ResolvedTable
does that mean its expected a ResolvedCatalog table to be passed to createTable?
e.g.
ResolvedCatalogTable resolvedCatalogTable = new ResolvedCatalogTable(leaderboardTable,ResolvedSchema.of(columns));
☝️ 1
p
the key is that Iceberg’s
FlinkCatalog
requires the incoming
CatalogBaseTable
to be an instance of
ResolvedCatalogTable
before it will create an Iceberg table. In your code, you’re currently constructing and passing a plain
CatalogTable
You could either change it to a DDL or wrap your catalog into a
ResolvedCatalogTable
Copy code
import org.apache.flink.table.catalog.ResolvedCatalogTable;
import org.apache.flink.table.catalog.ResolvedSchema;

CatalogTable sinkTable = CatalogTable.newBuilder()
    .schema(sinkSchema) // (an org.apache.flink.table.api.Schema)
    .options(properties)
    .build();

ResolvedSchema resolvedSchema = ResolvedSchema.physical(
    sinkSchema.getColumns(), 
    sinkSchema.getWatermarkSpecs(), 
    sinkSchema.getPrimaryKey().orElse(null)
);

ResolvedCatalogTable resolvedTable = new ResolvedCatalogTable(sinkTable, resolvedSchema);

catalog.createTable(sinkPath, resolvedTable, false);
I did not test the code. I think this may be the issue tho
k
yeah the moment I changed to the ResolvedCatalogTable it did work
🙌 1
and I was actually struggling to created a resolvedSchema until I saw through the API
thanks @Pedro Mázala
one more quick Q - in my case
sinkSchema.getColumns()
gets me the list of UnresolvedColumn but physical expects
Column
, is it safe to cast ?
just for simplicity my sinkSchema looks like
Copy code
final Schema sinkSchema =
      Schema.newBuilder()
        .column("player", DataTypes.STRING())
        .column("balloon_color", DataTypes.STRING())
        .column("score", DataTypes.BIGINT())
        .column("favorite_color_bonus", DataTypes.BOOLEAN())
        .column("timestamp", DataTypes.TIMESTAMP_LTZ(3))
        .build();
I did the other way like
Copy code
final ResolvedSchema leaderboardSchema =
      ResolvedSchema.of(
        Column.physical("player", DataTypes.STRING()),
        Column.physical("balloon_color", DataTypes.STRING()),
        Column.physical("score", DataTypes.STRING()),
        Column.physical("favorite_color_bonus", DataTypes.STRING()),
        Column.physical("timestamp", DataTypes.STRING()));
and where I was in need of Schema I did
Copy code
Schema.newBuilder().fromResolvedSchema(leaderboardSchema).build()
this seem to better as I dont need to build columns and resolvedSchema everytime
thoughts/recommended?
p
No recommendations here. I think if you change to ddl this would be sorted as well. Is it working as expected?
🙌 1
k
yes it does
actually I see Iceberf tables created but metadata is not getting updated just data files are written
debugging that now - on that context if you are aware any clue on how to send headers with Flink Iceberg connector?
p
Not really. I think this may be something more specific
k
no worries thank you.