You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by "nk1506 (via GitHub)" <gi...@apache.org> on 2024/08/27 18:23:12 UTC

[PR] Fix create view operation [polaris]

nk1506 opened a new pull request, #216:
URL: https://github.com/apache/polaris/pull/216

   # Description
   
   `CREATE VIEW <>` is failing with spark. 
   
   Fixes # (issue)
   add support of catalog properties for view. 
   
   ## Type of change
   
   Please delete options that are not relevant.
   
   - [*] Bug fix (non-breaking change which fixes an issue)
   
   # How Has This Been Tested?
   
   Tested with unit tests. 


-- 
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: commits-unsubscribe@polaris.apache.org

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


Re: [PR] Fix create view operation [polaris]

Posted by "nk1506 (via GitHub)" <gi...@apache.org>.
nk1506 commented on code in PR #216:
URL: https://github.com/apache/polaris/pull/216#discussion_r1733363067


##########
polaris-service/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -1143,12 +1143,19 @@ private class BasePolarisCatalogViewBuilder extends BaseMetastoreViewCatalog.Bas
 
     public BasePolarisCatalogViewBuilder(TableIdentifier identifier) {
       super(identifier);
+      withProperties(viewDefaultProperties());
     }
 
     @Override
     public ViewBuilder withLocation(String newLocation) {
       return super.withLocation(transformTableLikeLocation(newLocation));
     }
+
+    private Map<String, String> viewDefaultProperties() {
+      Map<String, String> viewDefaultProperties = PropertyUtil.propertiesWithPrefix(BasePolarisCatalog.this.properties(), "table-default.");
+      LOGGER.info("View properties set at catalog level through catalog properties: {}", viewDefaultProperties);

Review Comment:
   Thanks @sfc-gh-emaynard for reviewing. 
   Do you think it might log any sensitive message? Since catalog properties could have some kind of credentials. 



-- 
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: commits-unsubscribe@polaris.apache.org

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


Re: [PR] Fix create view operation [polaris]

Posted by "nk1506 (via GitHub)" <gi...@apache.org>.
nk1506 commented on code in PR #216:
URL: https://github.com/apache/polaris/pull/216#discussion_r1733378345


##########
polaris-service/src/test/java/org/apache/polaris/service/catalog/PolarisSparkIntegrationTest.java:
##########
@@ -264,6 +268,20 @@ public void testCreateTable() {
     assertThat(recordCount).isEqualTo(3);
   }
 
+  @Test

Review Comment:
   makes sense. Thanks. 



-- 
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: commits-unsubscribe@polaris.apache.org

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


Re: [PR] Fix create view operation [polaris]

Posted by "ebyhr (via GitHub)" <gi...@apache.org>.
ebyhr commented on code in PR #216:
URL: https://github.com/apache/polaris/pull/216#discussion_r1733944071


##########
polaris-service/src/test/java/org/apache/polaris/service/catalog/PolarisSparkIntegrationTest.java:
##########
@@ -346,6 +350,20 @@ public void testCreateAndUpdateExternalTable() {
     assertThat(rowCount).isEqualTo(4);
   }
 
+  @Test
+  public void testCreateView() {
+    long namespaceCount = onSpark("SHOW NAMESPACES").count();
+    assertThat(namespaceCount).isEqualTo(0L);
+
+    onSpark("CREATE NAMESPACE ns1");
+    onSpark("USE ns1");
+    onSpark("CREATE TABLE tb1 (col1 integer, col2 string)");
+    onSpark("INSERT INTO tb1 VALUES (1, 'a'), (2, 'b'), (3, 'c')");
+    onSpark("CREATE VIEW view1 as select * from tb1");

Review Comment:
   ```suggestion
       onSpark("CREATE VIEW view1 AS SELECT * FROM tb1");
   ```



##########
polaris-service/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -1143,12 +1143,18 @@ private class BasePolarisCatalogViewBuilder extends BaseMetastoreViewCatalog.Bas
 
     public BasePolarisCatalogViewBuilder(TableIdentifier identifier) {
       super(identifier);
+      withProperties(viewDefaultProperties());
     }
 
     @Override
     public ViewBuilder withLocation(String newLocation) {
       return super.withLocation(transformTableLikeLocation(newLocation));
     }
+
+    private Map<String, String> viewDefaultProperties() {
+      Map<String, String> viewDefaultProperties = PropertyUtil.propertiesWithPrefix(BasePolarisCatalog.this.properties(), "table-default.");
+      return viewDefaultProperties;
+    }

Review Comment:
   Why do we want to have a separate method for such a simple logic? 



-- 
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: commits-unsubscribe@polaris.apache.org

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


Re: [PR] Fix create view operation [polaris]

Posted by "nk1506 (via GitHub)" <gi...@apache.org>.
nk1506 commented on code in PR #216:
URL: https://github.com/apache/polaris/pull/216#discussion_r1733337662


##########
polaris-service/src/main/java/io/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -1065,12 +1068,19 @@ private class BasePolarisCatalogViewBuilder extends BaseMetastoreViewCatalog.Bas
 
     public BasePolarisCatalogViewBuilder(TableIdentifier identifier) {
       super(identifier);
+      withProperties(viewDefaultProperties());

Review Comment:
   If Iceberg would have options to add catalog level properties for view like table. This is not required. I have created a [PR](https://github.com/apache/iceberg/pull/11025) with iceberg to support catalog level properties. 
   
   Or are there any other ways to pass catalog level properties to views ? 



-- 
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: commits-unsubscribe@polaris.apache.org

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


Re: [PR] Fix create view operation [polaris]

Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on PR #216:
URL: https://github.com/apache/polaris/pull/216#issuecomment-2346901539

   Thanks @nk1506 for the fix. Thanks @ebyhr @eric-maynard @RussellSpitzer for the review.


-- 
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: commits-unsubscribe@polaris.apache.org

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


Re: [PR] Fix create view operation [polaris]

Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #216:
URL: https://github.com/apache/polaris/pull/216#discussion_r1733370198


##########
polaris-service/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -1143,12 +1143,19 @@ private class BasePolarisCatalogViewBuilder extends BaseMetastoreViewCatalog.Bas
 
     public BasePolarisCatalogViewBuilder(TableIdentifier identifier) {
       super(identifier);
+      withProperties(viewDefaultProperties());
     }
 
     @Override
     public ViewBuilder withLocation(String newLocation) {
       return super.withLocation(transformTableLikeLocation(newLocation));
     }
+
+    private Map<String, String> viewDefaultProperties() {
+      Map<String, String> viewDefaultProperties = PropertyUtil.propertiesWithPrefix(BasePolarisCatalog.this.properties(), "table-default.");
+      LOGGER.info("View properties set at catalog level through catalog properties: {}", viewDefaultProperties);

Review Comment:
   That's a fair point. I'm also okay with removing the log. I just don't think it should be at the `INFO` level



-- 
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: commits-unsubscribe@polaris.apache.org

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


Re: [PR] Fix create view operation [polaris]

Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain merged PR #216:
URL: https://github.com/apache/polaris/pull/216


-- 
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: commits-unsubscribe@polaris.apache.org

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


Re: [PR] Fix create view operation [polaris]

Posted by "nk1506 (via GitHub)" <gi...@apache.org>.
nk1506 commented on PR #216:
URL: https://github.com/apache/polaris/pull/216#issuecomment-2331296007

   Please let me know if there are any comments left for this fix. 


-- 
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: commits-unsubscribe@polaris.apache.org

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


Re: [PR] Fix create view operation [polaris]

Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #216:
URL: https://github.com/apache/polaris/pull/216#discussion_r1733368737


##########
polaris-service/src/test/java/org/apache/polaris/service/catalog/PolarisSparkIntegrationTest.java:
##########
@@ -264,6 +268,20 @@ public void testCreateTable() {
     assertThat(recordCount).isEqualTo(3);
   }
 
+  @Test

Review Comment:
   Totally agreed -- but this test to create a view is between a test for creating a table and one for creating an external table. 
   
   It's not obvious to me that this keeps tests for the same entities together any better than if the test for the view was moved to the end



-- 
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: commits-unsubscribe@polaris.apache.org

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


Re: [PR] Fix create view operation [polaris]

Posted by "nk1506 (via GitHub)" <gi...@apache.org>.
nk1506 commented on code in PR #216:
URL: https://github.com/apache/polaris/pull/216#discussion_r1733366152


##########
polaris-service/src/test/java/org/apache/polaris/service/catalog/PolarisSparkIntegrationTest.java:
##########
@@ -264,6 +268,20 @@ public void testCreateTable() {
     assertThat(recordCount).isEqualTo(3);
   }
 
+  @Test

Review Comment:
   IMO, we should group tests for the same entities together. This will improve readability.
   WDYT? 



-- 
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: commits-unsubscribe@polaris.apache.org

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


Re: [PR] Fix create view operation [polaris]

Posted by "sfc-gh-emaynard (via GitHub)" <gi...@apache.org>.
sfc-gh-emaynard commented on code in PR #216:
URL: https://github.com/apache/polaris/pull/216#discussion_r1733341558


##########
polaris-service/src/test/java/io/polaris/service/catalog/PolarisSparkIntegrationTest.java:
##########
@@ -253,6 +257,20 @@ public void testCreateTable() {
     assertThat(recordCount).isEqualTo(3);
   }
 
+  @Test

Review Comment:
   nit: new tests should probably go at the end of the file



##########
polaris-service/src/main/java/org/apache/polaris/service/catalog/BasePolarisCatalog.java:
##########
@@ -1143,12 +1143,19 @@ private class BasePolarisCatalogViewBuilder extends BaseMetastoreViewCatalog.Bas
 
     public BasePolarisCatalogViewBuilder(TableIdentifier identifier) {
       super(identifier);
+      withProperties(viewDefaultProperties());
     }
 
     @Override
     public ViewBuilder withLocation(String newLocation) {
       return super.withLocation(transformTableLikeLocation(newLocation));
     }
+
+    private Map<String, String> viewDefaultProperties() {
+      Map<String, String> viewDefaultProperties = PropertyUtil.propertiesWithPrefix(BasePolarisCatalog.this.properties(), "table-default.");
+      LOGGER.info("View properties set at catalog level through catalog properties: {}", viewDefaultProperties);

Review Comment:
   Let's make this a `DEBUG` log



##########
polaris-service/src/test/java/org/apache/polaris/service/catalog/PolarisSparkIntegrationTest.java:
##########
@@ -264,6 +268,20 @@ public void testCreateTable() {
     assertThat(recordCount).isEqualTo(3);
   }
 
+  @Test

Review Comment:
   nit: new tests should probably go at the end of the file



##########
polaris-service/src/test/java/io/polaris/service/catalog/PolarisSparkIntegrationTest.java:
##########
@@ -253,6 +257,20 @@ public void testCreateTable() {
     assertThat(recordCount).isEqualTo(3);
   }
 
+  @Test

Review Comment:
   nit: new tests should probably go at the end of the file



-- 
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: commits-unsubscribe@polaris.apache.org

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