Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
miland-db committed Jul 26, 2024
1 parent 6a37dcc commit fa82a44
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ class CompoundBodyExec(
statement.reset() // Clear all flags and result
handler.reset()
curr = Some(handler.getHandlerBody)
// return handler.getHandlerBody
}
}
statement
Expand Down Expand Up @@ -217,7 +216,6 @@ class CompoundBodyExec(
private var localIterator: Iterator[CompoundStatementExec] = statements.iterator
private var curr: Option[CompoundStatementExec] =
if (localIterator.hasNext) Some(localIterator.next()) else None
private var prev: Option[CompoundStatementExec] = None
private var stopIteration: Boolean = false // hard stop iteration flag

def getTreeIterator: Iterator[CompoundStatementExec] = treeIterator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,33 @@ class SqlScriptingInterpreterSuite extends SparkFunSuite with SharedSparkSession
)
verifySqlScriptResult(sqlScript, expected)
}

test("chained begin end blocks") {
val sqlScript =
"""
|BEGIN
| BEGIN
| SELECT 1;
| SELECT 2;
| END;
| BEGIN
| SELECT 3;
| SELECT 4;
| END;
| BEGIN
| SELECT 5;
| SELECT 6;
| END;
|END
|""".stripMargin
val expected = Seq(
Array(Row(1)), // select
Array(Row(2)), // select
Array(Row(3)), // select
Array(Row(4)), // select
Array(Row(5)), // select
Array(Row(6)) // select
)
verifySqlScriptResult(sqlScript, expected)
}
}

0 comments on commit fa82a44

Please sign in to comment.