Kaliyug Antagonist
Kaliyug Antagonist

Reputation: 3612

Hive index error

I'm facing issues while building an index on multiple columns in a Hive(0.9.0) table.

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

This works :

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

But this doesn't :

    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

I guess the index is somehow able to recognize only the first column because even this failed :

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

I checked this issue but I don't think this is the cause.

Upvotes: 0

Views: 2861

Answers (2)

Soumen
Soumen

Reputation: 1

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

or

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

Yes, this is working

Upvotes: 0

user2637464
user2637464

Reputation: 2356

Think Hive does not support indexing on partitioned columns.. please check if comp code is a partitioned column..

As far as indexing on multiple columns, it should work..

Upvotes: 2

Related Questions