Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-21453

HPL/SQL can not SELECT Date and Timestamp type value into variable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Patch Available
    • Minor
    • Resolution: Unresolved
    • 3.1.1
    • None
    • hpl/sql
    • Centos 7.1, Hive 3.1.1

    • Resolved the issue that HPL/SQL can not SELECT Date and Timestamp type values INTO variables

    Description

      HPL/SQL forgot Date and Timestamp types when SELECT INTO variables. for example, current implement will set null, not correct value, to variables for following case,  select_into3.sql:

      declare v_date date;
      declare v_timestamp timestamp(17, 3); 

      select
        cast('2019-02-20 12:23:45.678' as date),
        cast('2019-02-20 12:23:45.678' as timestamp)
      into
        v_date,
        v_timestamp
      from src limit 1;

      print 'date: ' || v_date;
      print 'timestamp: ' || v_timestamp;

      The result when running : bin/hplsql -f select_into3.sql --trace

      Configuration file: file:/hive/conf/hplsql-site.xml
      Parser tree: (program (block (stmt (declare_stmt declare (declare_stmt_item (declare_var_item (ident v_date) (dtype date))))) (stmt (semicolon_stmt ) (stmt (declare_stmt declare (declare_stmt_item (declare_var_item (ident v_timestamp) (dtype timestamp) (dtype_len ( 17 , 3 )))))) (stmt (semicolon_stmt ) (stmt (select_stmt (fullselect_stmt (fullselect_stmt_item (subselect_stmt select (select_list (select_list_item (expr (expr_spec_func cast ( (expr (expr_atom (string '2019-02-20 12:23:45.678'))) as (dtype date) )))) , (select_list_item (expr (expr_spec_func cast ( (expr (expr_atom (string '2019-02-20 12:23:45.678'))) as (dtype timestamp) ))))) (into_clause into (ident v_date) , (ident v_timestamp)) (from_clause from (from_table_clause (from_table_name_clause (table_name (ident src))))) (select_options (select_options_item limit (expr (expr_atom (int_number 1)))))))))) (stmt (semicolon_stmt ) (stmt (print_stmt print (expr (expr_concat (expr_concat_item (expr_atom (string 'date: '))) || (expr_concat_item (expr_atom (ident v_date))))))) (stmt (semicolon_stmt ) (stmt (print_stmt print (expr (expr_concat (expr_concat_item (expr_atom (string 'timestamp: '))) || (expr_concat_item (expr_atom (ident v_timestamp))))))) (stmt (semicolon_stmt )) <EOF>)
      Ln:1 DECLARE v_date date
      Ln:2 DECLARE v_timestamp timestamp
      Ln:4 SELECT
      Ln:4 select
      cast('2019-02-20 12:23:45.678' as date), cast('2019-02-20 12:23:45.678' as timestamp)
      from src LIMIT 1
      Open connection: jdbc:vertica://v001:5433/test (256 ms)
      Starting query
      Query executed successfully (55 ms)
      Ln:4 SELECT completed successfully
      Ln:4 SELECT INTO statement executed
      Ln:4 COLUMN: ?column?, Date
      Ln:4 SET v_date = null
      Ln:4 COLUMN: ?column?, Timestamp
      Ln:4 SET v_timestamp = null
      Ln:12 PRINT
      date:
      Ln:13 PRINT
      timestamp:

      Attachments

        1. HIVE-21453.patch
          2 kB
          DingQiang Liu

        Issue Links

          Activity

            People

              dingqiangliu DingQiang Liu
              dingqiangliu DingQiang Liu
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m