spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nongli <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-12576][SQL] Enable expression parsing i...
Date Mon, 11 Jan 2016 20:34:21 GMT
Github user nongli commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10649#discussion_r49374680
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/CatalystQl.scala ---
    @@ -58,26 +57,39 @@ private[sql] class CatalystQl(val conf: ParserConf = SimpleParserConf())
{
             throw new AnalysisException(e.getMessage)
           case e: NotImplementedError =>
             throw new AnalysisException(
    -          s"""
    -             |Unsupported language features in query: $sql
    -             |${getAst(sql).treeString}
    +          s"""== Unsupported language features in query ==
    +             |== SQL ==
    +             |$sql
    +             |== AST ==
    +             |${ast.treeString}
    +             |== Error ==
                  |$e
    +             |== Stacktrace ==
                  |${e.getStackTrace.head}
               """.stripMargin)
         }
       }
     
    -  protected def createPlan(sql: String, tree: ASTNode): LogicalPlan = nodeToPlan(tree)
    -
    -  def parseDdl(ddl: String): Seq[Attribute] = {
    -    val tree = getAst(ddl)
    -    assert(tree.text == "TOK_CREATETABLE", "Only CREATE TABLE supported.")
    -    val tableOps = tree.children
    -    val colList = tableOps
    -      .find(_.text == "TOK_TABCOLLIST")
    -      .getOrElse(sys.error("No columnList!"))
    -
    -    colList.children.map(nodeToAttribute)
    +  /** Creates LogicalPlan for a given SQL string. */
    +  def parsePlan(sql: String): LogicalPlan =
    +    safeParse(sql, ParseDriver.parsePlan(sql, conf))(nodeToPlan)
    +
    +  /** Creates Expression for a given SQL string. */
    +  def parseExpression(sql: String): Expression =
    +    safeParse(sql, ParseDriver.parseExpression(sql, conf))(selExprNodeToExpr(_).get)
    +
    +  /** Creates Expression for a given SQL string. */
    --- End diff --
    
    Expression -> TableIdentifier


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message