mansipp commented on issue #14107:
URL: https://github.com/apache/hudi/issues/14107#issuecomment-3583654221

   ### **Case 1: `CREATE -> CREATE LIKE`**
   
   * **Base table:** Exists ✅
   * **RO/RT tables:** Do not exist ❌
   
     * For MOR tables, only the base table is created initially, RO/RT tables 
are created on the first INSERT.
     * Since the source table has no RO/RT tables yet, we cannot test RO/RT 
behavior under this scenario.
   
   ---
   
   ### **Case 2 (Before modifying code): `CREATE -> INSERT -> CREATE LIKE (on 
base table)`**
   
   * **Base table:** Exists ✅
   
   * **RO/RT tables:** Exist after the first INSERT ✅
   
   * Not able to test this scenario due to the current property check on 
`hoodie.query.as.ro.table`.
     The code throws the exception:
     **"Creating ro/rt table need the existence of the base table."**
   
   * As a result, RO/RT table creation via `CREATE LIKE` is blocked before any 
code modifications.
   
   * **Code changes for testing:**
   
   * Even if we remove the check:
   
     ```scala
     if (!hoodieCatalogTable.hoodieTableExists) {
         throw new HoodieAnalysisException("Creating ro/rt table need the 
existence of the base table.")
     }
     ```
   
     the following still triggers:
   
     ```scala
     if (queryAsProp.isEmpty) {
         hoodieCatalogTable.initHoodieTable()
     }
     ```
   
     Replace the below logic 
     ```
     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.")
       }
     }
     ```
   
      with:
   
       ```scala
       if (!hoodieCatalogTable.hoodieTableExists) {
           hoodieCatalogTable.initHoodieTable()
       }
       ```
   
     This ensures proper initialization when the base table does not exist and 
allows the test to proceed.
   
   
   ### **Case 2 (After modification for testing): `CREATE -> INSERT -> CREATE 
LIKE (on base table)`**
   
   * **Base table:** Exists ✅
   * **RO/RT tables:** Exist after the first INSERT ✅
   * After modifying the checks, using `CREATE TABLE LIKE` works on base table.
   
   ---
   
   ### **Case 3: `CREATE -> INSERT -> CREATE LIKE (on RO/RT table)`**
   
   * **Base table:** Exists ✅
   * **RO/RT tables:** Exist after the first INSERT ✅
   * **Issue:*** After modifying the checks, using `CREATE TABLE LIKE` on the 
base table allows creation of RO/RT tables as well. This should *not* be 
allowed. A safeguard is needed to prevent RO/RT table creation via the LIKE 
command.
   
   ---
   
   Let me know if you want this rewritten as a Jira ticket summary or a PR 
description.
   


-- 
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]

Reply via email to