mansipp opened a new issue, #14107:
URL: https://github.com/apache/hudi/issues/14107
### Bug Description
**What happened:**
When using Hudi with Spark SQL (with Glue) and performing a CREATE TABLE ...
LIKE ... operation, the command fails with the error for COW and MOR:
```
spark-sql (mansipp_demo_db)> create table hudi_demo_table_like2 like
hudi_demo_table using hudi;
Creating ro/rt table need the existence of the base table.
```
Hudi’s CREATE TABLE LIKE implementation includes a check on the
configuration property `hoodie.query.as.ro.table`
- If `hoodie.query.as.ro.table` is empty, Hudi allows the CREATE TABLE LIKE
operation to create a table.
- If `hoodie.query.as.ro.table` is non-empty, the operation fails, expecting
the base table to exist.
- Although this property is intended for MOR tables to indicate
read-optimized behavior, it is also populated for COW tables in Glue (set to
false) and for MOR tables (set to true or false). Since the check only verifies
whether the property is empty, a non-empty value, regardless of table type or
relevance to RO/RT causes the operation to fail, preventing valid CREATE TABLE
LIKE operations for both COW and MOR tables.
```
val queryAsProp =
hoodieCatalogTable.catalogProperties.get(ConfigUtils.IS_QUERY_AS_RO_TABLE)
if (queryAsProp.isEmpty) {
// init hoodie table for a normal table (not a ro/rt table)
hoodieCatalogTable.initHoodieTable()
} else {
if (!hoodieCatalogTable.hoodieTableExists) {
throw new HoodieAnalysisException("Creating ro/rt table need the
existence of the base table.")
}
if (HoodieTableType.MERGE_ON_READ != hoodieCatalogTable.tableType) {
throw new HoodieAnalysisException("Creating ro/rt table should only
apply to a mor table.")
}
}
```
- When a new Hudi table is created and data is inserted, Glue automatically
stores the `hoodie.query.as.ro.table `property in glue regardless of
tableType(COW/MOR).
- Since this property is now non-empty, any subsequent CREATE TABLE ... LIKE
... operation against this table will fail with the above error for COW and MOR.
**What you expected:**
- The CREATE TABLE LIKE operation should succeed for both COW and MOR tables.
**Steps to reproduce:**
1.
```
CREATE TABLE hudi_demo_table (
id STRING,
name STRING,
ts BIGINT,
dt STRING
)
USING hudi
OPTIONS (
type = 'cow',
primaryKey = 'id',
preCombineField = 'ts'
)
PARTITIONED BY (dt)
LOCATION 's3://<PATH>/hudi_demo_table';
```
2.
```
INSERT INTO hudi_demo_table VALUES
('1', 'Bob', 1739660000000, '2025-10-16'),
('2', 'Alice', 1739660100000, '2025-10-16');
```
3.
```
CREATE TABLE hudi_demo_table_like2 LIKE hudi_demo_table USING HUDI;
```
### Environment
**Hudi version:**
1.0.2
**Query engine:** (Spark/Flink/Trino etc)
Spark
**Relevant configs:**
### Logs and Stack Trace
```
spark-sql (mansipp_demo_db)> create table hudi_demo_table_like2 like
hudi_demo_table using hudi;
Creating ro/rt table need the existence of the base 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]