Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hplsql/src/main/java/org/apache/hive/hplsql/Stmt.java
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,7 @@ public Integer exec(HplsqlParser.Exec_stmtContext ctx) {
exec.signal(query);
return 1;
}
exec.setSqlSuccess();
try {
if (ctx.T_INTO() != null) {
int cols = ctx.L_ID().size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,19 @@ public void testQuit() throws Throwable {
OutStream.ERR);
}

@Test
public void testERRORCODEForExecuteStatements() throws Throwable {
String scriptText =
"SET hplsql.onerror='seterror';\n" +
"CREATE TABLE result (id bigint, name string);\n" +
"EXECUTE IMMEDIATE 'load data local inpath ''../../data/files/hplsql.txt'' OVERWRITE INTO table result';\n" +
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.

Is it necessary to actually load the data?

How about testing with statements like

select 1;

and

select 1/0;

"EXECUTE 'select * from unknown';\n" +
"PRINT 'First ERRORCODE: ' || errorcode\n" +
"EXECUTE 'select * from result';\n" +
"PRINT 'Second ERRORCODE: ' || errorcode";
testScriptFile(scriptText, args(), "First ERRORCODE: -1.*Second ERRORCODE: 0", OutStream.ERR);
}

private static List<String> args() {
return Arrays.asList("-d", BeeLine.BEELINE_DEFAULT_JDBC_DRIVER,
"-u", miniHS2.getBaseJdbcURL() + ";mode=hplsql", "-n", USER_NAME);
Expand Down
Loading