【问题标题】:Sqoop import null values from mysql doesn't replace NullSqoop 从 mysql 导入空值不会替换 Null
【发布时间】:2017-02-18 02:55:25
【问题描述】:

在 mysql 中有一个表,其中一些列具有空值。我想 sqoop 将表导入配置单元。当我执行 sqoop 导入时,我会在 mysql 表中具有 null 的列中获取所有 null 值。

我正在做以下事情

sqoop import --connect jdbc:xxxxxx --username xxxx --password xxxx \
--query "select * from  hive_db.xxxx where \$CONDITIONS" --null-string '' \
--null-non-string '' -m 1 --hive-import --hive-database hivedatabase \
--hive-table table --as-parquetfile --create-hive-table --target-dir /user/hive/warehouse/hivedatabase.db/table

但我仍然将蜂巢列作为 Null intsead of empty

为什么会这样?我怎样才能得到想要的结果。

【问题讨论】:

    标签: mysql null hive sqoop


    【解决方案1】:

    它用于将数据作为文本文件导入以指定空值。

    解决方法可能是更改查询中的空值。根据您的数据库引擎,它可能是这样的(sql server sintax)

    --query "select isnull(columnA,''), isnull(columnB,''), etc from yourTable where $conditions”

    【讨论】:

    【解决方案2】:
    sqoop import --connect jdbc:xxxxxx --username xxxx --password xxxx \
    --query "select * from  hive_db.xxxx where \$CONDITIONS" --null-string " " \
    --null-non-string " " -m 1 --hive-import --hive-database hivedatabase \
    --hive-table table --as-parquetfile --create-hive-table --target-dir /user/hive/warehouse/hivedatabase.db/table
    

    【讨论】:

      猜你喜欢
      • 2017-07-01
      • 2017-06-13
      • 2019-08-27
      • 2018-09-17
      • 1970-01-01
      • 2017-03-10
      • 1970-01-01
      • 2014-07-23
      • 1970-01-01
      相关资源
      最近更新 更多