【问题标题】:extract data in hive提取hive中的数据
【发布时间】:2017-11-21 12:00:25
【问题描述】:

我在配置单元表列中有如下数据:

customer reason=Other#customer reason free text=Space#customer type=Regular#customer end date=2020-12-31 19:50:00#customer offering criterion=0#customer type=KK#Customer factor=0.00#customer period=0#customer type=TN#customer value=0#customer plan type=M#cttype type=KK#

我想根据客户价值提取数据值 0。

我尝试了下面的查询,但它给出了完整的“客户价值=0”,但我只想要 0。 请提出建议。

select regexp_replace(regexp_extract(information,'customer period=[^#]*',0),'customer period=','') from detail;

【问题讨论】:

  • 数据有点难理解,因为这不是很常见的格式。独立行应该用“#”分隔吗?数据在字段方面是异构的吗?

标签: hive bigdata hiveql


【解决方案1】:

这个问题根本不清楚。 如果要限制输出,请使用 LIMIT 1(其中 1 是要限制的行数)

【讨论】:

    【解决方案2】:

    请试一试,

    ---建表----

    创建表ch7(custdetails map string,string>)

    行格式分隔

    以“#”终止的集合项

    以 '=' 结尾的映射键;

    ----数据加载----

    加载数据本地路径'your-file-location-in-local'覆盖到表ch7中;

    ----数据选择-----

    select custdetails["customer value"] from ch7;

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-31
      • 2019-10-27
      • 2013-03-15
      • 1970-01-01
      相关资源
      最近更新 更多