A Spoty Spot
A Spoty Spot

Reputation: 746

Issue Counting Rows in Hive

I have a table in Hive. When I run the following I always get 0 returned:

select count(*) from <table_name>;

Event though if I run something like:

select * from <table_name> limit 10;

I get data returned. I am on Hive 1.1.0. I believe the following two issues are related:

https://issues.apache.org/jira/browse/HIVE-11266

https://issues.apache.org/jira/browse/HIVE-7400

Is there anything I can do to workaround this issue?

Upvotes: 0

Views: 733

Answers (1)

The root cause is the old and outdated statistics of the table. Try issuing this command which should solve the problem.

ANALYZE TABLE <table_name> COMPUTE STATISTICS;

When you import the table first there may be various reasons the statistics is not updated by Hive services. I am still looking for options and properties to make it right.

Upvotes: 1

Related Questions