[HUDI-2182] Support Compaction Command For Spark Sql (#3277)
This commit is contained in:
@@ -29,7 +29,7 @@ import org.apache.spark.sql.catalyst.plans.logical.{InsertIntoTable, Join, Logic
|
||||
import org.apache.spark.sql.catalyst.{AliasIdentifier, TableIdentifier}
|
||||
import org.apache.spark.sql.execution.datasources.{Spark2ParsePartitionUtil, SparkParsePartitionUtil}
|
||||
import org.apache.spark.sql.hudi.SparkAdapter
|
||||
import org.apache.spark.sql.hudi.parser.HoodieSqlParser
|
||||
import org.apache.spark.sql.hudi.parser.HoodieSpark2ExtendedSqlParser
|
||||
import org.apache.spark.sql.internal.SQLConf
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ class Spark2Adapter extends SparkAdapter {
|
||||
|
||||
override def createExtendedSparkParser: Option[(SparkSession, ParserInterface) => ParserInterface] = {
|
||||
Some(
|
||||
(spark: SparkSession, delegate: ParserInterface) => new HoodieSqlParser(spark, delegate)
|
||||
(spark: SparkSession, delegate: ParserInterface) => new HoodieSpark2ExtendedSqlParser(spark, delegate)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import scala.collection.JavaConverters._
|
||||
* Here we only do the parser for the extended sql syntax. e.g MergeInto. For
|
||||
* other sql syntax we use the delegate sql parser which is the SparkSqlParser.
|
||||
*/
|
||||
class HoodieSqlAstBuilder(conf: SQLConf, delegate: ParserInterface) extends HoodieSqlBaseBaseVisitor[AnyRef] with Logging {
|
||||
class HoodieSpark2ExtendedSqlAstBuilder(conf: SQLConf, delegate: ParserInterface) extends HoodieSqlBaseBaseVisitor[AnyRef] with Logging {
|
||||
|
||||
import ParserUtils._
|
||||
|
||||
@@ -32,11 +32,11 @@ import org.apache.spark.sql.catalyst.{FunctionIdentifier, TableIdentifier}
|
||||
import org.apache.spark.sql.types._
|
||||
import org.apache.spark.sql.{AnalysisException, SparkSession}
|
||||
|
||||
class HoodieSqlParser(session: SparkSession, delegate: ParserInterface)
|
||||
class HoodieSpark2ExtendedSqlParser(session: SparkSession, delegate: ParserInterface)
|
||||
extends ParserInterface with Logging {
|
||||
|
||||
private lazy val conf = session.sqlContext.conf
|
||||
private lazy val builder = new HoodieSqlAstBuilder(conf, delegate)
|
||||
private lazy val builder = new HoodieSpark2ExtendedSqlAstBuilder(conf, delegate)
|
||||
|
||||
override def parsePlan(sqlText: String): LogicalPlan = parse(sqlText) { parser =>
|
||||
builder.visit(parser.singleStatement()) match {
|
||||
Reference in New Issue
Block a user