You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "xsys (Jira)" <ji...@apache.org> on 2022/09/29 15:48:00 UTC

[jira] [Updated] (HIVE-26577) Inconsistency between Hive documentation and actual behaviors: TINYINT/SMALLINT/BIGINT lower bounds are not supported

     [ https://issues.apache.org/jira/browse/HIVE-26577?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

xsys updated HIVE-26577:
------------------------
    Description: 
h3. 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:
{code:java}
FAILED: SemanticException [Error 10029]: Line 1:27 Invalid numerical constant '128Y'{code}
h3. Steps To Reproduce

On [Hive 3.1.2|https://archive.apache.org/dist/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz], execute the following:
{code:java}
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);{code}
 
We encounter the following exception while inserting the lower bound of TINYINT:
{code:java}
FAILED: SemanticException [Error 10029]: Line 1:27 Invalid numerical constant '128Y'{code}
 
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:
{code:java}
insert into ws0 values(-128);
insert into ws0 values(cast (-128 as TINYINT));
insert into ws0 values(cast ("-128" as TINYINT));{code}
h3. Expected behavior

The [Hive Data Types documentation|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=27838462] 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|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-tinyint] (1-byte signed integer, from -128 to 127)
 * [SMALLINT|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-smallint] (2-byte signed integer, from -32,768 to 32,767)
 * [INT|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-int]/INTEGER (4-byte signed integer, from -2,147,483,648 to 2,147,483,647)\
 * [BIGINT|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-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.

  was:
h3. 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:
{code:java}
FAILED: SemanticException [Error 10029]: Line 1:27 Invalid numerical constant '128Y'{code}
h3. Steps To Reproduce

On [Hive 3.1.2|https://archive.apache.org/dist/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz], execute the following:

 
{code:java}
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);{code}
 
 
We encounter the following exception while inserting the lower bound of TINYINT:

 
{code:java}
FAILED: SemanticException [Error 10029]: Line 1:27 Invalid numerical constant '128Y'{code}
 
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:
{code:java}
insert into ws0 values(-128);
insert into ws0 values(cast (-128 as TINYINT));
insert into ws0 values(cast ("-128" as TINYINT));{code}
 
h3. Expected behavior

The [Hive Data Types documentation|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=27838462] 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|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-tinyint] (1-byte signed integer, from -128 to 127)
 * [SMALLINT|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-smallint] (2-byte signed integer, from -32,768 to 32,767)
 * [INT|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-int]/INTEGER (4-byte signed integer, from -2,147,483,648 to 2,147,483,647)\
 * [BIGINT|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-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.


> Inconsistency between Hive documentation and actual behaviors: TINYINT/SMALLINT/BIGINT lower bounds are not supported
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-26577
>                 URL: https://issues.apache.org/jira/browse/HIVE-26577
>             Project: Hive
>          Issue Type: Bug
>          Components: Parser
>            Reporter: xsys
>            Priority: Major
>
> h3. 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:
> {code:java}
> FAILED: SemanticException [Error 10029]: Line 1:27 Invalid numerical constant '128Y'{code}
> h3. Steps To Reproduce
> On [Hive 3.1.2|https://archive.apache.org/dist/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz], execute the following:
> {code:java}
> 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);{code}
>  
> We encounter the following exception while inserting the lower bound of TINYINT:
> {code:java}
> FAILED: SemanticException [Error 10029]: Line 1:27 Invalid numerical constant '128Y'{code}
>  
> 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:
> {code:java}
> insert into ws0 values(-128);
> insert into ws0 values(cast (-128 as TINYINT));
> insert into ws0 values(cast ("-128" as TINYINT));{code}
> h3. Expected behavior
> The [Hive Data Types documentation|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=27838462] 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|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-tinyint] (1-byte signed integer, from -128 to 127)
>  * [SMALLINT|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-smallint] (2-byte signed integer, from -32,768 to 32,767)
>  * [INT|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-int]/INTEGER (4-byte signed integer, from -2,147,483,648 to 2,147,483,647)\
>  * [BIGINT|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)