0

在 Hive(0.9.0) 表中的多个列上构建索引时遇到问题。

describe nas_comps;
OK
leg_id  int
ds_name string
dep_date        string
crr_code        string
flight_no       string
orgn    string
dstn    string
physical_cap    int
adjusted_cap    int
closed_cap      int
comp_code       string

这有效:

CREATE INDEX nas_comps_legid ON TABLE nas_comps (leg_id) AS 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' WITH DEFERRED REBUILD;

但这不是:

    CREATE INDEX nas_comps_legid_compcode ON TABLE nas_comps (leg_id,comp_code) AS 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' WITH DEFERRED REBUILD;

FAILED: Error in metadata: java.lang.RuntimeException: Check the index columns, they should appear in the table being indexed.
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

我猜索引以某种方式只能识别第一列,因为即使这样也失败了:

CREATE INDEX nas_comps_compcode ON TABLE nas_comps (comp_code) AS 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' WITH DEFERRED REBUILD;

FAILED: Error in metadata: java.lang.RuntimeException: Check the index columns, they should appear in the table being indexed.
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

我检查了这个问题,但我认为这不是原因。

4

2 回答 2

2

Think Hive 不支持对分区列进行索引..请检查 comp 代码是否是分区列..

至于多列的索引,它应该可以工作..

于 2013-08-03T06:12:52.413 回答
0

CREATE INDEX nas_comps_legid ON TABLE nas_comps (leg_id) AS 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' WITH DEFERRED REBUILD;

或者

CREATE INDEX nas_comps_legid ON TABLE nas_comps (leg_id) AS 'compact' WITH DEFERRED REBUILD;

是的,这是有效的

于 2017-10-26T18:26:06.523 回答