Skip to content

Commit e040ff5

Browse files
author
Patrick Woody
committed
fixes
1 parent 507aa7b commit e040ff5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ case class DataSource(
359359
val globbedPaths =
360360
checkAndGlobPathIfNecessary(checkEmptyGlobPath = true, checkFilesExist = checkFilesExist)
361361
val useCatalogFileIndex = sparkSession.sqlContext.conf.manageFilesourcePartitions &&
362-
catalogTable.isDefined
362+
catalogTable.isDefined && catalogTable.get.tracksPartitionsInCatalog &&
363+
catalogTable.get.dataSchema.nonEmpty
363364
val (fileCatalog, dataSchema, partitionSchema) = if (useCatalogFileIndex) {
364365
val defaultTableSize = sparkSession.sessionState.conf.defaultSizeInBytes
365366
val index = fileIndexFactory.create(

sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
498498

499499
test("Create partitioned data source table with user specified schema") {
500500
import testImplicits._
501-
val df = sparkContext.parallelize(1 to 10).map(i => (i, i.toString)).toDF("num", "str")
501+
val df = sparkContext.parallelize(1 to 10).map(i => (i.toString, i)).toDF("str", "num")
502502

503503
// Case 1: with partitioning columns but no schema: Option("num")
504504
// Case 2: without schema and partitioning columns: None
@@ -508,7 +508,7 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
508508
.save(pathToPartitionedTable.getCanonicalPath)
509509
checkSchemaInCreatedDataSourceTable(
510510
pathToPartitionedTable,
511-
userSpecifiedSchema = Option("num int, str string"),
511+
userSpecifiedSchema = Option("str string, num int"),
512512
userSpecifiedPartitionCols = partitionCols,
513513
expectedSchema = new StructType().add("str", StringType).add("num", IntegerType),
514514
expectedPartitionCols = partitionCols.map(Seq(_)).getOrElse(Seq.empty[String]))

0 commit comments

Comments
 (0)