GitHub user younghwan91 added a comment to the discussion: Can't write hudi 
format in catalog

The cause is the source table, not the sink. `HoodieCatalog` creates every 
table you define in it as a Hudi table: in `createTable` it rewrites the 
options and forces `connector = hudi` 
([`applyOptionsHook`](https://github.com/apache/hudi/blob/343402d4115e1878b5b2b6a8583ab50ba53b5c6a/hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/catalog/HoodieCatalog.java#L614-L620),
 called from 
[`createTable`](https://github.com/apache/hudi/blob/343402d4115e1878b5b2b6a8583ab50ba53b5c6a/hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/catalog/HoodieCatalog.java#L314);
 0.15.x and 1.0.x do the same). So `hudi_catalog.hudi_db.orders_datagen` is not 
a datagen table. It's an empty Hudi COW table under 
`hdfs://namenode:8020/hudi_catalog/hudi_db/orders_datagen`. The `INSERT ... 
SELECT` reads that empty table as a bounded source, so the job finishes right 
away with no errors and no parquet files. That's also why the same code works 
without the catalog.

Keep the Hudi sink in the catalog, but define the datagen source outside it. A 
temporary table is the simplest option, because temporary tables live in the 
Flink session and never go through `HoodieCatalog.createTable`:

```python
t_env.execute_sql("USE CATALOG hudi_catalog")
t_env.execute_sql("DROP TABLE IF EXISTS hudi_db.orders_datagen")   # remove the 
empty Hudi table created earlier

t_env.execute_sql("""
    CREATE TEMPORARY TABLE orders_datagen (
        order_number BIGINT,
        price        DECIMAL(10,2)
    ) WITH (
        'connector' = 'datagen',
        'rows-per-second' = '10',
        'fields.order_number.kind' = 'sequence',
        'fields.order_number.start' = '1',
        'fields.order_number.end'   = '1000',
        'fields.price.min' = '20.00',
        'fields.price.max' = '1000.00'
    )
""")

# hudi_orders DDL unchanged
t_env.execute_sql("""
    INSERT INTO hudi_catalog.hudi_db.hudi_orders
    SELECT * FROM orders_datagen
""")
```

You can also create the source in `default_catalog.default_database` and select 
from `default_catalog.default_database.orders_datagen`. In short, only tables 
with `connector = hudi` belong in a Hudi catalog.

Keep checkpointing on as you have it. The Flink Hudi writer only commits data 
files on checkpoints.

If this solves it, please mark it as the answer so others with the same problem 
can find it.


GitHub link: 
https://github.com/apache/hudi/discussions/17992#discussioncomment-19895390

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to