2017-10-06 8 views
0

MySQL에서 아래와 같은 쿼리를 사용합니다. 나는 원하는 결과를 얻고있다.sqoop 가져 오기가 올바른 SQL 쿼리에 대해 잘못된 결과를 나타냅니다.

select TABLE_NAME,count(column_name) as no_of_columns from information_schema.columns where TABLE_SCHEMA = 'testing' and TABLE_NAME NOT REGEXP 'temp|bkup|RemoveMe|test' group by TABLE_NAME 

sqoop import 문에서 동일한 쿼리를 사용하면 결과가 달라집니다.

sqoop 수입 신고서는 아래에 있습니다.

sqoop import --connect jdbc:mysql://xxxxxx:3306/information_schema --username xxxxx --password-file /user/xxxxx/passwds/mysql.file --query "select TABLE_NAME,count(column_name) as no_of_columns from information_schema.columns where TABLE_SCHEMA = 'testing' and TABLE_NAME NOT REGEXP 'temp|bkup|RemoveMe|test' group by TABLE_NAME and \$CONDITIONS" -m 1 --target-dir /user/hive/warehouse/xxxx.db/testing_columns --outdir /home/xxxxx/logs/outdir 

왜 이런 일이 내가 결과를 원하는받을하기 위해 어떻게해야

+0

전체 콘솔 출력을 제공 할 수 있습니까? – Shubhangi

답변

1

$CONDITIONS 토큰은 WHERE 절에 있어야합니다 :

sqoop import --connect jdbc:mysql://xxxxxx:3306/information_schema \ 
    --username xxxxx --password-file /user/xxxxx/passwds/mysql.file \ 
    --query "select TABLE_NAME,count(column_name) as no_of_columns \ 
       from information_schema.columns \ 
       where TABLE_SCHEMA = 'testing' \ 
       and TABLE_NAME NOT REGEXP 'temp|bkup|RemoveMe|test' \ 
       and \$CONDITIONS \ 
       group by TABLE_NAME" \ 
    -m 1 --target-dir /user/hive/warehouse/xxxx.db/testing_columns \ 
    --outdir /home/xxxxx/logs/outdir 

는 또한 그 Sqoop User Guide에 따라 고려 :

현재 v에서 자유형 쿼리를 사용하는 기능 Sqoop 의 수렴은 WHERE 절에 모호한 투영 및 OR 조건이없는 간단한 쿼리로 제한됩니다. 모호한 투영으로 이어지는 하위 쿼리 나 조인이있는 쿼리로 같은 복잡한 쿼리를 사용하면 예기치 않은 결과가 발생할 수 있습니다.