RussellSpitzer commented on a change in pull request #1948:
URL: https://github.com/apache/iceberg/pull/1948#discussion_r545886729
##########
File path:
spark3-extensions/src/main/scala/org/apache/spark/sql/catalyst/parser/extensions/IcebergSparkSqlExtensionsParser.scala
##########
@@ -94,13 +94,20 @@ class IcebergSparkSqlExtensionsParser(delegate:
ParserInterface) extends ParserI
*/
override def parsePlan(sqlText: String): LogicalPlan = {
val sqlTextAfterSubstitution = substitutor.substitute(sqlText)
- if
(sqlTextAfterSubstitution.toLowerCase(Locale.ROOT).trim().startsWith("call")) {
+ if (isIcebergCommand(sqlTextAfterSubstitution)) {
parse(sqlTextAfterSubstitution) { parser =>
astBuilder.visit(parser.singleStatement()) }.asInstanceOf[LogicalPlan]
} else {
delegate.parsePlan(sqlText)
}
}
+ private def isIcebergCommand(sqlText: String): Boolean = {
+ val normalized = sqlText.toLowerCase(Locale.ROOT).trim()
+ normalized.startsWith("call") ||
+ (normalized.startsWith("alter table") && (
+ normalized.contains("add partition field") ||
normalized.contains("drop partition field")))
Review comment:
I was thinking about this before and I didn't want it to be that
specific. I think maybe a cool solution could be trying both, and checking
which parser parsed the furthest. Each of our analysis exceptions should give a
position, so we can just pick whoever parsed the most. How does that sound?
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]