Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/16868#discussion_r100424068
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
---
@@ -926,38 +1006,63 @@ class HiveDDLSuite
|CREATE EXTERNAL TABLE $sourceTabName (key INT comment
'test', value STRING)
|COMMENT 'Apache Spark'
|PARTITIONED BY (ds STRING, hr STRING)
- |LOCATION '$basePath'
- """.stripMargin)
+ |LOCATION '$basePath1'
+ """.stripMargin)
for (ds <- Seq("2008-04-08", "2008-04-09"); hr <- Seq("11", "12"))
{
sql(
s"""
|INSERT OVERWRITE TABLE $sourceTabName
|partition (ds='$ds',hr='$hr')
|SELECT 1, 'a'
- """.stripMargin)
+ """.stripMargin)
+ }
+
+ if ( location.isEmpty ) {
+ sql(s"CREATE TABLE $targetTabName LIKE $sourceTabName")
+ } else {
+ sql(s"CREATE TABLE $targetTabName LIKE $sourceTabName" +
+ s" LOCATION '${location.getOrElse("")}'")
--- End diff --
The above logics can be simplified to
```Scala
val locationClause = if (location.nonEmpty) "LOCATION
'${location.getOrElse("")}'" else ""
sql(s"CREATE TABLE $targetTabName LIKE $sourceTabName $locationClause")
```
---
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]