dusantism-db opened a new pull request, #50090: URL: https://github.com/apache/spark/pull/50090
### What changes were proposed in this pull request? FOR statement will currently fail if it is nested in a compound statement, is the only statement in that body AND returns an empty result. For example: ``` BEGIN CREATE TABLE t (intCol INT) using parquet; REPEAT FOR SELECT * FROM t ORDER BY intCol DO SELECT intCol; END FOR; UNTIL 1 = 1 END REPEAT; END ``` throws `[INTERNAL_ERROR] No more elements to iterate through in the current SQL compound statement. SQLSTATE: XX000 ` This happens because the enclosing statement (REPEAT in this case) always expects at least one single statement in it's body which it can return. However, if the FOR has an empty result it doesn't have anything to return, and there is no other statement in the body, so the exception is thrown. In this PR, FOR is updated to return NOOP statement in this specific case. ### Why are the changes needed? To fix the bug. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Tests which were previously ignored due to this bug are no longer ignored. ### Was this patch authored or co-authored using generative AI tooling? No. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org