From 942cbbc7fb79e0ad04a1a164a6960eae91219a02 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Mon, 23 Dec 2024 13:40:45 -0800 Subject: [PATCH 1/3] Show security mode in SHOW CREATE VIEW Update test Lint Typo Fix tests Rerun CI Rerun CI 2 Rerun CI 3 Fix spacing Fix whitespace Rerun CI 1 --- .../rest/TestIcebergSmokeRestNestedNamespace.java | 10 ++++++---- .../presto/sql/rewrite/ShowQueriesRewrite.java | 3 ++- .../java/com/facebook/presto/sql/SqlFormatter.java | 3 +-- .../presto/spark/TestPrestoSparkQueryRunner.java | 2 +- .../presto/tests/AbstractTestDistributedQueries.java | 3 ++- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/rest/TestIcebergSmokeRestNestedNamespace.java b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/rest/TestIcebergSmokeRestNestedNamespace.java index 6660515ae681..1613bcfd9ba1 100644 --- a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/rest/TestIcebergSmokeRestNestedNamespace.java +++ b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/rest/TestIcebergSmokeRestNestedNamespace.java @@ -339,10 +339,12 @@ public void testView() assertUpdate(session, "CREATE VIEW view_orders AS SELECT * from orders"); assertQuery(session, "SELECT * FROM view_orders", "SELECT * from orders"); assertThat(computeActual("SHOW CREATE VIEW view_orders").getOnlyValue()) - .isEqualTo(format("CREATE VIEW iceberg.\"%s\".view_orders AS\n" + - "SELECT *\n" + - "FROM\n" + - " orders", schemaName)); + .isEqualTo(format("CREATE VIEW iceberg.\"%s\".view_orders SECURITY %s AS\n" + + "SELECT *\n" + + "FROM\n" + + " orders", + schemaName, + "DEFINER")); assertUpdate(session, "DROP VIEW view_orders"); } diff --git a/presto-main/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java b/presto-main/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java index 55493e19736a..0b56b1940972 100644 --- a/presto-main/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java +++ b/presto-main/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java @@ -472,7 +472,8 @@ protected Node visitShowCreate(ShowCreate node, Void context) } Query query = parseView(viewDefinition.get().getOriginalSql(), objectName, node); - String sql = formatSql(new CreateView(createQualifiedName(objectName), query, false, Optional.empty()), Optional.of(parameters)).trim(); + CreateView.Security security = (viewDefinition.get().isRunAsInvoker()) ? CreateView.Security.INVOKER : CreateView.Security.DEFINER; + String sql = formatSql(new CreateView(createQualifiedName(objectName), query, false, Optional.of(security)), Optional.of(parameters)).trim(); return singleValueQuery("Create View", sql); } diff --git a/presto-parser/src/main/java/com/facebook/presto/sql/SqlFormatter.java b/presto-parser/src/main/java/com/facebook/presto/sql/SqlFormatter.java index bb853ba01a8e..29553e2bc4c9 100644 --- a/presto-parser/src/main/java/com/facebook/presto/sql/SqlFormatter.java +++ b/presto-parser/src/main/java/com/facebook/presto/sql/SqlFormatter.java @@ -583,8 +583,7 @@ protected Void visitCreateView(CreateView node, Integer indent) node.getSecurity().ifPresent(security -> builder.append(" SECURITY ") - .append(security.toString()) - .append(" ")); + .append(security.toString())); builder.append(" AS\n"); diff --git a/presto-spark-base/src/test/java/com/facebook/presto/spark/TestPrestoSparkQueryRunner.java b/presto-spark-base/src/test/java/com/facebook/presto/spark/TestPrestoSparkQueryRunner.java index 1a030f4184c0..9a07a74e15ec 100644 --- a/presto-spark-base/src/test/java/com/facebook/presto/spark/TestPrestoSparkQueryRunner.java +++ b/presto-spark-base/src/test/java/com/facebook/presto/spark/TestPrestoSparkQueryRunner.java @@ -1202,7 +1202,7 @@ public void testCreateAlterTable() public void testCreateDropView() { // create table with default format orc - String createViewSql = "CREATE VIEW hive.hive_test.hive_view AS\n" + + String createViewSql = "CREATE VIEW hive.hive_test.hive_view SECURITY DEFINER AS\n" + "SELECT *\n" + "FROM\n" + " orders"; diff --git a/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestDistributedQueries.java b/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestDistributedQueries.java index 76197a25dae8..af59766dd458 100644 --- a/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestDistributedQueries.java +++ b/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestDistributedQueries.java @@ -968,10 +968,11 @@ public void testViewMetadata() // test SHOW CREATE VIEW String expectedSql = formatSqlText(format( - "CREATE VIEW %s.%s.%s AS %s", + "CREATE VIEW %s.%s.%s SECURITY %s AS %s", getSession().getCatalog().get(), getSession().getSchema().get(), "meta_test_view", + "DEFINER", query)).trim(); actual = computeActual("SHOW CREATE VIEW meta_test_view"); From 87f4f398f1141212c293d317c84b71f2b678728b Mon Sep 17 00:00:00 2001 From: Amit Dutta Date: Sun, 5 Jan 2025 11:05:13 -0800 Subject: [PATCH 2/3] [native] Advance velox. --- presto-native-execution/velox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presto-native-execution/velox b/presto-native-execution/velox index bfe085db7bfb..6171b52be4f4 160000 --- a/presto-native-execution/velox +++ b/presto-native-execution/velox @@ -1 +1 @@ -Subproject commit bfe085db7bfbcb63b73db69a8a5e53a6587f06f5 +Subproject commit 6171b52be4f4a846d32ea0ab31a8c2c028b93365 From 7913aa41c675fea2a4bb85b2f6dcaf6a4303bc4e Mon Sep 17 00:00:00 2001 From: Timothy Meehan Date: Fri, 13 Dec 2024 10:03:37 -0500 Subject: [PATCH 3/3] Do not use AI tools to generate documentation Update contributing guide to call out AI tools. These generate low quality documentation and they are easily identifiable. --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 151a5cf8d2ad..79f4af3092b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -478,6 +478,7 @@ We use the [Fork and Pull model](https://docs.github.com/en/pull-requests/collab * Ask reviewers to provide examples or code references without trying to find them on your own * Protest lack of documentation for a code section * Instead, review the related code, then draft initial documentation as a separate commit +* Use AI tools to generate documentation * Submit without test cases or clear justification for lack thereof * Request review when there are tests failing