ParserInterface — SQL Parser Contract

ParserInterface is the parser contract for creating Expression (to create Columns from), LogicalPlan, TableIdentifier, and StructType for a given SQL textual representation.

Note
The one and only ParserInterface in Spark SQL is AbstractSqlParser.

ParserInterface is available as sqlParser in SessionState.

val spark: org.apache.spark.sql.SparkSession = ...
spark.sessionState.sqlParser

ParserInterface Contract

package org.apache.spark.sql.catalyst.parser

trait ParserInterface {
  def parseExpression(sqlText: String): Expression
  def parsePlan(sqlText: String): LogicalPlan
  def parseTableIdentifier(sqlText: String): TableIdentifier
  def parseTableSchema(sqlText: String): StructType
}
Table 1. ParserInterface Contract (in alphabetical order)
Method Description

parseExpression

Used when…​

parsePlan

Used mainly when SparkSession is requested to execute a SQL query using sql method.

scala> :type spark
org.apache.spark.sql.SparkSession

scala> spark.sql("show databases").show
+------------+
|databaseName|
+------------+
|     default|
+------------+

parseTableIdentifier

Used when…​

parseTableSchema

Used when…​

It has the only single abstract subclass AbstractSqlParser.

results matching ""

    No results matching ""