SCHJonathan commented on code in PR #53024:
URL: https://github.com/apache/spark/pull/53024#discussion_r2521608937
##########
sql/connect/server/src/main/scala/org/apache/spark/sql/connect/pipelines/PipelinesHandler.scala:
##########
@@ -129,6 +131,46 @@ private[connect] object PipelinesHandler extends Logging {
}
}
+ /**
+ * Block unsupported SQL commands that are not explicitly allowlisted.
+ */
+ def blockUnsupportedSqlCommand(queryPlan: LogicalPlan): Unit = {
+ val supportedCommand = Set(
+ classOf[DescribeRelation],
+ classOf[ShowTables],
+ classOf[ShowTableProperties],
+ classOf[ShowNamespacesCommand],
+ classOf[ShowColumns],
+ classOf[ShowFunctions],
+ classOf[ShowViews],
+ classOf[ShowCatalogsCommand],
+ classOf[ShowCreateTable])
+ val isSqlCommandExplicitlyAllowlisted = {
+ supportedCommand.exists(c =>
queryPlan.getClass.getName.equals(c.getName))
+ }
+ val isUnsupportedSqlPlan = if (isSqlCommandExplicitlyAllowlisted) {
+ false
+ } else {
+ // If the SQL command is not explicitly allowlisted, check whether it
belongs to
+ // one of commands pipeline explicitly disallow.
+ // If not, the SQL command is supported.
+ queryPlan.isInstanceOf[Command] ||
+ queryPlan.isInstanceOf[CreateTableAsSelect] ||
+ queryPlan.isInstanceOf[CreateTable] ||
+ queryPlan.isInstanceOf[CreateView] ||
+ queryPlan.isInstanceOf[InsertIntoStatement] ||
+ queryPlan.isInstanceOf[RenameTable] ||
+ queryPlan.isInstanceOf[CreateNamespace] ||
+ queryPlan.isInstanceOf[DropView]
+ }
+ // scalastyle:on
Review Comment:
Whoops. Good catch!
--
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]