Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12146#discussion_r59119287
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala 
---
    @@ -0,0 +1,156 @@
    +/*
    + * 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.
    + */
    +
    +package org.apache.spark.sql.hive.execution
    +
    +import org.apache.hadoop.fs.Path
    +
    +import org.apache.spark.sql.{AnalysisException, QueryTest, SaveMode}
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.hive.test.TestHiveSingleton
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.sql.test.SQLTestUtils
    +
    +class HiveDDLSuite extends QueryTest with SQLTestUtils with 
TestHiveSingleton {
    +  import hiveContext.implicits._
    +
    +  // check if the directory for recording the data of the table exists.
    +  private def tableDirectoryExists(tableIdentifier: TableIdentifier): 
Boolean = {
    +    val expectedTablePath =
    +      
hiveContext.sessionState.catalog.hiveDefaultTableFilePath(tableIdentifier)
    +    val filesystemPath = new Path(expectedTablePath)
    +    val fs = filesystemPath.getFileSystem(sparkContext.hadoopConfiguration)
    +    fs.exists(filesystemPath)
    +  }
    +
    +  test("drop tables") {
    +    withTable("tab1") {
    +      val tabName = "tab1"
    +
    +      assert(!tableDirectoryExists(TableIdentifier(tabName)))
    +      sql(s"CREATE TABLE $tabName(c1 int)")
    +
    +      assert(tableDirectoryExists(TableIdentifier(tabName)))
    +      sql(s"DROP TABLE $tabName")
    +
    +      assert(!tableDirectoryExists(TableIdentifier(tabName)))
    +      sql(s"DROP TABLE IF EXISTS $tabName")
    +      sql(s"DROP VIEW IF EXISTS $tabName")
    +    }
    +  }
    +
    +  test("drop managed tables") {
    +    withTempDir { tmpDir =>
    +      val tabName = "tab1"
    +      withTable(tabName) {
    +        assert(tmpDir.listFiles.isEmpty)
    +        sql(
    +          s"""
    +             |create external table $tabName(c1 int COMMENT 'abc', c2 
string)
    +             |stored as parquet
    +             |location '$tmpDir'
    +             |as select 1, '3'
    +          """.stripMargin)
    --- End diff --
    
    btw, for this test case, I am not sure Hive allows you to provide a column 
list in a CTAS table. Also, I am not sure if Hive allows you to provide 
EXTERNAL keyword for a table generated by CTAS query. Can you double check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to