Reputation: 8726
I want to import data from MsSQL to HBase running a free form query which has an alias on the key I want to split by. For example my query is:
SELECT convert(varchar,Table1.Field1) + '_' + Table2.field1 AS 'xyz'
FROM Table1
INNER JOIN Table2
ON Table1.field3 = Table2.field4
WHERE $CONDITIONS
And I want to split work units by this aliased field. So, in my sqoop query I have --split-by 'xyz'
option. But, this doesn't work. I get:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException:
Ambiguous column name 'xyz'.
So, how can I make sqoop work with this aliased select field?
Upvotes: 2
Views: 1721
Reputation: 8726
This was a limitation of SQL-Server. It doesn't allow a GROUP BY on an aliased column.
Rewriting the query in the following way helped:
SELECT xyz FROM
(
SELECT convert(varchar,Table1.Field1) + '_' + Table2.field1 AS 'xyz'
FROM Table1
INNER JOIN Table2
ON Table1.field3 = Table2.field4
) as sub
WHERE $CONDITIONS
Upvotes: 2