1

There is Hive table that is defined by thrift.

struct A {
    1: optional map<i16, string> myMap;
}

I have tried a few queries to search through this table.

// this one gets an error:
select myMap[10] from A where myMap[10] is not null

Line 1:74 MAP key type does not match index expression type '10'

And the following two returns the right results.

// this one works well
select myMap[10S] from A where myMap[10S] is not null

// this one works well
select myMap[10Y] from A where myMap[10Y] is not null

I know 10Y means tinyint and 10S means smallint, and i16 is smallint.

But why does Hive cast a smallint to tinyint instead of int?

I think this may cause some information loss or number overflow.

tk421
  • 5,775
  • 6
  • 23
  • 34
Hao Tan
  • 1,530
  • 2
  • 13
  • 20

0 Answers0