davidm-db commented on code in PR #47442:
URL: https://github.com/apache/spark/pull/47442#discussion_r1701776960
##########
sql/core/src/test/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionNodeSuite.scala:
##########
@@ -77,11 +93,157 @@ class SqlScriptingExecutionNodeSuite extends SparkFunSuite
{
TestLeafStatement("three"),
TestNestedStatementIterator(Seq(TestLeafStatement("four"),
TestLeafStatement("five")))))
.getTreeIterator
- val statements = iter.map {
- case TestLeafStatement(v) => v
- case _ => fail("Unexpected statement type")
- }.toList
-
+ val statements = iter.map(extractStatementValue).toSeq
assert(statements === Seq("one", "two", "three", "four", "five"))
}
+
+ test("if else - enter body of the IF clause") {
+ val iter = TestNestedStatementIterator(Seq(
+ TestIfElse(
+ conditions = Seq(
+ TestSingleStatement("con1")
Review Comment:
@cloud-fan I did what I said in last comment - created
`evaluateBooleanCondition` in `NonLeafStatementExec` to be reused by other exec
nodes that will need to evaluate conditions (switch/case and loops) and removed
`StatementBooleanEvaluator` completely. Sorted the tests for now with dummy
`TestIfElseCondition` - will figure out the similar approach for loops, but
this seems fine I would say.
Can you please check if this is according to what you had in mind?
##########
sql/core/src/test/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionNodeSuite.scala:
##########
@@ -77,11 +93,157 @@ class SqlScriptingExecutionNodeSuite extends SparkFunSuite
{
TestLeafStatement("three"),
TestNestedStatementIterator(Seq(TestLeafStatement("four"),
TestLeafStatement("five")))))
.getTreeIterator
- val statements = iter.map {
- case TestLeafStatement(v) => v
- case _ => fail("Unexpected statement type")
- }.toList
-
+ val statements = iter.map(extractStatementValue).toSeq
assert(statements === Seq("one", "two", "three", "four", "five"))
}
+
+ test("if else - enter body of the IF clause") {
+ val iter = TestNestedStatementIterator(Seq(
+ TestIfElse(
+ conditions = Seq(
+ TestSingleStatement("con1")
Review Comment:
@cloud-fan I did what I said in last comment - created
`evaluateBooleanCondition` in `NonLeafStatementExec` to be reused by other exec
nodes that will need to evaluate conditions (switch/case and loops) and removed
`StatementBooleanEvaluator` completely. Sorted the tests for now with dummy
`TestIfElseCondition` - will figure out the similar approach for loops, but
this seems fine I would say.
Can you please check if this is conforming to what you had in mind?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]