You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sqoop.apache.org by "Eugen Stoianovici (JIRA)" <ji...@apache.org> on 2016/01/15 12:36:39 UTC

[jira] [Created] (SQOOP-2791) Errors in import when using query with aliases as source

Eugen Stoianovici created SQOOP-2791:
----------------------------------------

             Summary: 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.

$ 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





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