Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Hivecontext is providing 1 extra count than the base hive table count

Hivecontext is providing 1 extra count than the base hive table count

New Contributor

Hello Everyone,

 

when i am executing the query in hive as "select count(1) from table Table_Name" it is providing count as 100, But when i am executing same query from spark as "var RecordCount = hiveContext.sql("select count(1) from table Table_Name")" it is providing count as 101.

Please help me to resolve this issue.

 

Regards

Manoj

2 REPLIES 2

Re: Hivecontext is providing 1 extra count than the base hive table count

Champion
What version of CDH and Spark are you using?
Highlighted

Re: Hivecontext is providing 1 extra count than the base hive table count

Champion
I just tested with CDH 5.11.1 and Spark 1.6. The table I used is very simple and only has 5 records. Both systems returned the same and expected value.

This query doesn't look right thought "select count(1) from table Table_Name". It shouldn't have the 'table' keyword in it.

Note: if you include more than one valid table name in the query it will query the first table only and produce no errors.