4

I am using Spark 2.1.0

I have a View which is owned by some other group AND we CANNOT change it as we don't own it.

create or replace view testUnderscore AS
SELECT 
lookup_id, 
source_table, 
`_c3` AS lookup_type, 
`_c5` AS transaction_type, 
start_date, 
end_date, 
`_c8` AS transaction_grp, 
`_c9` AS transaction_source
From table_1;

While creating, the view got created but when i am trying to use this view in Spark i am getting this Error :

Error in query: cannot resolve '`_c3`' given input columns:

My Query which gives above Error :

Select a,b,c
from some_table1,
testUnderscore        --(This is the View created above & bcoz of which getting error)
where some_table1.key1 = testUnderscore.lookup_id

I know that this Error is due to the Column Names starting with an 'underscore' but as i mentioned earlier we cannot change it as it is owned by some other team and also as u can see that i am not even using that _c3 column in my SQL query. Its just that when the Query parser reads through the Query it encounters the _c3 & throws Error.

So I need a help here to bypass this _c3. Like i have many columns starting with an underscore and i have to use this View in my Query , How can i escape or bypass this .??

AJm
  • 993
  • 2
  • 20
  • 39
  • Is the view in hive or spark? – uh_big_mike_boi Dec 02 '17 at 03:33
  • Can you replicate the problem by creating a dummy view with underscores in the column names and querying that view? – ayplam Dec 02 '17 at 06:15
  • Not sure but i tried creating it in HIVE with the same above syntax & name mentioned above & it got created in HIVE . But when i tried Querying in Spark as shown above gives me the Error. You can just try creating similar view on any table & then query it from Spark as 'Select * from ' – AJm Dec 02 '17 at 06:54

0 Answers0