amogh-jahagirdar commented on code in PR #9247:
URL: https://github.com/apache/iceberg/pull/9247#discussion_r1419759456


##########
api/src/main/java/org/apache/iceberg/view/View.java:
##########
@@ -121,4 +121,15 @@ default UpdateLocation updateLocation() {
   default UUID uuid() {
     throw new UnsupportedOperationException("Retrieving a view's uuid is not 
supported");
   }
+
+  /**
+   * Returns the view representation for the given SQL dialect
+   *
+   * @return the view representation for the given SQL dialect, or null if no 
representation could
+   *     be resolved
+   */
+  default ViewRepresentation sqlFor(String dialect) {

Review Comment:
   It's unfortunate, this API has to return a `ViewRepresentation`. It would 
have been better if it could have returned a `SQLViewRepresentation` 
specifically but since that's an implementation in core that's not possible. 
The issue is that now callers have to cast. But I guess they would've had to do 
that anyways?



##########
core/src/test/java/org/apache/iceberg/view/ViewCatalogTests.java:
##########
@@ -200,6 +200,13 @@ public void completeCreateView() {
                         .build())
                 .build());
 
+    assertThat(((SQLViewRepresentation) view.sqlFor("spark")).sql())
+        .isEqualTo("select * from ns.tbl");
+    assertThat(((SQLViewRepresentation) view.sqlFor("trino")).sql())
+        .isEqualTo("select * from ns.tbl using X");
+    assertThat(((SQLViewRepresentation) view.sqlFor("unknown-dialect")).sql())
+        .isEqualTo("select * from ns.tbl using X");

Review Comment:
   I should add a test where a non "sql" representation is added, to verify 
null is returned when there is no sql representation. Our APIs don't really 
expose that anyways but worth testing.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to