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.

Hive provides count of table without using "from" keyword

Hive provides count of table without using "from" keyword

New Contributor

Hi All,

I accidentally queried "wrong syntax" Hive SQL statement and but got output without error.

Here's the query:

select count(*) w_clm_recoverpoint_getgroupsetsoutput_history; --> No from keyword

Result

hive> select count(*) w_clm_recoverpoint_getgroupsetsoutput_history;
Query ID = hdpadmin_20180509054222_fd5bf136-6f0b-4b7b-b3bf-68a7c4ddd61f
Total jobs = 1
Launching Job 1 out of 1
Status: Running (Executing on YARN cluster with App id application_1525436078697_8838)
--------------------------------------------------------------------------------
        VERTICES      STATUS  TOTAL  COMPLETED  RUNNING  PENDING  FAILED  KILLED
--------------------------------------------------------------------------------
Map 1 ..........   SUCCEEDED      1          1        0        0       0       0
Reducer 2 ......   SUCCEEDED      1          1        0        0       0       0
--------------------------------------------------------------------------------
VERTICES: 02/02  [==========================>>] 100%  ELAPSED TIME: 3.66 s
--------------------------------------------------------------------------------
OK
1
Time taken: 10.739 seconds, Fetched: 1 row(s)


As you can see, the result shows 1.

If I provide "from" keyword, the result is 8076

So my question here now is:

1. Why it did not throw any syntax error?

2. How did I get result as 1 here?

3. My actual correct result is 8076. So it means 1 + 8075 ???

Thanks,

Shesh Kumar

2 REPLIES 2
Highlighted

Re: Hive provides count of table without using "from" keyword

HI @Shesh Kumar. It's interpreting the table as a value. You can execute "select count(*) foobar" and it will come back with 1 as a result.

Re: Hive provides count of table without using "from" keyword

New Contributor

Okay... try giving only "select count(*)" and run the query. It will still give result as 1.

So with this, we can say that its not interpreting the table as value.

Don't have an account?
Coming from Hortonworks? Activate your account here