raghav-reglobe opened a new issue, #67625:
URL: https://github.com/apache/doris/issues/67625

   ## Description
   `CREATE ROW POLICY ... ON <internal_view> USING (<col> ...)` fails with
   `column not exist: <col>` when `<internal_view>` is a view (in the `internal`
   catalog) whose body reads a table in an **external** catalog (e.g. an Iceberg
   REST catalog) — but only **after an FE metadata replay** (FE restart / 
failover).
   A freshly created view of the same shape works. Meanwhile `DESCRIBE`, `SELECT
   <col>`, `information_schema.columns`, and `SHOW CREATE VIEW` all resolve 
`<col>`
   correctly on the very same view, and the row policy would enforce fine at 
query
   time — so only the CREATE-time validation is wrong.
   
   ## Reproduce
   1. Create an external catalog (Iceberg REST) `ext`, with a table 
`ext.db.t(col ...)`.
   2. In the internal catalog, create a view over it:
      `CREATE VIEW internal.d.v AS SELECT ext.db.t.col FROM ext.db.t;`
   3. `CREATE ROW POLICY p ON internal.d.v AS RESTRICTIVE TO ROLE r USING (col 
IS NOT NULL);`
      -> succeeds.
   4. Restart the FE (or trigger a failover) so `internal.d.v` is rebuilt from 
the
      edit log / image (metadata replay).
   5. `CREATE ROW POLICY p2 ON internal.d.v AS RESTRICTIVE TO ROLE r USING (col 
IS NOT NULL);`
      -> **fails: `column not exist: col`**, while `DESCRIBE internal.d.v` 
still lists `col`.
   
   ## Root cause
   `CreatePolicyCommand#validate()` checks column existence with
   `tableIf.getColumn(slot.getName())`. `Table#getColumn(name)` reads the
   `nameToColumn` map, which the `Table` constructor keys by
   `Column#getDefineName()`. For a view over an external catalog, metadata 
replay
   reconstructs the view's columns with a `defineName` that differs from the 
plain
   column `name` (the qualified source reference), so `getColumn(name)` misses a
   column that is present in `getFullSchema()`. `DESCRIBE`, query planning, and 
the
   row-policy runtime (`LogicalCheckPolicy` binds the stored predicate against 
the
   analyzed plan output, not `getColumn`) all resolve the column, which is why 
only
   the CREATE-time guard fails, and only after replay.
   
   ## Fix
   Resolve the predicate columns against `getFullSchema()` (case-insensitive) — 
the
   same source `DESCRIBE`/query planning use, and a superset of the 
`nameToColumn`
   map, so the guard never rejects a column `getColumn` would have accepted. A 
PR
   follows.
   
   ## Version
   Reproduces on master (the `getColumn`-based check is present on the current 
tip).
   


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

Reply via email to