Github user xwu0226 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13212#discussion_r64257719
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
    @@ -774,13 +774,42 @@ class SparkSqlAstBuilder(conf: SQLConf) extends 
AstBuilder {
       }
     
       /**
    -   * Create an [[AddJarCommand]] or [[AddFileCommand]] command depending 
on the requested resource.
    +   * Create a [[AddFileCommand]], [[AddJarCommand]], [[ListFilesCommand]] 
or [[ListJarsCommand]]
    +   * command depending on the requested operation on resources.
    +   * Expected format:
    +   * {{{
    +   *   ADD (FILE[s] [filepath ...] | JAR[s] [jarpath ...])
    +   *   DELETE (FILE[s] [filepath ...] | JAR[s] [jarpath ...])
    +   *   LIST (FILE[s] [filepath ...] | JAR[s] [jarpath ...])
    +   * }}}
        */
    -  override def visitAddResource(ctx: AddResourceContext): LogicalPlan = 
withOrigin(ctx) {
    -    ctx.identifier.getText.toLowerCase match {
    -      case "file" => AddFileCommand(remainder(ctx.identifier).trim)
    -      case "jar" => AddJarCommand(remainder(ctx.identifier).trim)
    -      case other => throw operationNotAllowed(s"ADD with resource type 
'$other'", ctx)
    +  override def visitManageResource(ctx: ManageResourceContext): 
LogicalPlan = withOrigin(ctx) {
    +    val mayebePaths = remainder(ctx.identifier).trim
    +    ctx.op.getType match {
    +      case SqlBaseParser.ADD =>
    +        ctx.identifier.getText.toLowerCase match {
    +          case "file" => AddFileCommand(mayebePaths)
    +          case "jar" => AddJarCommand(mayebePaths)
    +          case other => throw operationNotAllowed(s"ADD with resource type 
'$other'", ctx)
    +        }
    +      case SqlBaseParser.DELETE =>
    +        throw operationNotAllowed(s"DELETE resources", ctx)
    +      case SqlBaseParser.LIST =>
    +        ctx.identifier.getText.toLowerCase match {
    +          case "files" | "file" =>
    +            if (mayebePaths.length > 0) {
    +              ListFilesCommand(mayebePaths.split("\\s+"))
    --- End diff --
    
    Currently, our `add file/jar` command does not support path containing 
space yet. For example:
    ```
    spark-sql> add file "/Users/xinwu/spark-test/data/test 1.jar";
    16/05/23 10:37:39 ERROR SparkSQLDriver: Failed in [add file 
"/Users/xinwu/spark-test/data/test 1.jar"]
    java.net.URISyntaxException: Illegal character in path at index 0: 
"/Users/xinwu/spark-test/data/test 1.jar"
        at java.net.URI$Parser.fail(URI.java:2848)
        at java.net.URI$Parser.checkChars(URI.java:3021)
        at java.net.URI$Parser.parseHierarchical(URI.java:3105)
        at java.net.URI$Parser.parse(URI.java:3063)
        at java.net.URI.<init>(URI.java:588)
        at org.apache.spark.SparkContext.addFile(SparkContext.scala:1404)
        at org.apache.spark.SparkContext.addFile(SparkContext.scala:1386)
        at 
org.apache.spark.sql.execution.command.AddFileCommand.run(resources.scala:50)
        at 
org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:57)
        at 
org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:55)
        at 
org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:69)
        at 
org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:115)
        at 
org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:115)
        at 
org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$1.apply(SparkPlan.scala:136)
        at 
org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
        at 
org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:133)
        at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:114)
    ```
    We can look into that with another PR. What do you think?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to