ebyhr commented on code in PR #14831:
URL: https://github.com/apache/iceberg/pull/14831#discussion_r2616144150
##########
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveViewCommits.java:
##########
@@ -111,6 +113,34 @@ public void dropTestView() throws IOException {
catalog.dropView(VIEW_IDENTIFIER);
}
+ @Test
+ public void testViewQueryIsUpdatedOnCommit() throws Exception {
+ HiveViewOperations ops = (HiveViewOperations) ((BaseView)
view).operations();
+ Table tbl = ops.loadHmsTable();
+ assertThat(tbl.getViewOriginalText()).isEqualTo(VIEW_QUERY);
+ assertThat(tbl.getViewExpandedText()).isEqualTo(VIEW_QUERY);
+
+ String newQuery = "select * from ns.tbl2 limit 10";
Review Comment:
There's no guarantee that VIEW_QUERY constant will be different from
newQuery in the future. We could add the following assertion just in case:
```java
assertThat(VIEW_QUERY).isNotEqualTo(newQuery);
```
##########
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java:
##########
@@ -145,7 +142,11 @@ public void doCommit(ViewMetadata base, ViewMetadata
metadata) {
database,
viewName);
}
-
+ String sqlQuery = sqlFor(metadata);
+ if (sqlQuery != null) {
+ tbl.setViewExpandedText(sqlQuery);
+ tbl.setViewOriginalText(sqlQuery);
+ }
Review Comment:
An empty line can be added after `}`.
##########
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java:
##########
@@ -145,7 +142,11 @@ public void doCommit(ViewMetadata base, ViewMetadata
metadata) {
database,
viewName);
}
-
Review Comment:
Let's keep the existing new lines.
https://iceberg.apache.org/contribute/#block-spacing
> To improve readability and maintain consistency, always place a newline
after control blocks (if, for, while, switch, etc.).
--
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]