aokolnychyi commented on a change in pull request #3661:
URL: https://github.com/apache/iceberg/pull/3661#discussion_r764353545
##########
File path:
spark/v3.2/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/parser/extensions/IcebergSparkSqlExtensionsParser.scala
##########
@@ -103,7 +114,43 @@ class IcebergSparkSqlExtensionsParser(delegate:
ParserInterface) extends ParserI
if (isIcebergCommand(sqlTextAfterSubstitution)) {
parse(sqlTextAfterSubstitution) { parser =>
astBuilder.visit(parser.singleStatement()) }.asInstanceOf[LogicalPlan]
} else {
- delegate.parsePlan(sqlText)
+ val parsedPlan = delegate.parsePlan(sqlText)
+ parsedPlan match {
+ case DeleteFromTable(UnresolvedIcebergTable(aliasedTable), condition)
=>
+ DeleteFromIcebergTable(aliasedTable, condition)
+ case _ =>
+ parsedPlan
+ }
+ }
+ }
+
+ object UnresolvedIcebergTable {
+
+ def unapply(plan: LogicalPlan): Option[LogicalPlan] = {
+ EliminateSubqueryAliases(plan) match {
+ case UnresolvedRelation(multipartIdentifier, _, _) if
isIcebergTable(multipartIdentifier) =>
+ Some(plan)
+ case _ =>
+ None
+ }
+ }
+
+ private def isIcebergTable(multipartIdent: Seq[String]): Boolean = {
+ val catalogAndIdentifier =
Spark3Util.catalogAndIdentifier(SparkSession.active, multipartIdent.asJava)
+ catalogAndIdentifier.catalog match {
+ case tableCatalog: TableCatalog =>
+ Try(tableCatalog.loadTable(catalogAndIdentifier.identifier))
+ .map(isIcebergTable)
+ .getOrElse(false)
+
+ case _ =>
+ false
+ }
+ }
+
+ private def isIcebergTable(table: Table): Boolean = table match {
+ case _: SparkTable =>true
Review comment:
Removed.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]