HIVE-29497: [HPLSQL] quit is not exiting from execution flow in HPLSQL.#6405
HIVE-29497: [HPLSQL] quit is not exiting from execution flow in HPLSQL.#6405mdayakar wants to merge 1 commit intoapache:masterfrom
Conversation
a5826b8 to
7209d60
Compare
| } else if (sig.exception != null) { | ||
| console.printError("HPL/SQL error: " + ExceptionUtils.getStackTrace(sig.exception)); | ||
| } else if (sig.type == Signal.Type.LEAVE_PROGRAM) { | ||
| console.printError("Leaving Program: " + sig.value); |
There was a problem hiding this comment.
If we encounter a LEAVE_PROGRAM, does it always mean an ERROR? From the added test it looks like .QUIT was intentional, and so maybe shouldn't write to the error stream? Could this impact production code where a customer could treat error output as failure?
What are your thoughts on this?
There was a problem hiding this comment.
I don't think it will make any difference, anyway both will be written on the beeline console. Here user explicitly calling QUIT so I also feel it can't be written on the error stream so changed accordingly.
| " PRINT 'Error detected. Exiting...';\n" + | ||
| " .QUIT ERRORCODE;\n" + | ||
| "END IF;\n" + | ||
| "INSERT INTO def VALUES('Tbl2 Not Exists');" + |
There was a problem hiding this comment.
nit: not required but if you're adding anything to the PR, consider adding a \n for consistency.
PS: nit: Also not required, but sonar is recommending a text block instead of concatenating strings, and it would certainly improve readablity.
There was a problem hiding this comment.
Added \n at the end of the satement.
7209d60 to
fc1fe4e
Compare
|



HIVE-29497: [HPLSQL] quit is not exiting from execution flow in HPLSQL.
What changes were proposed in this pull request?
When .QUIT statement is executed through HPLSQL it will add a signal LEAVE_PROGRAM to the signal stack but later that signal is not getting handled due to that the HPLSQL script is not getting exited, its continuing the execution with other statements which is not correct. As part of the fix, now we are handling LEAVE_PROGRAM signal before executing any further statements that means exiting from the execution.
Why are the changes needed?
The changes fix the issue reported in HIVE-29497.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Test added in TestHplSqlViaBeeLine.java
mvn test -Dtest=TestHplSqlViaBeeLine#testQuit -pl itests/hive-unit -Pitests