[ https://issues.apache.org/jira/browse/HIVE-24383?focusedWorklogId=577033&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-577033 ]
ASF GitHub Bot logged work on HIVE-24383: ----------------------------------------- Author: ASF GitHub Bot Created on: 05/Apr/21 19:07 Start Date: 05/Apr/21 19:07 Worklog Time Spent: 10m Work Description: mustafaiman commented on a change in pull request #2130: URL: https://github.com/apache/hive/pull/2130#discussion_r607247615 ########## 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: Can we consolidate known error codes into a class/enum with meaningful variable names? I would like to be able to search for the error code in a known location and understand what is going on when debugging in the future. Similarly we should be able to search within the IDE which code paths can possibly cause a given error code. ########## File path: hplsql/src/main/java/org/apache/hive/hplsql/Stmt.java ########## @@ -961,6 +987,22 @@ public Integer forRange(HplsqlParser.For_range_stmtContext ctx) { return 0; } + public Integer unconditionalLoop(HplsqlParser.Unconditional_loop_stmtContext ctx) { + trace(ctx, "UNCONDITIONAL LOOP - ENTERED"); + String label = exec.labelPop(); + while (true) { + exec.enterScope(Scope.Type.LOOP); + visit(ctx.block()); + exec.leaveScope(); + if (canContinue(label)) { + continue; + } + break; Review comment: can be simplified ``` if (!canContinue(label)) { break; } ``` ########## 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: Seems like we ignore unknown variables. Shouldn't we fail fast when such thing happens? ########## File path: hplsql/src/main/java/org/apache/hive/hplsql/Var.java ########## @@ -26,13 +26,14 @@ import org.apache.hive.hplsql.executor.QueryResult; + Review comment: leftover blank line ########## File path: hplsql/src/main/java/org/apache/hive/hplsql/objects/HplClass.java ########## @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hive.hplsql.objects; + +public interface HplClass { + HplObject instantiate(); Review comment: Shouldn't this be newInstance(). We create a new instance of HplClass, we do not instantiate the HplClass. -- 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: 577033) Time Spent: 20m (was: 10m) > 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: 20m > Remaining Estimate: 0h > -- This message was sent by Atlassian Jira (v8.3.4#803005)