huaxingao commented on PR #19277:
URL: https://github.com/apache/iceberg/pull/19277#issuecomment-7434518863
Thanks @nastra. Handling 1 separately sounds good.
For 2, I might be missing something, but I think one Trino case still reads
the wrong column:
```java
@Test
public void readFromTrinoJoinViewAfterAddingDuplicateColumnName() throws
NoSuchTableException {
String left = viewName("l");
String right = viewName("r");
String using = catalogName.equals(SPARK_CATALOG) ? " USING iceberg" : "";
sql("CREATE TABLE IF NOT EXISTS %s (x INT)%s", left, using);
sql("CREATE TABLE IF NOT EXISTS %s (y INT)%s", right, using);
sql("INSERT INTO %s VALUES (10)", left);
sql("INSERT INTO %s VALUES (20)", right);
String viewName = viewName("trinoJoinView");
String query = String.format("SELECT * FROM %s CROSS JOIN %s", left,
right);
viewCatalog()
.buildView(TableIdentifier.of(NAMESPACE, viewName))
.withQuery("trino", query)
.withDefaultNamespace(NAMESPACE)
.withDefaultCatalog(catalogName)
.withSchema(schema(query))
.create();
assertThat(sql("SELECT * FROM %s", viewName)).containsExactly(row(10, 20));
sql("ALTER TABLE %s ADD COLUMN y INT AFTER x", left);
// passes today: the view reads the new l.y instead of r.y
assertThat(sql("SELECT * FROM %s", viewName)).containsExactly(row(10,
null));
}
```
A Trino view has no `spark.query-column-names`, so the duplicate-name check
in `resolveViewColumn` is skipped. This isn't a regression, since it returned
the same result before this PR, so we can fix it in a follow-up and get this
fix in first.
--
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]