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

Beeline ignore where clause when it is the last line of file and missing a EOL hence give wrong query result

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.2.1
    • 1.3.0, 2.0.0
    • Beeline
    • None

    Description

      Steps to reproduce:
      Say we have a simple table:

      select * from lji.lu_test;
      +---------------+------------------+--+
      | lu_test.name  | lu_test.country  |
      +---------------+------------------+--+
      | john          | us               |
      | hong          | cn               |
      +---------------+------------------+--+
      2 rows selected (0.04 seconds)
      

      We have a simple query in a file. But note this file missing the last EOL.

      cat -A test.hql
      use lji;$
      select * from lu_test$
      where country='us';[lji@~]$
      

      Then if we execute file using both hive CLI and beeline + HS2, we have different result.

      [lji@~]$ hive -f test.hql
      WARNING: Use "yarn jar" to launch YARN applications.
      
      Logging initialized using configuration in file:/etc/hive/2.3.4.7-4/0/hive-log4j.properties
      OK
      Time taken: 1.624 seconds
      OK
      john    us
      Time taken: 1.482 seconds, Fetched: 1 row(s)
      [lji@~]$ beeline -u "jdbc:hive2://XXX:10000/default;principal=hive/_HOST@XXX" -f test.hql
      WARNING: Use "yarn jar" to launch YARN applications.
      Connecting to jdbc:hive2://XXXl:10000/default;principal=hive/_HOST@XXX
      Connected to: Apache Hive (version 1.2.1.2.3.4.7-4)
      Driver: Hive JDBC (version 1.2.1.2.3.4.7-4)
      Transaction isolation: TRANSACTION_REPEATABLE_READ
      0: jdbc:hive2://XXX> use lji;
      No rows affected (0.06 seconds)
      0: jdbc:hive2://XXX> select * from lu_test
      0: jdbc:hive2://XXX> where country='us';+---------------+------------------+--+
      | lu_test.name  | lu_test.country  |
      +---------------+------------------+--+
      | john          | us               |
      | hong          | cn               |
      +---------------+------------------+--+
      2 rows selected (0.073 seconds)
      0: jdbc:hive2://XXX>
      Closing: 0: jdbc:hive2://XXX:10000/default;principal=hive/_HOST@XXX
      

      Obviously, beeline gave the wrong result. It ignore the where clause in the last line.
      I know it is quit weird for a file missing the last EOL, but for whatever reason, we kind of having quit some files in this state.

      Attachments

        Activity

          People

            dengzh Zhihua Deng
            lji Lu Ji
            Votes:
            6 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: