Skip to content

Commit e4399b9

Browse files
committed
tmp
1 parent 1e2fc4c commit e4399b9

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

integration/spark/src/main/scala/org/apache/spark/sql/CarbonEnv.scala

+2-7
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,8 @@ object CarbonEnv {
394394
isExternal: Boolean,
395395
isTransactionalTable: Boolean
396396
)(sparkSession: SparkSession): String = {
397-
var tmpPath = location.getOrElse(
398-
CarbonEnv.newTablePath(databaseNameOp, tableName)(sparkSession))
399-
if (!isExternal && isTransactionalTable && location.isEmpty &&
400-
(FileFactory.getCarbonFile(tmpPath).exists() || EnvHelper.isLegacy(sparkSession))) {
401-
tmpPath = tmpPath + "_" + tableId
402-
}
403-
val path = new Path(tmpPath)
397+
val path = new Path(location.getOrElse(
398+
CarbonEnv.newTablePath(databaseNameOp, tableName)(sparkSession)))
404399
val fs = path.getFileSystem(sparkSession.sparkContext.hadoopConfiguration)
405400
fs.makeQualified(path).toString
406401
}

integration/spark/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonCreateTableCommand.scala

-12
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,6 @@ case class CarbonCreateTableCommand(
153153
CarbonEnv.getInstance(sparkSession).carbonMetaStore
154154
.removeTableFromMetadata(dbName, tableName)
155155

156-
// Delete the folders created by this call if the actual path is different
157-
val actualPath = CarbonEnv
158-
.getCarbonTable(TableIdentifier(tableName, Option(dbName)))(sparkSession)
159-
.getTablePath
160-
161-
if (!actualPath.equalsIgnoreCase(tablePath)) {
162-
LOGGER
163-
.error(
164-
"TableAlreadyExists with path : " + actualPath + " So, deleting " + tablePath)
165-
FileFactory.deleteAllCarbonFilesOfDir(FileFactory.getCarbonFile(tablePath))
166-
}
167-
168156
// No need to throw for create if not exists
169157
if (ifNotExistsSet) {
170158
LOGGER.error(e, e)

integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableIfNotExists.scala

+17
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.carbondata.spark.testsuite.createTable
1919

20+
import java.io.File
2021
import java.util.concurrent.{Callable, Executors, ExecutorService, Future, TimeUnit}
2122

2223
import org.apache.spark.sql.AnalysisException
@@ -44,6 +45,22 @@ class TestCreateTableIfNotExists extends QueryTest with BeforeAndAfterAll {
4445
}
4546
}
4647

48+
test("test create table with consistent table location") {
49+
val dbName = "testdb"
50+
val tblName = "testtbl"
51+
sql(s"drop database if exists $dbName cascade")
52+
val dblocation = warehouse + File.separator + dbName
53+
sql(s"create database $dbName location '$dblocation'")
54+
sql(s"use $dbName")
55+
56+
// here, we make sure the carbontablepath contains uuid
57+
val tbllocation = dblocation + File.separator + tblName
58+
new File(tbllocation).mkdir()
59+
assert(new File(tbllocation).exists())
60+
61+
sql(s"create table $tblName(a int, b string) stored as carbondata")
62+
}
63+
4764
test("test create table if not exist concurrently") {
4865

4966
val executorService: ExecutorService = Executors.newFixedThreadPool(10)

0 commit comments

Comments
 (0)