[ 
https://issues.apache.org/jira/browse/SQOOP-2791?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jarek Jarcec Cecho updated SQOOP-2791:
--------------------------------------
    Description: 
SQOOP always fails with a syntax error when specifying an alias on the split 
column of the source query.

{code}
$ sqoop import \
  --query 'SELECT t1.i as something, t2.j FROM t1, t2 WHERE $CONDITIONS AND 
t1.i = t2.i' \
  --target-dir /user/eugen/sqoop1 \
  --split-by t1.i \
  --connect jdbc:mysql://example.com/eugen \
  --username usr1 \
  --password-file /user/eugen/sqoop.password
{code}

Results in:
{code}
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 
't1.i' in 'field list'
{code}

The query failing in this case is:
{code}
  SELECT MIN(t1.i), MAX(t1.i) FROM (SELECT t1.i as something, t2.j FROM t1, t2 
WHERE  (1 = 1)  AND t1.i = t2.i) AS t1
{code}

This is the query for generating the splits. We can rewrite the scenario to 
make this particular query successful:

{code}
sqoop import \
  --query 'SELECT t1.i as something, t2.j FROM t1, t2 WHERE $CONDITIONS AND 
t1.i = t2.i' \
  --target-dir /user/eugen/sqoop1 \
  --split-by something \
  --connect jdbc:mysql://example.com/eugen \
  --username usr1 \
  --password-file /user/eugen/sqoop.password
{code}

This results in:
{code}
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 
'something' in 'where clause'
{code}

The query failing in this case is:
{code}
  SELECT t1.i as something, t2.j FROM t1, t2 WHERE ( something >= ? ) AND ( 
something < ? ) AND t1.i = t2.i
{code}



  was:
SQOOP always fails with a syntax error when specifying an alias on the split 
column of the source query.

$ sqoop import \
  --query 'SELECT t1.i as something, t2.j FROM t1, t2 WHERE $CONDITIONS AND 
t1.i = t2.i' \
  --target-dir /user/eugen/sqoop1 \
  --split-by t1.i \
  --connect jdbc:mysql://example.com/eugen \
  --username usr1 \
  --password-file /user/eugen/sqoop.password

Results in:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 
't1.i' in 'field list'

The query failing in this case is:
  SELECT MIN(t1.i), MAX(t1.i) FROM (SELECT t1.i as something, t2.j FROM t1, t2 
WHERE  (1 = 1)  AND t1.i = t2.i) AS t1

This is the query for generating the splits. We can rewrite the scenario to 
make this particular query successful:

sqoop import \
  --query 'SELECT t1.i as something, t2.j FROM t1, t2 WHERE $CONDITIONS AND 
t1.i = t2.i' \
  --target-dir /user/eugen/sqoop1 \
  --split-by something \
  --connect jdbc:mysql://example.com/eugen \
  --username usr1 \
  --password-file /user/eugen/sqoop.password

This results in:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 
'something' in 'where clause'

The query failing in this case is:
  SELECT t1.i as something, t2.j FROM t1, t2 WHERE ( something >= ? ) AND ( 
something < ? ) AND t1.i = t2.i




> Errors in import when using query with aliases as source
> --------------------------------------------------------
>
>                 Key: SQOOP-2791
>                 URL: https://issues.apache.org/jira/browse/SQOOP-2791
>             Project: Sqoop
>          Issue Type: Bug
>          Components: codegen
>            Reporter: Eugen Stoianovici
>            Priority: Minor
>
> SQOOP always fails with a syntax error when specifying an alias on the split 
> column of the source query.
> {code}
> $ sqoop import \
>   --query 'SELECT t1.i as something, t2.j FROM t1, t2 WHERE $CONDITIONS AND 
> t1.i = t2.i' \
>   --target-dir /user/eugen/sqoop1 \
>   --split-by t1.i \
>   --connect jdbc:mysql://example.com/eugen \
>   --username usr1 \
>   --password-file /user/eugen/sqoop.password
> {code}
> Results in:
> {code}
> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 
> 't1.i' in 'field list'
> {code}
> The query failing in this case is:
> {code}
>   SELECT MIN(t1.i), MAX(t1.i) FROM (SELECT t1.i as something, t2.j FROM t1, 
> t2 WHERE  (1 = 1)  AND t1.i = t2.i) AS t1
> {code}
> This is the query for generating the splits. We can rewrite the scenario to 
> make this particular query successful:
> {code}
> sqoop import \
>   --query 'SELECT t1.i as something, t2.j FROM t1, t2 WHERE $CONDITIONS AND 
> t1.i = t2.i' \
>   --target-dir /user/eugen/sqoop1 \
>   --split-by something \
>   --connect jdbc:mysql://example.com/eugen \
>   --username usr1 \
>   --password-file /user/eugen/sqoop.password
> {code}
> This results in:
> {code}
> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 
> 'something' in 'where clause'
> {code}
> The query failing in this case is:
> {code}
>   SELECT t1.i as something, t2.j FROM t1, t2 WHERE ( something >= ? ) AND ( 
> something < ? ) AND t1.i = t2.i
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to