[ https://issues.apache.org/jira/browse/HIVE-24383?focusedWorklogId=578300&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-578300 ]
ASF GitHub Bot logged work on HIVE-24383: ----------------------------------------- Author: ASF GitHub Bot Created on: 07/Apr/21 11:40 Start Date: 07/Apr/21 11:40 Worklog Time Spent: 10m Work Description: zeroflag commented on a change in pull request #2130: URL: https://github.com/apache/hive/pull/2130#discussion_r608575321 ########## File path: hplsql/src/main/java/org/apache/hive/hplsql/Select.java ########## @@ -87,37 +94,38 @@ public Integer select(HplsqlParser.Select_stmtContext ctx) { trace(ctx, "SELECT completed successfully"); exec.setSqlSuccess(); try { - int into_cnt = getIntoCount(ctx); - if (into_cnt > 0) { - trace(ctx, "SELECT INTO statement executed"); - if (query.next()) { - for (int i = 0; i < into_cnt; i++) { - String into_name = getIntoVariable(ctx, i); - Var var = exec.findVariable(into_name); - if (var != null) { - if (var.type != Var.Type.ROW) { - var.setValue(query, i); - } else { - var.setValues(query); - } - if (trace) { - exec.trace(ctx, var, query.metadata(), i); - } - } - else { - trace(ctx, "Variable not found: " + into_name); + int intoCount = getIntoCount(ctx); + if (intoCount > 0) { + if (isBulkCollect(ctx)) { + trace(ctx, "SELECT BULK COLLECT INTO statement executed"); + long rowIndex = 1; + List<Table> tables = exec.intoTables(ctx, intoVariableNames(ctx, intoCount)); + tables.forEach(Table::removeAll); + while (query.next()) { + for (int i = 0; i < intoCount; i++) { + Table table = tables.get(i); + table.populate(query, rowIndex, i); } + rowIndex++; + } + } else { + trace(ctx, "SELECT INTO statement executed"); + if (query.next()) { + for (int i = 0; i < intoCount; i++) { + populateVariable(ctx, query, i); + } + exec.incRowCount(); + exec.setSqlSuccess(); + if (query.next()) { + exec.setSqlCode(-1422); Review comment: I added a new class for that. ########## File path: hplsql/src/main/java/org/apache/hive/hplsql/Select.java ########## @@ -155,7 +162,25 @@ else if (ctx.parent instanceof HplsqlParser.StmtContext) { } query.close(); return 0; - } + } + + private void populateVariable(HplsqlParser.Select_stmtContext ctx, QueryResult query, int columnIndex) { + String intoName = getIntoVariable(ctx, columnIndex); + Var var = exec.findVariable(intoName); + if (var != null) { + if (var.type == Var.Type.HPL_OBJECT && var.value instanceof Table) { + Table table = (Table) var.value; + table.populate(query, getIntoTableIndex(ctx, columnIndex), columnIndex); + } else if (var.type == Var.Type.ROW) { + var.setRowValues(query); + } else { + var.setValue(query, columnIndex); + } + exec.trace(ctx, var, query.metadata(), columnIndex); + } else { + trace(ctx, "Variable not found: " + intoName); Review comment: I replaced it with an exception. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 578300) Time Spent: 0.5h (was: 20m) > Add Table type to HPL/SQL > ------------------------- > > Key: HIVE-24383 > URL: https://issues.apache.org/jira/browse/HIVE-24383 > Project: Hive > Issue Type: Sub-task > Components: hpl/sql > Reporter: Attila Magyar > Assignee: Attila Magyar > Priority: Major > Labels: pull-request-available > Time Spent: 0.5h > Remaining Estimate: 0h > -- This message was sent by Atlassian Jira (v8.3.4#803005)