Skip to content

Commit

Permalink
Correct the preparing of carbon analyzer with custom rules with spark…
Browse files Browse the repository at this point in the history
… analyzer
  • Loading branch information
akashrn5 committed Jun 6, 2019
1 parent 9d02092 commit 8b83773
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,35 @@ class CarbonInMemorySessionStateBuilder (sparkSession: SparkSession,

override lazy val optimizer: Optimizer = new CarbonOptimizer(catalog, conf, experimentalMethods)

override protected def analyzer: Analyzer = new CarbonAnalyzer(catalog, conf, sparkSession,
override protected def analyzer: Analyzer = {
new CarbonAnalyzer(catalog,
conf,
sparkSession,
getAnalyzer(super.analyzer))
}

/**
* This method adds carbon rules to Hive Analyzer and returns new analyzer
*
* @param analyzer SessionStateBuilder analyzer
* @return
*/
def getAnalyzer(analyzer: Analyzer): Analyzer = {
new Analyzer(catalog, conf) {

override val extendedResolutionRules: Seq[Rule[LogicalPlan]] =
new FindDataSourceTable(session) +:
new ResolveSQLOnFile(session) +:
new CarbonIUDAnalysisRule(sparkSession) +:
new CarbonPreInsertionCasts(sparkSession) +: customResolutionRules
analyzer.extendedResolutionRules ++
Seq(CarbonIUDAnalysisRule(sparkSession)) ++
Seq(CarbonPreInsertionCasts(sparkSession)) ++ customResolutionRules

override val extendedCheckRules: Seq[LogicalPlan => Unit] =
PreWriteCheck :: HiveOnlyCheck :: Nil
analyzer.extendedCheckRules

override val postHocResolutionRules: Seq[Rule[LogicalPlan]] =
PreprocessTableCreation(session) +:
PreprocessTableInsertion(conf) +:
DataSourceAnalysis(conf) +:
customPostHocResolutionRules
analyzer.postHocResolutionRules
}
)
}

override protected def newBuilder: NewBuilder = new CarbonInMemorySessionStateBuilder(_, _)
}

Original file line number Diff line number Diff line change
Expand Up @@ -236,29 +236,33 @@ class CarbonSessionStateBuilder(sparkSession: SparkSession,

override lazy val optimizer: Optimizer = new CarbonOptimizer(catalog, conf, experimentalMethods)

override protected def analyzer: Analyzer = new CarbonAnalyzer(catalog, conf, sparkSession,
override protected def analyzer: Analyzer = {
new CarbonAnalyzer(catalog,
conf,
sparkSession,
getAnalyzer(super.analyzer))
}

/**
* This method adds carbon rules to Hive Analyzer and returns new analyzer
* @param analyzer hiveSessionStateBuilder analyzer
* @return
*/
def getAnalyzer(analyzer: Analyzer): Analyzer = {
new Analyzer(catalog, conf) {

override val extendedResolutionRules: Seq[Rule[LogicalPlan]] =
new ResolveHiveSerdeTable(session) +:
new FindDataSourceTable(session) +:
new ResolveSQLOnFile(session) +:
new CarbonIUDAnalysisRule(sparkSession) +:
new CarbonPreInsertionCasts(sparkSession) +: customResolutionRules
analyzer.extendedResolutionRules ++
Seq(CarbonIUDAnalysisRule(sparkSession)) ++
Seq(CarbonPreInsertionCasts(sparkSession)) ++ customResolutionRules

override val extendedCheckRules: Seq[LogicalPlan => Unit] =
PreWriteCheck :: HiveOnlyCheck :: Nil
analyzer.extendedCheckRules

override val postHocResolutionRules: Seq[Rule[LogicalPlan]] =
new DetermineTableStats(session) +:
RelationConversions(conf, catalog) +:
PreprocessTableCreation(session) +:
PreprocessTableInsertion(conf) +:
DataSourceAnalysis(conf) +:
HiveAnalysis +:
customPostHocResolutionRules
analyzer.postHocResolutionRules
}
)
}

override protected def newBuilder: NewBuilder = new CarbonSessionStateBuilder(_, _)
}

0 comments on commit 8b83773

Please sign in to comment.