Sqoop --where多条件过滤配置求助(Oracle到Hadoop数据导入)
解决方法
直接在原有的--where参数中用AND拼接新增的过滤条件即可,无需改用--query参数。
原脚本片段示例
sqoop import \ --connect jdbc:oracle:thin:@//oracle-host:1521/ORCL \ --username your_username \ --password your_password \ --table your_oracle_table \ --where "date='2024-05-20'" \ --target-dir /hdfs/path/your_hadoop_table \ --delete-target-dir
修改后的脚本片段示例
sqoop import \ --connect jdbc:oracle:thin:@//oracle-host:1521/ORCL \ --username your_username \ --password your_password \ --table your_oracle_table \ --where "date='2024-05-20' AND status='Active'" \ --target-dir /hdfs/path/your_hadoop_table \ --delete-target-dir
额外说明
如果date字段是Oracle的日期类型,需确保日期格式匹配Oracle的要求,比如可以用TO_DATE函数规范格式:
--where "date=TO_DATE('2024-05-20','YYYY-MM-DD') AND status='Active'"
内容的提问来源于stack exchange,提问作者aruntheimperfect
相关产品推荐
相关产品推荐

