swapna267 commented on code in PR #12116:
URL: https://github.com/apache/iceberg/pull/12116#discussion_r1934430629
##########
flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java:
##########
@@ -384,13 +395,6 @@ public void renameTable(ObjectPath tablePath, String
newTableName, boolean ignor
@Override
public void createTable(ObjectPath tablePath, CatalogBaseTable table,
boolean ignoreIfExists)
throws CatalogException, TableAlreadyExistException {
- if (Objects.equals(
- table.getOptions().get("connector"),
FlinkDynamicTableFactory.FACTORY_IDENTIFIER)) {
- 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.");
- }
Review Comment:
Tables can be created using LIKE in
1. Flink Catalog - Not supported currently.
2. Another table in Iceberg catalog itself as detailed in
[doc](https://iceberg.apache.org/docs/nightly/flink-ddl/#create-table-like)
This check basically fails, if we try to create table using LIKE in Iceberg
catalog, basically case#2 if we have **connector=iceberg** in options . For
example, DDL like below,
```
CREATE TABLE `hive_catalog`.`default`.`sample_like`
LIKE `hive_catalog`.`default`.`sample`
WITH ('connector'='iceberg')
```
In order to support Case#1 without user setting any extra Options using WITH
clause, we need to add connector in getTable,
https://github.com/apache/iceberg/blob/52bfbdc0b03bafb610efde8486a6633be2b9cc4f/flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java#L344
This check was added in very old PR,
https://github.com/apache/iceberg/pull/2666
https://github.com/apache/iceberg/pull/2666#discussion_r660569612 where
Flink SQL didn't support CREATE TABLE A LIKE B , where A and B are in different
Catalogs.
So, in this case by removing this check, we are ignoring connector option
being passed, so following DDL can create table table_like in Flink catalog
backed by `iceberg_catalog.db.table`. As we know source table is an Iceberg
table, adding connector=iceberg would be redundant.
```
CREATE TABLE table_like (
eventTS AS CAST(t1 AS TIMESTAMP(3)),
) LIKE iceberg_catalog.db.table;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]