SQOOP --where 不使用 --query
SQOOP --where is not working with --query
WHERE 子句不适用于 --where
以及 --query
sqoop import --connect "jdbc:mysql://quickstart.cloudera:3306/retail_db" --username "retail_dba" --password "cloudera" --target-dir "/user/cloudera/sqoop_import_tables/departments21" --query "select * From orders where $CONDITIONS" --where "order_id < 8000" --split-by order_id;
日志显示 "WHERE ( order_id < 8000 )" - 在 BoundingValsQuery 中忽略了条件:-
16/08/31 12:20:26 INFO db.DBInputFormat: Using read commited transaction isolation
16/08/31 12:20:26 INFO db.DataDrivenDBInputFormat: BoundingValsQuery: SELECT MIN(order_id), MAX(order_id) FROM (select * From orders where (1 = 1) ) AS t1
16/08/31 12:20:26 INFO db.IntegerSplitter: Split size: 17220; Num splits: 4 from: 1 to: 68883
16/08/31 12:20:26 DEBUG db.IntegerSplitter: Splits: [ 1 to 68,883] into 4 parts
16/08/31 12:20:26 DEBUG db.IntegerSplitter: 1
16/08/31 12:20:26 DEBUG db.IntegerSplitter: 17,222
16/08/31 12:20:26 DEBUG db.IntegerSplitter: 34,443
16/08/31 12:20:26 DEBUG db.IntegerSplitter: 51,663
16/08/31 12:20:26 DEBUG db.IntegerSplitter: 68,883
16/08/31 12:20:26 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound 'order_id >= 1' and upper bound 'order_id < 17222'
16/08/31 12:20:26 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound 'order_id >= 17222' and upper bound 'order_id < 34443'
16/08/31 12:20:26 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound 'order_id >= 34443' and upper bound 'order_id < 51663'
16/08/31 12:20:26 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound 'order_id >= 51663' and upper bound 'order_id <= 68883'
16/08/31 12:20:26 INFO mapreduce.JobSubmitter: number of splits:4
16/08/31 12:20:26 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1472622587119_0024
WHERE 子句适用于 --where
和 --table
。
sqoop import --connect "jdbc:mysql://quickstart.cloudera:3306/retail_db" --username "retail_dba" --password "cloudera" --target-dir "/user/cloudera/sqoop_import_tables/departments22" --table orders --where "order_id < 8000" --split-by order_id
日志显示 "WHERE ( order_id < 8000 )" - 满足条件。
16/08/31 12:34:35 INFO db.DataDrivenDBInputFormat: BoundingValsQuery: SELECT MIN(`order_id`), MAX(`order_id`) FROM `orders` WHERE ( order_id < 8000 )
16/08/31 12:34:35 INFO db.IntegerSplitter: Split size: 1999; Num splits: 4 from: 1 to: 7999
16/08/31 12:34:35 DEBUG db.IntegerSplitter: Splits: [ 1 to 7,999] into 4 parts
16/08/31 12:34:35 DEBUG db.IntegerSplitter: 1
16/08/31 12:34:35 DEBUG db.IntegerSplitter: 2,001
16/08/31 12:34:35 DEBUG db.IntegerSplitter: 4,001
16/08/31 12:34:35 DEBUG db.IntegerSplitter: 6,000
16/08/31 12:34:35 DEBUG db.IntegerSplitter: 7,999
16/08/31 12:34:35 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound '`order_id` >= 1' and upper bound '`order_id` < 2001'
16/08/31 12:34:35 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound '`order_id` >= 2001' and upper bound '`order_id` < 4001'
16/08/31 12:34:35 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound '`order_id` >= 4001' and upper bound '`order_id` < 6000'
16/08/31 12:34:35 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound '`order_id` >= 6000' and upper bound '`order_id` <= 7999'
16/08/31 12:34:35 INFO mapreduce.JobSubmitter: number of splits:4
- 任何逻辑原因,为什么
--where
选项不适用于 --query
而与 --table
一起使用?
- 在
--query
选项的情况下,我们如何使用--where
来提供额外的过滤?
- 感谢任何关于此的文档。
您始终可以在自由格式查询中进行过滤,例如
... --query "select ... where order_id < 8000 and $CONDITIONS" ...
当然,在这里使用 query
选项是不必要的,因为无论如何您都选择了所有行。因此,您不妨删除查询部分并包含 --where "order_id < 8000"
。
基本上,这是一个或另一个(--query
或--where
);使用两者没有意义。有关详细信息,请参阅 documentation。
您的所有其他问题都已得到解答。我正在挑选 -
why the --where
option is not working with --query
and working with --table
?
因为它会导致模棱两可的结果。
例如,
你把--where id > 100
和--query "select * from table where order_id < 100 and $CONDITIONS"
现在您希望 sqoop 达到什么效果 return?
因此,从用户的角度来看,这可能会造成混淆并导致错误的结果。
您始终可以将 WHERE 条件放在 --query
中。所以不需要 --where
标签和 --query
标签。
--where
是 --query
.
的子集
使用自由格式查询 (--query) 如果你使用 --where 它将被 sqoop 忽略。 sqoop 将优先考虑 --query....
中提到的 where 子句
WHERE 子句不适用于 --where
以及 --query
sqoop import --connect "jdbc:mysql://quickstart.cloudera:3306/retail_db" --username "retail_dba" --password "cloudera" --target-dir "/user/cloudera/sqoop_import_tables/departments21" --query "select * From orders where $CONDITIONS" --where "order_id < 8000" --split-by order_id;
日志显示 "WHERE ( order_id < 8000 )" - 在 BoundingValsQuery 中忽略了条件:-
16/08/31 12:20:26 INFO db.DBInputFormat: Using read commited transaction isolation
16/08/31 12:20:26 INFO db.DataDrivenDBInputFormat: BoundingValsQuery: SELECT MIN(order_id), MAX(order_id) FROM (select * From orders where (1 = 1) ) AS t1
16/08/31 12:20:26 INFO db.IntegerSplitter: Split size: 17220; Num splits: 4 from: 1 to: 68883
16/08/31 12:20:26 DEBUG db.IntegerSplitter: Splits: [ 1 to 68,883] into 4 parts
16/08/31 12:20:26 DEBUG db.IntegerSplitter: 1
16/08/31 12:20:26 DEBUG db.IntegerSplitter: 17,222
16/08/31 12:20:26 DEBUG db.IntegerSplitter: 34,443
16/08/31 12:20:26 DEBUG db.IntegerSplitter: 51,663
16/08/31 12:20:26 DEBUG db.IntegerSplitter: 68,883
16/08/31 12:20:26 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound 'order_id >= 1' and upper bound 'order_id < 17222'
16/08/31 12:20:26 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound 'order_id >= 17222' and upper bound 'order_id < 34443'
16/08/31 12:20:26 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound 'order_id >= 34443' and upper bound 'order_id < 51663'
16/08/31 12:20:26 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound 'order_id >= 51663' and upper bound 'order_id <= 68883'
16/08/31 12:20:26 INFO mapreduce.JobSubmitter: number of splits:4
16/08/31 12:20:26 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1472622587119_0024
WHERE 子句适用于 --where
和 --table
。
sqoop import --connect "jdbc:mysql://quickstart.cloudera:3306/retail_db" --username "retail_dba" --password "cloudera" --target-dir "/user/cloudera/sqoop_import_tables/departments22" --table orders --where "order_id < 8000" --split-by order_id
日志显示 "WHERE ( order_id < 8000 )" - 满足条件。
16/08/31 12:34:35 INFO db.DataDrivenDBInputFormat: BoundingValsQuery: SELECT MIN(`order_id`), MAX(`order_id`) FROM `orders` WHERE ( order_id < 8000 )
16/08/31 12:34:35 INFO db.IntegerSplitter: Split size: 1999; Num splits: 4 from: 1 to: 7999
16/08/31 12:34:35 DEBUG db.IntegerSplitter: Splits: [ 1 to 7,999] into 4 parts
16/08/31 12:34:35 DEBUG db.IntegerSplitter: 1
16/08/31 12:34:35 DEBUG db.IntegerSplitter: 2,001
16/08/31 12:34:35 DEBUG db.IntegerSplitter: 4,001
16/08/31 12:34:35 DEBUG db.IntegerSplitter: 6,000
16/08/31 12:34:35 DEBUG db.IntegerSplitter: 7,999
16/08/31 12:34:35 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound '`order_id` >= 1' and upper bound '`order_id` < 2001'
16/08/31 12:34:35 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound '`order_id` >= 2001' and upper bound '`order_id` < 4001'
16/08/31 12:34:35 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound '`order_id` >= 4001' and upper bound '`order_id` < 6000'
16/08/31 12:34:35 DEBUG db.DataDrivenDBInputFormat: Creating input split with lower bound '`order_id` >= 6000' and upper bound '`order_id` <= 7999'
16/08/31 12:34:35 INFO mapreduce.JobSubmitter: number of splits:4
- 任何逻辑原因,为什么
--where
选项不适用于--query
而与--table
一起使用? - 在
--query
选项的情况下,我们如何使用--where
来提供额外的过滤? - 感谢任何关于此的文档。
您始终可以在自由格式查询中进行过滤,例如
... --query "select ... where order_id < 8000 and $CONDITIONS" ...
当然,在这里使用 query
选项是不必要的,因为无论如何您都选择了所有行。因此,您不妨删除查询部分并包含 --where "order_id < 8000"
。
基本上,这是一个或另一个(--query
或--where
);使用两者没有意义。有关详细信息,请参阅 documentation。
您的所有其他问题都已得到解答。我正在挑选 -
why the
--where
option is not working with--query
and working with--table
?
因为它会导致模棱两可的结果。
例如,
你把--where id > 100
和--query "select * from table where order_id < 100 and $CONDITIONS"
现在您希望 sqoop 达到什么效果 return?
因此,从用户的角度来看,这可能会造成混淆并导致错误的结果。
您始终可以将 WHERE 条件放在 --query
中。所以不需要 --where
标签和 --query
标签。
--where
是 --query
.
使用自由格式查询 (--query) 如果你使用 --where 它将被 sqoop 忽略。 sqoop 将优先考虑 --query....
中提到的 where 子句