Cyrus
Cyrus

Reputation: 1032

'<EOF>' in subquery source in Hive query

I am running a query on Hive similar to:

SELECT *
FROM (SELECT a
      FROM b
      WHERE
      sex = 'M'
      AND   degree = 'Bs'
      AND   age = 15
      AND   name LIKE 'L%'
      );

the error is:

cannot recognize input near '<EOF>' '<EOF>' '<EOF>' in subquery source

Upvotes: 22

Views: 25554

Answers (2)

a m Sreekanth
a m Sreekanth

Reputation: 390

Adding a table alias for your subquery is necessary for Hive. Below I use 't1' as the alias:

SELECT *
FROM (SELECT a
  FROM b
  WHERE
  sex = 'M'
  AND   degree = 'Bs'
  AND   age = 15
  AND   name LIKE 'L%'
  ) t1 ;

Upvotes: 40

Abay Bektursun
Abay Bektursun

Reputation: 93

All the down-votes are unjustified. Hive often does not produce correct error and throws lazy "EOF" at you. In this case you just need to specify table alias for your sub-query. SELECT * FROM (.....) tbl_alias

Upvotes: 6

Related Questions