sqoop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Abraham Elmahrek (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SQOOP-1204) Issue with Sqoop column aliases
Date Tue, 01 Jul 2014 18:24:26 GMT

    [ https://issues.apache.org/jira/browse/SQOOP-1204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14049152#comment-14049152
] 

Abraham Elmahrek commented on SQOOP-1204:
-----------------------------------------

The following seem to work as expected:
{code}
sqoop import --connect jdbc:mysql://localhost/myisamtest --username root --password hue -e
'SELECT c.id AS cid, concat(c.firstname, c.lastname) AS name FROM aliases c WHERE $CONDITIONS'
--target-dir /tmp/sqoop1 -m 1
{code}
{code}
sqoop import --connect jdbc:mysql://localhost/myisamtest --username root --password hue -e
'SELECT c.id, concat(c.firstname, c.lastname) AS name FROM aliases c WHERE $CONDITIONS' --target-dir
/tmp/sqoop1 --split-by id
{code}

I think the above examples have a few errors in them:
# $CONDITIONS are missing in the free-form query.
# -m 1 or --split-by are missing.

I think it will be difficult to rectify given Sqoop will not be able to split by cid since
the WHERE clause can be evaluated before the column value has been determined.

Is there any other misbehavior that you're seeing?  What do you mean by "The above query gets
me the data as required and but one of the column aliases is incorrect"? Sqoop should only
care about column names/aliases for distributing the import process and resolving data types.

> Issue with Sqoop column aliases
> -------------------------------
>
>                 Key: SQOOP-1204
>                 URL: https://issues.apache.org/jira/browse/SQOOP-1204
>             Project: Sqoop
>          Issue Type: Bug
>    Affects Versions: 1.4.4
>         Environment: Linux
>            Reporter: Prashanth Babu
>            Assignee: Prashanth Babu
>
> I came across an issue in Sqoop v1.4.4 import for column aliases. I remember it was present
even in earlier versions [I first saw this issue in v1.2.0 dating back to mid-2011].
> Consider a Sqoop import:
> {{sqoop import --connect jdbc:mysql://my_ip/my_db --username root --password **** --query
"SELECT c.id AS cid, concat(c.firstname, c.lastname) AS name FROM customer c LIMIT 10"}}
> The above query gets me the data as required and but one of the column aliases is incorrect
[instead of cid, it shows the column alias as id].
> id            name
> I have found a workaround [though it is not elegant per-se]
> {{sqoop import --connect jdbc:mysql://my_ip/my_db --username root --password **** --query
"SELECT concat(c.id, ‘’) AS cid, concat(c.firstname, c.lastname) AS name FROM customer
c LIMIT 10"}}
> The above query gets me the data as required and with the exact column aliases I have
mentioned.
> cid          name
> If I am getting just the column, Sqoop does not consider the column alias. And if I give
a function like {{concat}} as above, it considers the column alias as well.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message