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

Inconsistency between Hive documentation and actual behaviors: TINYINT/SMALLINT/BIGINT lower bounds are not supported

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.1.2
    • None
    • Parser
    • None

    Description

      Describe the bug

      In Hive, we have a table where TINYINT is a part of its schema. We want to insert the lower bound of TINYINT (-128Y) into the TINYINT column of the table. We expect it to have the same behavior as the upper bound value (127Y) that can be successfully inserted into the table. However, we encountered the below exception:

      FAILED: SemanticException [Error 10029]: Line 1:27 Invalid numerical constant '128Y'

      Steps To Reproduce

      On Hive 3.1.2, execute the following:

      create table ws0(c1 TINYINT) ROW FORMAT SERDE "org.apache.hadoop.hive.serde2.avro.AvroSerDe" STORED AS INPUTFORMAT "org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat" OUTPUTFORMAT "org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat" ;
      insert into ws0 values(-128Y);

       
      We encounter the following exception while inserting the lower bound of TINYINT:

      FAILED: SemanticException [Error 10029]: Line 1:27 Invalid numerical constant '128Y'

       
      The upper bound value (127) is supported and we are able to insert 127Y. Additionally, we tried other ways to insert -128, which all worked:

      insert into ws0 values(-128);
      insert into ws0 values(cast (-128 as TINYINT));
      insert into ws0 values(cast ("-128" as TINYINT));

      Expected behavior

      The Hive Data Types documentation mentioned the lower bounds for TINYINT -128 / SMALLINT -32,768 / BIGINT -9,223,372,036,854,775,808, which are expected to be successfully inserted into tables:

      • TINYINT (1-byte signed integer, from -128 to 127)
      • SMALLINT (2-byte signed integer, from -32,768 to 32,767)
      • INT/INTEGER (4-byte signed integer, from -2,147,483,648 to 2,147,483,647)\
      • BIGINT (8-byte signed integer, from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)

      Additional context

      The lower bounds of SMALLINT / BIGINT have the same exceptions, but INT works fine.

      Attachments

        Activity

          People

            Unassigned Unassigned
            x/sys xsys
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: