shihchengwei-lab commented on PR #19277: URL: https://github.com/apache/iceberg/pull/19277#issuecomment-7362535242
The name-at-ordinal guard still allows stale `SELECT *` views to read and persist different columns in two cases. I reproduced both on Spark 4.1.4 at `452ba809`; each `CREATE TABLE AS SELECT` completed and stored the wrong value. 1. A comma in a quoted name loses its field boundary: ```sql CREATE TABLE t (id INT, `price,usd` INT) USING iceberg; INSERT INTO t VALUES (10, 20); CREATE VIEW v AS SELECT * FROM t; ALTER TABLE t ADD COLUMN n INT FIRST; SELECT * FROM v; -- (NULL, 10), previously (10, 20) ``` The saved property is `id,price,usd`. Splitting it yields three names for two fields, so the guard falls back to unchecked ordinals. The same encoding makes a newly created view immediately stale when its query uses the alias `` `amount,` ``; the base can read that view. 2. A join can keep the expected name at an ordinal while changing its source: ```sql CREATE TABLE l (x INT) USING iceberg; CREATE TABLE r (y INT) USING iceberg; INSERT INTO l VALUES (10); INSERT INTO r VALUES (20); CREATE VIEW joined AS SELECT * FROM l CROSS JOIN r; ALTER TABLE l ADD COLUMN y INT AFTER x; SELECT y FROM joined; -- NULL; r.y is still 20 ``` Adding `l.y` puts it in the middle of the expanded output `(l.x, l.y, r.y)`. The guard sees the saved name `y` at position 1 and returns `l.y`; copying the view stores `NULL`. Both cases also reproduce on the base, so they are within this PR's stated goal of turning shifted-column reads into stale-view errors. Could the metadata preserve names losslessly and the resolver reject an ordinal when the saved name has multiple candidates in the expanded output? AI assistance: Codex traced both paths, tested the base and PR revisions, and drafted this comment. -- 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]
