Skip to content

Commit b4c55d6

Browse files
committed
modify some comment
1 parent 7e9d341 commit b4c55d6

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ class SessionCatalog(
249249
/**
250250
* Create a metastore table in the database specified in `tableDefinition`.
251251
* If no such database is specified, create it in the current database.
252+
* suggestIgnoreIfPathExists suggest whether should check if the path of table
253+
* exists when ignoreIfExists is false, if it is false, it will only check the
254+
* path of a managed table, if it is true, it will not do the check for all
255+
* type tables.
252256
*/
253257
def createTable(
254258
tableDefinition: CatalogTable,

sql/core/src/main/scala/org/apache/spark/sql/execution/command/createDataSourceTables.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ case class CreateDataSourceTableAsSelectCommand(
158158
// the schema of df). It is important since the nullability may be changed by the relation
159159
// provider (for example, see org.apache.spark.sql.parquet.DefaultSource).
160160
schema = result.schema)
161+
// the path of the table has been created above before create table, we should not
162+
// check if the path existes, so suggestIgnoreIfPathExists set to true .
161163
sessionState.catalog.createTable(newTable, ignoreIfExists = false,
162164
suggestIgnoreIfPathExists = true)
163165

sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/CreateHiveTableAsSelectCommand.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ package org.apache.spark.sql.hive.execution
1919

2020
import scala.util.control.NonFatal
2121

22-
import org.apache.hadoop.fs.Path
23-
2422
import org.apache.spark.sql.{AnalysisException, Row, SaveMode, SparkSession}
2523
import org.apache.spark.sql.catalyst.analysis.UnresolvedRelation
26-
import org.apache.spark.sql.catalyst.catalog.{CatalogTable, CatalogTableType}
24+
import org.apache.spark.sql.catalyst.catalog.CatalogTable
2725
import org.apache.spark.sql.catalyst.plans.logical.{InsertIntoTable, LogicalPlan}
2826
import org.apache.spark.sql.execution.command.RunnableCommand
2927

@@ -70,9 +68,9 @@ case class CreateHiveTableAsSelectCommand(
7068
// add the relation into catalog, just in case of failure occurs while data
7169
// processing.
7270
assert(tableDesc.schema.isEmpty)
73-
7471
sparkSession.sessionState.catalog.createTable(
7572
tableDesc.copy(schema = query.schema), ignoreIfExists = false)
73+
7674
try {
7775
sparkSession.sessionState.executePlan(
7876
InsertIntoTable(

0 commit comments

Comments
 (0)