首页 > 解决方案 > 为什么 Hive Map 键 (i16) 在按键搜索时不能向上转换?

问题描述

有一个由 thrift 定义的 Hive 表。

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

我尝试了一些查询来搜索此表。

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

第 1:74 行 MAP 键类型与索引表达式类型“10”不匹配

以下两个返回正确的结果。

// 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

我知道10Y手段tinyint10S手段smallint,而且i16smallint

但是为什么 Hive 会使用smallinttotinyint而不是int

我认为这可能会导致一些信息丢失或数字溢出。

标签: hivehiveqlhive-query

解决方案


推荐阅读