File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
core/src/main/scala/org/apache/spark/sql/execution/datasources
hive/src/test/scala/org/apache/spark/sql/hive/execution Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ class FindDataSourceTable(sparkSession: SparkSession) extends Rule[LogicalPlan]
240240 // TODO: improve `InMemoryCatalog` and remove this limitation.
241241 catalogTable = if (withHiveSupport) Some (table) else None )
242242
243- LogicalRelation (dataSource.resolveRelation(), catalogTable = Some (table))
243+ LogicalRelation (dataSource.resolveRelation(false ), catalogTable = Some (table))
244244 }
245245 })
246246 }
Original file line number Diff line number Diff line change @@ -1431,4 +1431,27 @@ class HiveDDLSuite
14311431 }
14321432 }
14331433 }
1434+
1435+ test(" insert data to a table which has altered the table location " +
1436+ " to a not exist location should success" ) {
1437+ withTable(" t" , " t1" ) {
1438+ withTempDir { dir =>
1439+ spark.sql(
1440+ s """ create table t(a string, b int)
1441+ |using parquet
1442+ |options(path " ${dir.getAbsolutePath}")
1443+ """ .stripMargin)
1444+ var table = spark.sessionState.catalog.getTableMetadata(TableIdentifier (" t" ))
1445+ assert(table.location == dir.getAbsolutePath)
1446+
1447+ var newDir = dir.getAbsolutePath.stripSuffix(" /" ) + " /x"
1448+ spark.sql(s " alter table t set location ' $newDir' " )
1449+ table = spark.sessionState.catalog.getTableMetadata(TableIdentifier (" t" ))
1450+ assert(table.location == newDir)
1451+
1452+ spark.sql(" insert into table t select 'c', 1" )
1453+ checkAnswer(spark.table(" t" ), Row (" c" , 1 ) :: Nil )
1454+ }
1455+ }
1456+ }
14341457}
You can’t perform that action at this time.
0 commit comments