Skip to content

[SPARK-12889][SQL] Rename ParserDialect -> ParserInterface. #10817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import scala.util.parsing.input.CharArrayReader.EofCh
import org.apache.spark.sql.catalyst.plans.logical._

private[sql] abstract class AbstractSparkSQLParser
extends StandardTokenParsers with PackratParsers with ParserDialect {
extends StandardTokenParsers with PackratParsers with ParserInterface {

def parsePlan(input: String): LogicalPlan = synchronized {
// Initialize the Keywords.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.apache.spark.util.random.RandomSampler
/**
* This class translates SQL to Catalyst [[LogicalPlan]]s or [[Expression]]s.
*/
private[sql] class CatalystQl(val conf: ParserConf = SimpleParserConf()) extends ParserDialect {
private[sql] class CatalystQl(val conf: ParserConf = SimpleParserConf()) extends ParserInterface {
object Token {
def unapply(node: ASTNode): Some[(String, List[ASTNode])] = {
CurrentOrigin.setPosition(node.line, node.positionInLine)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
/**
* Interface for a parser.
*/
trait ParserDialect {
trait ParserInterface {
/** Creates LogicalPlan for a given SQL string. */
def parsePlan(sqlText: String): LogicalPlan

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class SQLContext private[sql](
protected[sql] lazy val optimizer: Optimizer = new SparkOptimizer(this)

@transient
protected[sql] val sqlParser: ParserDialect = new SparkSQLParser(new SparkQl(conf))
protected[sql] val sqlParser: ParserInterface = new SparkSQLParser(new SparkQl(conf))

@transient
protected[sql] val ddlParser: DDLParser = new DDLParser(sqlParser)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package org.apache.spark.sql.execution

import scala.util.parsing.combinator.RegexParsers

import org.apache.spark.sql.catalyst.{AbstractSparkSQLParser, ParserDialect, TableIdentifier}
import org.apache.spark.sql.catalyst.{AbstractSparkSQLParser, ParserInterface, TableIdentifier}
import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference, Expression}
import org.apache.spark.sql.catalyst.plans.logical
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
Expand All @@ -33,7 +33,7 @@ import org.apache.spark.sql.types.StringType
* parameter because this allows us to return a different dialect if we
* have to.
*/
class SparkSQLParser(fallback: => ParserDialect) extends AbstractSparkSQLParser {
class SparkSQLParser(fallback: => ParserInterface) extends AbstractSparkSQLParser {

override def parseExpression(sql: String): Expression = fallback.parseExpression(sql)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import scala.util.matching.Regex

import org.apache.spark.Logging
import org.apache.spark.sql.SaveMode
import org.apache.spark.sql.catalyst.{AbstractSparkSQLParser, ParserDialect, TableIdentifier}
import org.apache.spark.sql.catalyst.{AbstractSparkSQLParser, ParserInterface, TableIdentifier}
import org.apache.spark.sql.catalyst.analysis.UnresolvedRelation
import org.apache.spark.sql.catalyst.expressions.Expression
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
Expand All @@ -32,7 +32,7 @@ import org.apache.spark.sql.types._
/**
* A parser for foreign DDL commands.
*/
class DDLParser(fallback: => ParserDialect)
class DDLParser(fallback: => ParserInterface)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: it is somewhat strange that DDLParser has a "parse" method (not parsePlan). I'm leaving that unchanged because this class will likely just go away.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I missed that one. AbstractSparkSQLParser already implements this, it should have been overridden.

extends AbstractSparkSQLParser with DataTypeParser with Logging {

override def parseExpression(sql: String): Expression = fallback.parseExpression(sql)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import org.apache.spark.api.java.JavaSparkContext
import org.apache.spark.sql._
import org.apache.spark.sql.SQLConf.SQLConfEntry
import org.apache.spark.sql.SQLConf.SQLConfEntry._
import org.apache.spark.sql.catalyst.{InternalRow, ParserDialect}
import org.apache.spark.sql.catalyst.{InternalRow, ParserInterface}
import org.apache.spark.sql.catalyst.analysis._
import org.apache.spark.sql.catalyst.expressions.{Expression, LeafExpression}
import org.apache.spark.sql.catalyst.expressions.codegen.CodegenFallback
Expand Down Expand Up @@ -546,7 +546,7 @@ class HiveContext private[hive](
}

@transient
protected[sql] override val sqlParser: ParserDialect = {
protected[sql] override val sqlParser: ParserInterface = {
new SparkSQLParser(new ExtendedHiveQlParser(this))
}

Expand Down