jzhuge commented on a change in pull request #25735: [SPARK-29030][SQL]
Simplify lookupV2Relation
URL: https://github.com/apache/spark/pull/25735#discussion_r323880243
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -970,25 +966,24 @@ class Analyzer(
tableName: Seq[String],
changes: Seq[TableChange]): Option[AlterTable] = {
lookupV2Relation(tableName) match {
- case scala.Left((v2Catalog, ident, tableOpt)) =>
+ case (Some(table), Some((catalog, ident))) =>
Some(AlterTable(
- v2Catalog.asTableCatalog,
+ catalog,
ident,
-
tableOpt.map(DataSourceV2Relation.create).getOrElse(UnresolvedRelation(tableName)),
- changes
- ))
- case scala.Right(tableOpt) =>
- tableOpt.map { table =>
- AlterTable(
- sessionCatalog.asTableCatalog,
- Identifier.of(tableName.init.toArray, tableName.last),
- DataSourceV2Relation.create(table),
- changes
- )
- }
+ DataSourceV2Relation.create(table),
+ changes))
+ case (Some(table), None) =>
+ Some(AlterTable(
+ sessionCatalog.asTableCatalog, // table being resolved means this
exists
Review comment:
Good suggestion. This may inspire an even further simplification. Let me
explore and report back.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]