gengliangwang commented on code in PR #50538: URL: https://github.com/apache/spark/pull/50538#discussion_r2034193451
########## sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala: ########## @@ -256,6 +257,22 @@ class FindDataSourceTable(sparkSession: SparkSession) extends Rule[LogicalPlan] QualifiedTableName(table.identifier.catalog.get, table.database, table.identifier.table) val catalog = sparkSession.sessionState.catalog val dsOptions = DataSourceUtils.generateDatasourceOptions(extraOptions, table) + + // Invalidate the cache if the table is already cached but options have changed. + val cachedPlan = catalog.getCachedTable(qualifiedTableName) + if (cachedPlan != null) { + cachedPlan match { + case LogicalRelationWithTable( + HadoopFsRelation(_, _, _, _, _, options), _) => + val prevOptions = new CaseInsensitiveStringMap(options.asJava) + val newOptions = new CaseInsensitiveStringMap(dsOptions.asJava) + if (prevOptions != newOptions) { + catalog.invalidateCachedTable(qualifiedTableName) + } + case _ => + } + } + catalog.getCachedPlan(qualifiedTableName, () => { Review Comment: Let's compare the data source option with the result plan. If different, construct a plan with the new dsOptions. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org