Skip to content

HIVE-29497: [HPLSQL] quit is not exiting from execution flow in HPLSQL.#6405

Open
mdayakar wants to merge 1 commit intoapache:masterfrom
mdayakar:HIVE-29497_HPLSQLIssue
Open

HIVE-29497: [HPLSQL] quit is not exiting from execution flow in HPLSQL.#6405
mdayakar wants to merge 1 commit intoapache:masterfrom
mdayakar:HIVE-29497_HPLSQLIssue

Conversation

@mdayakar
Copy link
Copy Markdown
Contributor

@mdayakar mdayakar commented Apr 2, 2026

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

} 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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');" +
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added \n at the end of the satement.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 5, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants