This is an automated email from the ASF dual-hosted git repository.

okumin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new b0fb704ac41 HIVE-29850: Remove HOST and COPY commands from HPLSQL 
(#6736)
b0fb704ac41 is described below

commit b0fb704ac41b267554ea477762f21ff9e0195d2b
Author: Dayakar M <[email protected]>
AuthorDate: Tue Sep 22 08:25:19 2026 +0530

    HIVE-29850: Remove HOST and COPY commands from HPLSQL (#6736)
    
    * HIVE-29850: Remove HOST command from HPLSQL
    
    * HIVE-29850: Remove COPY FROM LOCAL command from HPLSQL
    
    * HIVE-29850: Removed HOSTCODE from HPLSQL
    
    * HIVE-29850: Removed COPY command from HPLSQL
---
 .../main/antlr4/org/apache/hive/hplsql/Hplsql.g4   |  80 +---
 .../src/main/java/org/apache/hive/hplsql/Copy.java | 462 ---------------------
 .../src/main/java/org/apache/hive/hplsql/Exec.java | 123 ------
 .../org/apache/hive/hplsql/TestHplsqlLocal.java    |   5 -
 hplsql/src/test/queries/local/seterror.sql         |   8 -
 .../src/test/results/local/invalid_syntax.out.txt  |   2 +-
 hplsql/src/test/results/local/seterror.out.txt     |   5 -
 7 files changed, 6 insertions(+), 679 deletions(-)

diff --git a/hplsql/src/main/antlr4/org/apache/hive/hplsql/Hplsql.g4 
b/hplsql/src/main/antlr4/org/apache/hive/hplsql/Hplsql.g4
index f2f97fbd34a..ec9546d65c7 100644
--- a/hplsql/src/main/antlr4/org/apache/hive/hplsql/Hplsql.g4
+++ b/hplsql/src/main/antlr4/org/apache/hive/hplsql/Hplsql.g4
@@ -51,8 +51,6 @@ stmt :
      | collect_stats_stmt
      | close_stmt
      | cmp_stmt
-     | copy_from_local_stmt
-     | copy_stmt
      | commit_stmt
      | create_database_stmt
      | create_function_stmt
@@ -99,8 +97,6 @@ stmt :
      | while_stmt
      | unconditional_loop_stmt
      | label
-     | hive     
-     | host
      | null_stmt
      | expr_stmt     
      | semicolon_stmt      // Placed here to allow null statements ;;...       
   
@@ -642,36 +638,7 @@ cmp_stmt :              // CMP statement
 cmp_source :
       (table_name where_clause? | T_OPEN_P select_stmt T_CLOSE_P) (T_AT 
qident)?
      ;
-     
-copy_from_local_stmt :  // COPY FROM LOCAL statement
-       T_COPY T_FROM T_LOCAL copy_source (T_COMMA copy_source)* T_TO 
copy_target copy_file_option*
-     ;
-     
-copy_stmt :             // COPY statement
-       T_COPY (table_name | T_OPEN_P select_stmt T_CLOSE_P) T_TO T_HDFS? 
copy_target copy_option*
-     ;
-     
-copy_source :
-       (file_name | expr) 
-     ;
 
-copy_target :
-       (file_name | expr) 
-     ;
-    
-copy_option :
-       T_AT qident
-     | T_BATCHSIZE expr
-     | T_DELIMITER expr
-     | T_SQLINSERT qident
-     ;
-
-copy_file_option :
-       T_DELETE
-     | T_IGNORE
-     | T_OVERWRITE
-     ;
-     
 commit_stmt :           // COMMIT statement
        T_COMMIT T_WORK?
      ;
@@ -1195,30 +1162,7 @@ expr_file :
        file_name
      | expr
      ;
-      
-hive :
-       T_HIVE hive_item*
-     ;
 
-hive_item :
-       T_SUB qident expr
-     | T_SUB qident L_ID T_EQUAL expr
-     | T_SUB qident
-     ;  
-
-host :     
-       '!' host_cmd  ';'                   // OS command
-     | host_stmt
-     ;
-
-host_cmd :     
-       .*?          
-     ;
-     
-host_stmt :     
-       T_HOST expr          
-     ;
-     
 file_name :
        L_FILE | ('/' | '.' '/')? qident ('/' qident)*
      ;
@@ -1277,7 +1221,6 @@ non_reserved_words :                      // Tokens that 
are not reserved words
      | T_AT
      | T_AUTO_INCREMENT
      | T_AVG
-     | T_BATCHSIZE
      | T_BEGIN   
      | T_BETWEEN
      | T_BIGINT  
@@ -1307,8 +1250,7 @@ non_reserved_words :                      // Tokens that 
are not reserved words
      | T_COLUMN
      | T_COMMENT  
      | T_COMPRESS     
-     | T_CONSTANT     
-     | T_COPY
+     | T_CONSTANT
      | T_COMMIT
      | T_CONCAT
      | T_CONDITION
@@ -1344,7 +1286,6 @@ non_reserved_words :                      // Tokens that 
are not reserved words
      | T_DEFINITION
      | T_DELETE
      | T_DELIMITED
-     | T_DELIMITER
      | T_DENSE_RANK
      | T_DESC   
      | T_DESCRIBE 
@@ -1393,10 +1334,7 @@ non_reserved_words :                      // Tokens that 
are not reserved words
      | T_GROUP        
      | T_HANDLER      
      | T_HASH
-     | T_HAVING       
-     | T_HDFS
-     | T_HIVE         
-     | T_HOST    
+     | T_HAVING
      | T_IDENTITY     
      | T_IF    
      | T_IGNORE     
@@ -1535,8 +1473,7 @@ non_reserved_words :                      // Tokens that 
are not reserved words
      | T_SMALLDATETIME
      | T_SMALLINT     
      | T_SQL
-     | T_SQLEXCEPTION 
-     | T_SQLINSERT
+     | T_SQLEXCEPTION
      | T_SQLSTATE
      | T_SQLWARNING  
      | T_STATS
@@ -1606,8 +1543,7 @@ T_ASC             : A S C ;
 T_ASSOCIATE       : A S S O C I A T E ; 
 T_AT              : A T ;
 T_AUTO_INCREMENT  : A U T O '_' I N C R E M E N T ;
-T_AVG             : A V G ; 
-T_BATCHSIZE       : B A T C H S I Z E ;
+T_AVG             : A V G ;
 T_BEGIN           : B E G I N ;
 T_BETWEEN         : B E T W E E N ; 
 T_BIGINT          : B I G I N T ;
@@ -1644,7 +1580,6 @@ T_CONCAT          : C O N C A T;
 T_CONDITION       : C O N D I T I O N ;
 T_CONSTRAINT      : C O N S T R A I N T ; 
 T_CONTINUE        : C O N T I N U E ;
-T_COPY            : C O P Y ;
 T_COUNT           : C O U N T ;
 T_COUNT_BIG       : C O U N T '_' B I G;
 T_CREATE          : C R E A T E ;
@@ -1669,8 +1604,7 @@ T_DEFINED         : D E F I N E D ;
 T_DEFINER         : D E F I N E R ;
 T_DEFINITION      : D E F I N I T I O N ; 
 T_DELETE          : D E L E T E ;
-T_DELIMITED       : D E L I M I T E D ; 
-T_DELIMITER       : D E L I M I T E R ; 
+T_DELIMITED       : D E L I M I T E D ;
 T_DESC            : D E S C ;
 T_DESCRIBE        : D E S C R I B E ; 
 T_DIAGNOSTICS     : D I A G N O S T I C S ;
@@ -1718,9 +1652,6 @@ T_GROUP           : G R O U P ;
 T_HANDLER         : H A N D L E R ;
 T_HASH            : H A S H ;
 T_HAVING          : H A V I N G ;
-T_HDFS            : H D F S ; 
-T_HIVE            : H I V E ;
-T_HOST            : H O S T ;
 T_IDENTITY        : I D E N T I T Y ; 
 T_IF              : I F ;
 T_IGNORE          : I G N O R E ; 
@@ -1859,7 +1790,6 @@ T_SMALLDATETIME   : S M A L L D A T E T I M E ;
 T_SMALLINT        : S M A L L I N T ;
 T_SQL             : S Q L ; 
 T_SQLEXCEPTION    : S Q L E X C E P T I O N ;
-T_SQLINSERT       : S Q L I N S E R T ;
 T_SQLSTATE        : S Q L S T A T E ;
 T_SQLWARNING      : S Q L W A R N I N G ;
 T_STATS           : S T A T S ; 
diff --git a/hplsql/src/main/java/org/apache/hive/hplsql/Copy.java 
b/hplsql/src/main/java/org/apache/hive/hplsql/Copy.java
deleted file mode 100644
index e0d9cf327a6..00000000000
--- a/hplsql/src/main/java/org/apache/hive/hplsql/Copy.java
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * 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;
-
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.math.RoundingMode;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.text.DecimalFormat;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.antlr.v4.runtime.ParserRuleContext;
-import org.apache.commons.lang3.StringEscapeUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hive.hplsql.executor.QueryExecutor;
-import org.apache.hive.hplsql.executor.QueryResult;
-
-public class Copy {
-  
-  Exec exec;
-  Timer timer = new Timer();
-  boolean trace = false;
-  boolean info = false;
-  
-  long srcSizeInBytes = 0;
-  
-  String delimiter = "\t";
-  boolean sqlInsert = false;
-  String sqlInsertName;
-  String targetConn;
-  int batchSize = 1000;
-  
-  boolean overwrite = false;
-  boolean delete = false;
-  boolean ignore = false;
-  private QueryExecutor queryExecutor;
-
-  Copy(Exec e, QueryExecutor queryExecutor) {
-    exec = e;
-    trace = exec.getTrace();
-    info = exec.getInfo();
-    this.queryExecutor = queryExecutor;
-  }
-  
-  /**
-   * Run COPY command
-   */
-  Integer run(HplsqlParser.Copy_stmtContext ctx) {
-    trace(ctx, "COPY");
-    initOptions(ctx);
-    StringBuilder sql = new StringBuilder();
-    if (ctx.table_name() != null) {
-      String table = evalPop(ctx.table_name()).toString();
-      sql.append("SELECT * FROM ");
-      sql.append(table); 
-    }
-    else {
-      sql.append(evalPop(ctx.select_stmt()).toString());
-      if (trace) {
-        trace(ctx, "Statement:\n" + sql);
-      }
-    }
-    QueryResult query = queryExecutor.executeQuery(sql.toString(), ctx);
-    if (query.error()) { 
-      exec.signal(query);
-      return 1;
-    }    
-    exec.setSqlSuccess();
-    try {
-      if (targetConn != null) {
-        copyToTable(ctx, query);
-      }
-      else {
-        copyToFile(ctx, query);
-      }
-    } catch (Exception e) {
-      exec.signal(e);
-      return 1;
-    } finally {
-      query.close();
-    }
-    return 0;
-  }
-    
-  /**
-   * Copy the query results to another table
-   * @throws Exception 
-   */
-  void copyToTable(HplsqlParser.Copy_stmtContext ctx, QueryResult query) 
throws Exception {
-    int cols = query.columnCount();
-    int rows = 0;
-    if (trace) {
-      trace(ctx, "SELECT executed: " + cols + " columns");
-    } 
-    Connection conn = exec.getConnection(targetConn);
-    StringBuilder sql = new StringBuilder();
-    sql.append("INSERT INTO " + sqlInsertName + " VALUES (");
-    for (int i = 0; i < cols; i++) {
-      sql.append("?");
-      if (i + 1 < cols) {
-        sql.append(",");
-      }
-    }
-    sql.append(")");
-    PreparedStatement ps = conn.prepareStatement(sql.toString());
-    long start = timer.start();
-    long prev = start;
-    boolean batchOpen = false;
-    while (query.next()) {
-      for (int i = 0; i < cols; i++) {
-        ps.setObject(i, query.column(i, Object.class));
-      }
-      rows++;
-      if (batchSize > 1) {
-        ps.addBatch();
-        batchOpen = true;
-        if (rows % batchSize == 0) {
-          ps.executeBatch();
-          batchOpen = false;
-        }        
-      }
-      else {
-        ps.executeUpdate();
-      }      
-      if (trace && rows % 100 == 0) {
-        long cur = timer.current();
-        if (cur - prev > 10000) {
-          trace(ctx, "Copying rows: " + rows + " (" + rows/((cur - 
start)/1000) + " rows/sec)");
-          prev = cur;
-        }
-      }
-    }
-    if (batchOpen) {
-      ps.executeBatch();
-    }
-    ps.close();
-    exec.returnConnection(targetConn, conn);
-    exec.setRowCount(rows);
-    long elapsed = timer.stop();
-    if (info) {
-      DecimalFormat df = new DecimalFormat("#,##0.00");
-      df.setRoundingMode(RoundingMode.HALF_UP);
-      info(ctx, "COPY completed: " + rows + " row(s), " + timer.format() + ", 
" + df.format(rows/(elapsed/1000.0)) + " rows/sec");
-    }
-  }
-  
-  /**
-   * Copy the query results to a file
-   * @throws Exception 
-   */
-  void copyToFile(HplsqlParser.Copy_stmtContext ctx, QueryResult query) throws 
Exception {
-    String filename = null;
-    if (ctx.copy_target().expr() != null) {
-      filename = evalPop(ctx.copy_target().expr()).toString();
-    }
-    else {
-      filename = ctx.copy_target().getText();
-    }
-    byte[] del = delimiter.getBytes();
-    byte[] rowdel = "\n".getBytes();
-    byte[] nullstr = "NULL".getBytes();
-    int cols = query.columnCount();
-    int rows = 0;
-    long bytes = 0;
-    if (trace || info) {
-      String mes = "Query executed: " + cols + " columns, output file: " + 
filename;
-      if (trace) {
-        trace(ctx, mes);
-      }
-      else {
-        info(ctx, mes);
-      }
-    } 
-    java.io.File file = null;
-    File hdfsFile = null;
-    if (ctx.T_HDFS() == null) {
-      file = new java.io.File(filename);
-    }
-    else {
-      hdfsFile = new File();
-    }     
-    OutputStream out = null;
-    timer.start();
-    try {      
-      if (file != null) {
-        if (!file.exists()) {
-          file.createNewFile();
-        }
-        out = new FileOutputStream(file, false /*append*/);
-      }
-      else {
-        out = hdfsFile.create(filename, true /*overwrite*/);
-      }
-      String col;
-      String sql = "";
-      if (sqlInsert) {
-        sql = "INSERT INTO " + sqlInsertName + " VALUES (";
-        rowdel = ");\n".getBytes();
-      }
-      while (query.next()) {
-        if (sqlInsert) {
-          out.write(sql.getBytes());
-        }
-        for (int i = 0; i < cols; i++) {
-          if (i > 0) {
-            out.write(del);
-            bytes += del.length;
-          }
-          col = query.column(i, String.class);
-          if (col != null) {
-            if (sqlInsert) {
-              col = Utils.quoteString(col);
-            }
-            byte[] b = col.getBytes();
-            out.write(b);
-            bytes += b.length;
-          }
-          else if (sqlInsert) {
-            out.write(nullstr);
-          }
-        }
-        out.write(rowdel);
-        bytes += rowdel.length;
-        rows++;
-      }
-      exec.setRowCount(rows);
-    }
-    finally {
-      if (out != null) {
-        out.close();
-      }
-    }
-    long elapsed = timer.stop();
-    if (info) {
-      DecimalFormat df = new DecimalFormat("#,##0.00");
-      df.setRoundingMode(RoundingMode.HALF_UP);
-      info(ctx, "COPY completed: " + rows + " row(s), " + 
Utils.formatSizeInBytes(bytes) + ", " + timer.format() + ", " + 
df.format(rows/(elapsed/1000.0)) + " rows/sec");
-    }
-  }
-  
-  /**
-   * Run COPY FROM LOCAL statement
-   */
-  public Integer runFromLocal(HplsqlParser.Copy_from_local_stmtContext ctx) { 
-    trace(ctx, "COPY FROM LOCAL");
-    initFileOptions(ctx.copy_file_option());
-    HashMap<String, Pair<String, Long>> srcFiles = new HashMap<>();
-    String src = evalPop(ctx.copy_source(0)).toString();
-    String dest = evalPop(ctx.copy_target()).toString();
-    int srcItems = ctx.copy_source().size();
-    for (int i = 0; i < srcItems; i++) {
-      createLocalFileList(srcFiles, evalPop(ctx.copy_source(i)).toString(), 
null);
-    }
-    if (info) {
-      info(ctx, "Files to copy: " + srcFiles.size() + " (" + 
Utils.formatSizeInBytes(srcSizeInBytes) + ")");
-    }
-    if (srcFiles.size() == 0) {
-      exec.setHostCode(2);
-      return 2;
-    }
-    timer.start();
-    File file = new File();
-    FileSystem fs;
-    int succeed = 0;
-    int failed = 0;
-    long copiedSize = 0;
-    try {
-      fs = file.createFs();
-      boolean multi = false;
-      if (srcFiles.size() > 1) {
-        multi = true;
-      }
-      for (Map.Entry<String, Pair<String, Long>> i : srcFiles.entrySet()) {
-        try {
-          Path s = new Path(i.getKey());           
-          Path d;
-          if (multi) {
-            String relativePath = i.getValue().getLeft();
-            if (relativePath == null) {
-              d = new Path(dest, s.getName());
-            }
-            else {
-              d = new Path(dest, relativePath + Path.SEPARATOR + s.getName()); 
-            }
-          }
-          else {
-            // Path to file is specified (can be relative), so treat target as 
a file name (hadoop fs -put behavior)
-            if (srcItems == 1 && i.getKey().endsWith(src)) {
-              d = new Path(dest);
-            }
-            // Source directory is specified, so treat the target as a 
directory 
-            else {
-              d = new Path(dest + Path.SEPARATOR + s.getName());
-            }
-          }
-          fs.copyFromLocalFile(delete, overwrite, s, d);
-          succeed++;
-          long size = i.getValue().getRight();
-          copiedSize += size;
-          if (info) {
-            info(ctx, "Copied: " + file.resolvePath(d) + " (" + 
Utils.formatSizeInBytes(size) + ")");
-          }
-        }
-        catch(IOException e) {
-          failed++;
-          if (!ignore) {
-            throw e;
-          }
-        }
-      }
-    }
-    catch(IOException e) {
-      exec.signal(e);
-      exec.setHostCode(1);
-      return 1;
-    }
-    finally {
-      long elapsed = timer.stop();
-      if (info) {
-        info(ctx, "COPY completed: " + succeed + " succeed, " + failed + " 
failed, " + 
-              timer.format() + ", " + Utils.formatSizeInBytes(copiedSize) + ", 
" +
-              Utils.formatBytesPerSec(copiedSize, elapsed));
-      }
-      if (failed == 0) {
-        exec.setHostCode(0);
-      }
-      else {
-        exec.setHostCode(1);
-      }
-      file.close();
-    }
-    return 0; 
-  }
-  
-  /**
-   * Create the list of local files for the specified path (including 
subdirectories)
-   */
-  void createLocalFileList(HashMap<String, Pair<String, Long>> list, String 
path, String relativePath) {
-    java.io.File file = new java.io.File(path);
-    if (file.exists()) {
-      if (file.isDirectory()) {
-        for (java.io.File i : file.listFiles()) {
-          if (i.isDirectory()) {
-            String rel;
-            if (relativePath == null) {
-              rel = i.getName();
-            }
-            else {
-              rel = relativePath + java.io.File.separator + i.getName(); 
-            }
-            createLocalFileList(list, i.getAbsolutePath(), rel);
-          }
-          else {
-            long size = i.length();
-            list.put(i.getAbsolutePath(), Pair.of(relativePath, size));
-            srcSizeInBytes += size;
-          }
-        }
-      }
-      else {
-        long size = file.length();
-        list.put(file.getAbsolutePath(), Pair.of(relativePath, size));
-        srcSizeInBytes += size;
-      }
-    }
-  }
-  
-  /**
-   * Initialize COPY command options
-   */
-  void initOptions(HplsqlParser.Copy_stmtContext ctx) {
-    int cnt = ctx.copy_option().size();
-    for (int i = 0; i < cnt; i++) {
-      HplsqlParser.Copy_optionContext option = ctx.copy_option(i);
-      if (option.T_DELIMITER() != null) {
-        delimiter = 
StringEscapeUtils.unescapeJava(evalPop(option.expr()).toString());
-      }
-      else if (option.T_SQLINSERT() != null) {
-        sqlInsert = true;
-        delimiter = ", ";
-        if (option.qident() != null) {
-          sqlInsertName = option.qident().getText();
-        }
-      }
-      else if (option.T_AT() != null) {
-        targetConn = option.qident().getText();
-        if (ctx.copy_target().expr() != null) {
-          sqlInsertName = evalPop(ctx.copy_target().expr()).toString();
-        }
-        else {
-          sqlInsertName = ctx.copy_target().getText();
-        }
-      }
-      else if (option.T_BATCHSIZE() != null) {
-        batchSize = evalPop(option.expr()).intValue();
-      }
-    }
-  }
-  
-  /**
-   * Initialize COPY FILE options
-   */
-  void initFileOptions(List<HplsqlParser.Copy_file_optionContext> options) {
-    srcSizeInBytes = 0;
-    for (HplsqlParser.Copy_file_optionContext i : options) {
-      if (i.T_OVERWRITE() != null) {
-        overwrite = true;
-      }
-      else if (i.T_DELETE() != null) {
-        delete = true;
-      }
-      else if (i.T_IGNORE() != null) {
-        ignore = true;
-      }
-    }
-  }
- 
-  /**
-   * Evaluate the expression and pop value from the stack
-   */
-  Var evalPop(ParserRuleContext ctx) {
-    exec.visit(ctx);
-    if (!exec.stack.isEmpty()) { 
-      return exec.stackPop();
-    }
-    return Var.Empty;
-  }
-
-  /**
-   * Trace and information
-   */
-  public void trace(ParserRuleContext ctx, String message) {
-    exec.trace(ctx, message);
-  }
-  
-  public void info(ParserRuleContext ctx, String message) {
-    exec.info(ctx, message);
-  }
-}
diff --git a/hplsql/src/main/java/org/apache/hive/hplsql/Exec.java 
b/hplsql/src/main/java/org/apache/hive/hplsql/Exec.java
index 62f067f346b..d8aac452d32 100644
--- a/hplsql/src/main/java/org/apache/hive/hplsql/Exec.java
+++ b/hplsql/src/main/java/org/apache/hive/hplsql/Exec.java
@@ -102,7 +102,6 @@ public class Exec extends HplsqlBaseVisitor<Integer> 
implements Closeable {
   public static final String ERRORCODE = "ERRORCODE";
   public static final String SQLCODE = "SQLCODE";
   public static final String SQLSTATE = "SQLSTATE";
-  public static final String HOSTCODE = "HOSTCODE";
 
   Exec exec;
   private IMetaStoreClient msc;
@@ -745,16 +744,6 @@ public void setSqlState(String sqlstate) {
   public void setResultListener(ResultListener resultListener) {
     select.setResultListener(resultListener);
   }
-
-  /**
-   * Set HOSTCODE
-   */
-  public void setHostCode(int code) {
-    Var var = findVariable(HOSTCODE);
-    if (var != null) {
-      var.setValue(Long.valueOf(code));
-    }
-  }
   
   /**
    * Set successful execution for SQL
@@ -869,7 +858,6 @@ public void init() {
     addVariable(new Var(ERRORCODE, Var.Type.BIGINT, 0L));
     addVariable(new Var(SQLCODE, Var.Type.BIGINT, 0L));
     addVariable(new Var(SQLSTATE, Var.Type.STRING, "00000"));
-    addVariable(new Var(HOSTCODE, Var.Type.BIGINT, 0L)); 
     for (Map.Entry<String, String> v : arguments.getVars().entrySet()) {
       addVariable(new Var(v.getKey(), Var.Type.STRING, v.getValue()));
     }
@@ -1405,22 +1393,6 @@ public Integer 
visitCmp_stmt(HplsqlParser.Cmp_stmtContext ctx) {
     return new Cmp(exec, queryExecutor).run(ctx);
   }
   
-  /**
-   * COPY statement
-   */
-  @Override 
-  public Integer visitCopy_stmt(HplsqlParser.Copy_stmtContext ctx) { 
-    return new Copy(exec, queryExecutor).run(ctx);
-  }
-
-  /**
-   * COPY FROM LOCAL statement
-   */
-  @Override 
-  public Integer 
visitCopy_from_local_stmt(HplsqlParser.Copy_from_local_stmtContext ctx) { 
-    return new Copy(exec, queryExecutor).runFromLocal(ctx);
-  }
-  
   /**
    * DECLARE HANDLER statement
    */
@@ -2283,101 +2255,6 @@ public Integer 
visitDelete_stmt(HplsqlParser.Delete_stmtContext ctx) {
   public Integer visitMerge_stmt(HplsqlParser.Merge_stmtContext ctx) { 
     return stmt.merge(ctx); 
   }
-    
-  /**
-   * Run a Hive command line
-   */
-  @Override 
-  public Integer visitHive(@NotNull HplsqlParser.HiveContext ctx) { 
-    trace(ctx, "HIVE");      
-    ArrayList<String> cmd = new ArrayList<>();
-    cmd.add("hive");    
-    Var params = new Var(Var.Type.STRINGLIST, cmd);
-    stackPush(params);
-    visitChildren(ctx);
-    stackPop();    
-    try { 
-      String[] cmdarr = new String[cmd.size()];
-      cmd.toArray(cmdarr);
-      if(trace) {
-        trace(ctx, "HIVE Parameters: " + Utils.toString(cmdarr, ' '));      
-      }     
-      if (!offline) {
-        Process p = Runtime.getRuntime().exec(cmdarr);      
-        new StreamGobbler(p.getInputStream(), console).start();
-        new StreamGobbler(p.getErrorStream(), console).start();
-        int rc = p.waitFor();      
-        if (trace) {
-          trace(ctx, "HIVE Process exit code: " + rc);      
-        } 
-      }
-    } catch (Exception e) {
-      setSqlCode(SqlCodes.ERROR);
-      signal(Signal.Type.SQLEXCEPTION, e.getMessage(), e);
-      return -1;
-    }    
-    return 0; 
-  }
-  
-  @Override 
-  @SuppressWarnings("unchecked")
-  public Integer visitHive_item(HplsqlParser.Hive_itemContext ctx) { 
-    Var params = stackPeek();
-    ArrayList<String> a = (ArrayList<String>)params.value;
-    String param = ctx.getChild(1).getText();
-    switch (param) {
-      case "e":
-        a.add("-e");
-        a.add(evalPop(ctx.expr()).toString());
-        break;
-      case "f":
-        a.add("-f");
-        a.add(evalPop(ctx.expr()).toString());
-        break;
-      case "hiveconf":
-        a.add("-hiveconf");
-        a.add(ctx.L_ID().toString() + "=" + evalPop(ctx.expr()).toString());
-        break;
-    }
-    return 0;
-  }
-  
-  /**
-   * Executing OS command
-   */
-  @Override 
-  public Integer visitHost_cmd(HplsqlParser.Host_cmdContext ctx) { 
-    trace(ctx, "HOST");      
-    execHost(ctx, ctx.start.getInputStream().getText(
-        new org.antlr.v4.runtime.misc.Interval(ctx.start.getStartIndex(), 
ctx.stop.getStopIndex())));                
-    return 0; 
-  }
-  
-  @Override 
-  public Integer visitHost_stmt(HplsqlParser.Host_stmtContext ctx) { 
-    trace(ctx, "HOST");      
-    execHost(ctx, evalPop(ctx.expr()).toString());                
-    return 0; 
-  }
-  
-  public void execHost(ParserRuleContext ctx, String cmd) { 
-    try { 
-      if (trace) {
-        trace(ctx, "HOST Command: " + cmd);      
-      } 
-      Process p = Runtime.getRuntime().exec(cmd);      
-      new StreamGobbler(p.getInputStream(), console).start();
-      new StreamGobbler(p.getErrorStream(), console).start();
-      int rc = p.waitFor();      
-      if (trace) {
-        trace(ctx, "HOST Process exit code: " + rc);      
-      }
-      setHostCode(rc);
-    } catch (Exception e) {
-      setHostCode(1);
-      signal(Signal.Type.SQLEXCEPTION);
-    }        
-  }
   
   /**
    * Standalone expression (as a statement)
diff --git a/hplsql/src/test/java/org/apache/hive/hplsql/TestHplsqlLocal.java 
b/hplsql/src/test/java/org/apache/hive/hplsql/TestHplsqlLocal.java
index 14c67417cbf..05330964f6b 100644
--- a/hplsql/src/test/java/org/apache/hive/hplsql/TestHplsqlLocal.java
+++ b/hplsql/src/test/java/org/apache/hive/hplsql/TestHplsqlLocal.java
@@ -333,11 +333,6 @@ public void testReturn() throws Exception {
     run("return");
   }
 
-  @Test
-  public void testSetError() throws Exception {
-    run("seterror");
-  }
-
   @Test
   public void testSub() throws Exception {
     run("sub");
diff --git a/hplsql/src/test/queries/local/seterror.sql 
b/hplsql/src/test/queries/local/seterror.sql
deleted file mode 100644
index 666fbfda253..00000000000
--- a/hplsql/src/test/queries/local/seterror.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-BEGIN
-HOST 'abcd';
-IF HOSTCODE <> 0 THEN
-  PRINT 'Correct';
-END IF;
-EXCEPTION WHEN OTHERS THEN
-  PRINT 'FAILED';
-END
\ No newline at end of file
diff --git a/hplsql/src/test/results/local/invalid_syntax.out.txt 
b/hplsql/src/test/results/local/invalid_syntax.out.txt
index 26eba40e305..e87914deaa8 100644
--- a/hplsql/src/test/results/local/invalid_syntax.out.txt
+++ b/hplsql/src/test/results/local/invalid_syntax.out.txt
@@ -1,3 +1,3 @@
 Syntax error at line 1:27 no viable alternative at input 'b,'
-Syntax error at line 1:27 mismatched input ',' expecting {<EOF>, '@', '#', 
'!', T_ACTION, T_ADD2, T_ALL, T_ALLOCATE, T_ALTER, T_AND, T_ANSI_NULLS, 
T_ANSI_PADDING, T_AS, T_ASC, T_ASSOCIATE, T_AT, T_AUTO_INCREMENT, T_AVG, 
T_BATCHSIZE, T_BEGIN, T_BETWEEN, T_BIGINT, T_BINARY_DOUBLE, T_BINARY_FLOAT, 
T_BIT, T_BODY, T_BREAK, T_BULK, T_BY, T_BYTE, T_CALL, T_CALLER, T_CASCADE, 
T_CASE, T_CASESPECIFIC, T_CAST, T_CHAR, T_CHARACTER, T_CHARSET, T_CLIENT, 
T_CLOSE, T_CLUSTERED, T_CMP, T_COLLECT, T_COLLE [...]
+Syntax error at line 1:27 mismatched input ',' expecting {<EOF>, '@', '#', 
T_ACTION, T_ADD2, T_ALL, T_ALLOCATE, T_ALTER, T_AND, T_ANSI_NULLS, 
T_ANSI_PADDING, T_AS, T_ASC, T_ASSOCIATE, T_AT, T_AUTO_INCREMENT, T_AVG, 
T_BEGIN, T_BETWEEN, T_BIGINT, T_BINARY_DOUBLE, T_BINARY_FLOAT, T_BIT, T_BODY, 
T_BREAK, T_BULK, T_BY, T_BYTE, T_CALL, T_CALLER, T_CASCADE, T_CASE, 
T_CASESPECIFIC, T_CAST, T_CHAR, T_CHARACTER, T_CHARSET, T_CLIENT, T_CLOSE, 
T_CLUSTERED, T_CMP, T_COLLECT, T_COLLECTION, T_COLUMN, T [...]
 Ln:1 identifier 'CREATE' must be declared.
diff --git a/hplsql/src/test/results/local/seterror.out.txt 
b/hplsql/src/test/results/local/seterror.out.txt
deleted file mode 100644
index 37816f2c64e..00000000000
--- a/hplsql/src/test/results/local/seterror.out.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Ln:2 HOST
-Ln:2 HOST Command: abcd
-Ln:6 EXCEPTION HANDLER
-Ln:7 PRINT
-FAILED

Reply via email to