You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/03/08 12:32:35 UTC

[GitHub] [spark] maropu commented on a change in pull request #31721: [SPARK-34603][SQL] Support ADD ARCHIVE and LIST ARCHIVES command

maropu commented on a change in pull request #31721:
URL: https://github.com/apache/spark/pull/31721#discussion_r589370939



##########
File path: docs/sql-ref-syntax-aux-resource-mgmt-add-archive.md
##########
@@ -0,0 +1,53 @@
+---
+layout: global
+title: ADD ARCHIVE
+displayTitle: ADD ARCHIVE
+license: |
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+---
+
+### Description
+
+`ADD ARCHIVE` can be used to add an archive file to the list of resources. The given archive file should be one of .zip, .tar, .tar.gz, .tgz and .jar. The added archive file can be listed using [LIST ARCHIVE](sql-ref-syntax-aux-resource-mgmt-list-archive.html).

Review comment:
       Please update the index (`menu-sql.yaml `) for this page?

##########
File path: docs/sql-ref-syntax-aux-resource-mgmt-list-archive.md
##########
@@ -0,0 +1,53 @@
+---
+layout: global
+title: LIST ARCHIVE
+displayTitle: LIST ARCHIVE
+license: |
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+---
+
+### Description
+
+`LIST ARCHIVE` lists the archives added by [ADD ARCHIVE](sql-ref-syntax-aux-resource-mgmt-add-archive.html).

Review comment:
       ditto: Please update the index (`menu-sql.yaml `) for this page?

##########
File path: docs/sql-ref-syntax-aux-resource-mgmt-list-archive.md
##########
@@ -0,0 +1,53 @@
+---
+layout: global
+title: LIST ARCHIVE
+displayTitle: LIST ARCHIVE
+license: |
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+---
+
+### Description
+
+`LIST ARCHIVE` lists the archives added by [ADD ARCHIVE](sql-ref-syntax-aux-resource-mgmt-add-archive.html).
+
+### Syntax
+
+```sql
+LIST ARCHIVE

Review comment:
       `LIST { ARCHIVE | ARCHIVES }`?

##########
File path: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -857,6 +857,31 @@ class HiveQuerySuite extends HiveComparisonTest with SQLTestUtils with BeforeAnd
     assert(sql(s"list file $testFile").count() == 1)
   }
 
+  test("ADD ARCHIVE command") {
+    withTempDir { dir =>
+      val file = File.createTempFile("someprefix1", "somesuffix1", dir)
+      val zipFile = new File(dir, "test.zip")
+      TestUtils.createJar(Seq(file), zipFile)
+      sql(s"ADD ARCHIVE ${zipFile.getAbsolutePath}#foo")

Review comment:
       Could you add a test for `ADD ARCHIVES`, too?

##########
File path: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -857,6 +857,31 @@ class HiveQuerySuite extends HiveComparisonTest with SQLTestUtils with BeforeAnd
     assert(sql(s"list file $testFile").count() == 1)
   }
 
+  test("ADD ARCHIVE command") {
+    withTempDir { dir =>
+      val file = File.createTempFile("someprefix1", "somesuffix1", dir)
+      val zipFile = new File(dir, "test.zip")
+      TestUtils.createJar(Seq(file), zipFile)
+      sql(s"ADD ARCHIVE ${zipFile.getAbsolutePath}#foo")
+
+      val checkAddArchive =
+        sparkContext.parallelize(
+          Seq(
+            "foo",
+            s"foo/${file.getName}"), 1).map { name =>
+          (name, new File(SparkFiles.get(name)).canRead)
+        }.collect()
+
+      assert(checkAddArchive(0) === ("foo", true))
+      assert(checkAddArchive(1) === (s"foo/${file.getName}", true))
+      assert(sql("list archives").

Review comment:
       nit: please use the upper case where possible, `LIST ARCHIVES`.

##########
File path: docs/sql-ref-syntax-aux-resource-mgmt-add-archive.md
##########
@@ -0,0 +1,53 @@
+---
+layout: global
+title: ADD ARCHIVE
+displayTitle: ADD ARCHIVE
+license: |
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+---
+
+### Description
+
+`ADD ARCHIVE` can be used to add an archive file to the list of resources. The given archive file should be one of .zip, .tar, .tar.gz, .tgz and .jar. The added archive file can be listed using [LIST ARCHIVE](sql-ref-syntax-aux-resource-mgmt-list-archive.html).
+
+### Syntax
+
+```sql
+ADD ARCHIVE file_name

Review comment:
       `ADD { ARCHIVE | ARCHIVES }`?

##########
File path: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -857,6 +857,31 @@ class HiveQuerySuite extends HiveComparisonTest with SQLTestUtils with BeforeAnd
     assert(sql(s"list file $testFile").count() == 1)
   }
 
+  test("ADD ARCHIVE command") {
+    withTempDir { dir =>
+      val file = File.createTempFile("someprefix1", "somesuffix1", dir)
+      val zipFile = new File(dir, "test.zip")
+      TestUtils.createJar(Seq(file), zipFile)
+      sql(s"ADD ARCHIVE ${zipFile.getAbsolutePath}#foo")
+
+      val checkAddArchive =
+        sparkContext.parallelize(
+          Seq(
+            "foo",
+            s"foo/${file.getName}"), 1).map { name =>
+          (name, new File(SparkFiles.get(name)).canRead)
+        }.collect()
+
+      assert(checkAddArchive(0) === ("foo", true))
+      assert(checkAddArchive(1) === (s"foo/${file.getName}", true))
+      assert(sql("list archives").
+        filter(_.getString(0).contains(s"${zipFile.getAbsolutePath}")).count() > 0)
+      assert(sql("list archive").
+        filter(_.getString(0).contains(s"${zipFile.getAbsolutePath}")).count() > 0)
+      assert(sql(s"list archive ${zipFile.getAbsolutePath}").count() == 1)

Review comment:
       ditto

##########
File path: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -857,6 +857,31 @@ class HiveQuerySuite extends HiveComparisonTest with SQLTestUtils with BeforeAnd
     assert(sql(s"list file $testFile").count() == 1)
   }
 
+  test("ADD ARCHIVE command") {
+    withTempDir { dir =>
+      val file = File.createTempFile("someprefix1", "somesuffix1", dir)
+      val zipFile = new File(dir, "test.zip")
+      TestUtils.createJar(Seq(file), zipFile)
+      sql(s"ADD ARCHIVE ${zipFile.getAbsolutePath}#foo")
+
+      val checkAddArchive =
+        sparkContext.parallelize(
+          Seq(
+            "foo",
+            s"foo/${file.getName}"), 1).map { name =>
+          (name, new File(SparkFiles.get(name)).canRead)
+        }.collect()
+
+      assert(checkAddArchive(0) === ("foo", true))
+      assert(checkAddArchive(1) === (s"foo/${file.getName}", true))
+      assert(sql("list archives").
+        filter(_.getString(0).contains(s"${zipFile.getAbsolutePath}")).count() > 0)
+      assert(sql("list archive").

Review comment:
       ditto

##########
File path: docs/sql-ref-syntax-aux-resource-mgmt-add-archive.md
##########
@@ -0,0 +1,53 @@
+---
+layout: global
+title: ADD ARCHIVE
+displayTitle: ADD ARCHIVE
+license: |
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+---
+
+### Description
+
+`ADD ARCHIVE` can be used to add an archive file to the list of resources. The given archive file should be one of .zip, .tar, .tar.gz, .tgz and .jar. The added archive file can be listed using [LIST ARCHIVE](sql-ref-syntax-aux-resource-mgmt-list-archive.html).
+
+### Syntax
+
+```sql
+ADD ARCHIVE file_name
+```
+
+### Parameters
+
+* **file_name**
+
+    The name of the archive file to be added. It could be either on a local file system or a distributed file system.
+
+### Examples
+
+```sql
+ADD ARCHIVE /tmp/test.tar.gz;

Review comment:
       We can pass multiple files here? If so,
   ```
   ADD { ARCHIVE | ARCHIVES } file_name [ ... ]?
   ```
   ?

##########
File path: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
##########
@@ -857,6 +857,31 @@ class HiveQuerySuite extends HiveComparisonTest with SQLTestUtils with BeforeAnd
     assert(sql(s"list file $testFile").count() == 1)
   }
 
+  test("ADD ARCHIVE command") {
+    withTempDir { dir =>
+      val file = File.createTempFile("someprefix1", "somesuffix1", dir)
+      val zipFile = new File(dir, "test.zip")
+      TestUtils.createJar(Seq(file), zipFile)
+      sql(s"ADD ARCHIVE ${zipFile.getAbsolutePath}#foo")

Review comment:
       What if the given file does not exist? Also, what if the given file has a unsupported format?




----------------------------------------------------------------
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.

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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org