Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Update name to be SqlScripting*
  • Loading branch information
miland-db committed Nov 13, 2024
commit c27dcc754471cd68c8a14509a5f7bb291a9f1a06
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ class AstBuilder extends DataTypeAstBuilder
}

override def visitSingleCompoundStatement(ctx: SingleCompoundStatementContext): CompoundBody = {
val labelCtx = new ScriptingLabelContext()
val labelCtx = new SqlScriptingLabelContext()
visitBeginEndCompoundBlockImpl(ctx.beginEndCompoundBlock(), labelCtx)
}

private def visitCompoundBodyImpl(
ctx: CompoundBodyContext,
label: Option[String],
allowVarDeclare: Boolean,
labelCtx: ScriptingLabelContext): CompoundBody = {
labelCtx: SqlScriptingLabelContext): CompoundBody = {
val buff = ListBuffer[CompoundPlanStatement]()
ctx.compoundStatements.forEach(
compoundStatement => buff += visitCompoundStatementImpl(compoundStatement, labelCtx))
Expand Down Expand Up @@ -187,7 +187,7 @@ class AstBuilder extends DataTypeAstBuilder

private def visitBeginEndCompoundBlockImpl(
ctx: BeginEndCompoundBlockContext,
labelCtx: ScriptingLabelContext): CompoundBody = {
labelCtx: SqlScriptingLabelContext): CompoundBody = {
val labelText =
labelCtx.enterLabeledScope(Option(ctx.beginLabel()), Option(ctx.endLabel()))
val body = visitCompoundBodyImpl(
Expand All @@ -202,7 +202,7 @@ class AstBuilder extends DataTypeAstBuilder

private def visitCompoundStatementImpl(
ctx: CompoundStatementContext,
labelCtx: ScriptingLabelContext): CompoundPlanStatement =
labelCtx: SqlScriptingLabelContext): CompoundPlanStatement =
withOrigin(ctx) {
Option(ctx.statement().asInstanceOf[ParserRuleContext])
.orElse(Option(ctx.setStatementWithOptionalVarKeyword().asInstanceOf[ParserRuleContext]))
Expand Down Expand Up @@ -235,7 +235,7 @@ class AstBuilder extends DataTypeAstBuilder

private def visitIfElseStatementImpl(
ctx: IfElseStatementContext,
labelCtx: ScriptingLabelContext): IfElseStatement = {
labelCtx: SqlScriptingLabelContext): IfElseStatement = {
IfElseStatement(
conditions = ctx.booleanExpression().asScala.toList.map(boolExpr => withOrigin(boolExpr) {
SingleStatement(
Expand All @@ -254,7 +254,7 @@ class AstBuilder extends DataTypeAstBuilder

private def visitWhileStatementImpl(
ctx: WhileStatementContext,
labelCtx: ScriptingLabelContext): WhileStatement = {
labelCtx: SqlScriptingLabelContext): WhileStatement = {
val labelText =
labelCtx.enterLabeledScope(Option(ctx.beginLabel()), Option(ctx.endLabel()))
val boolExpr = ctx.booleanExpression()
Expand All @@ -272,7 +272,7 @@ class AstBuilder extends DataTypeAstBuilder

private def visitSearchedCaseStatementImpl(
ctx: SearchedCaseStatementContext,
labelCtx: ScriptingLabelContext): CaseStatement = {
labelCtx: SqlScriptingLabelContext): CaseStatement = {
val conditions = ctx.conditions.asScala.toList.map(boolExpr => withOrigin(boolExpr) {
SingleStatement(
Project(
Expand Down Expand Up @@ -300,7 +300,7 @@ class AstBuilder extends DataTypeAstBuilder

private def visitSimpleCaseStatementImpl(
ctx: SimpleCaseStatementContext,
labelCtx: ScriptingLabelContext): CaseStatement = {
labelCtx: SqlScriptingLabelContext): CaseStatement = {
// uses EqualTo to compare the case variable(the main case expression)
// to the WHEN clause expressions
val conditions = ctx.conditionExpressions.asScala.toList.map(expr => withOrigin(expr) {
Expand Down Expand Up @@ -330,7 +330,7 @@ class AstBuilder extends DataTypeAstBuilder

private def visitRepeatStatementImpl(
ctx: RepeatStatementContext,
labelCtx: ScriptingLabelContext): RepeatStatement = {
labelCtx: SqlScriptingLabelContext): RepeatStatement = {
val labelText =
labelCtx.enterLabeledScope(Option(ctx.beginLabel()), Option(ctx.endLabel()))
val boolExpr = ctx.booleanExpression()
Expand Down Expand Up @@ -406,7 +406,7 @@ class AstBuilder extends DataTypeAstBuilder

private def visitLoopStatementImpl(
ctx: LoopStatementContext,
labelCtx: ScriptingLabelContext): LoopStatement = {
labelCtx: SqlScriptingLabelContext): LoopStatement = {
val labelText =
labelCtx.enterLabeledScope(Option(ctx.beginLabel()), Option(ctx.endLabel()))
val body = visitCompoundBodyImpl(ctx.compoundBody(), None, allowVarDeclare = false, labelCtx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ object ParserUtils extends SparkParserUtils {
}
}

class ScriptingLabelContext {
class SqlScriptingLabelContext {
/** Set to keep track of labels seen so far */
private val seenLabels = Set[String]()

Expand Down