【问题标题】:How to create external table on parquet file如何在镶木地板文件上创建外部表
【发布时间】:2021-03-15 08:23:33
【问题描述】:

我在 gcp 存储上有一个 parquet 文件。从简单 json {"id":1,"name":"John"} 转换的文件。

你能帮我写出正确的脚本吗?没有架构可以做到这一点吗?

create external table test (
    id         string,
    name       string
)
row format delimited
fields terminated by '\;'
stored as ?????
location '??????'
tblproperties ('skip.header.line.count'='1');

【问题讨论】:

    标签: hive parquet


    【解决方案1】:

    Hive 作为 sql 数据库,在写入模式架构中工作,因此您无法在不使用模式的情况下使用 HQL 创建表(与 NoSql 的其他情况不同,例如 Hbase 或其他情况)。我建议你使用 >= 0.14 的 Hive 版本,它更容易:

    CREATE TABLE table_name (
        string1 string,
        string2 string,
        int1 int,
        boolean1 boolean,
        long1 bigint,
        float1 float,
        double1 double,
        inner_record1 struct,
        enum1 string,
        array1 array,
        map1 map,
        union1 uniontype,
        fixed1 binary,
        null1 void,
        unionnullint int,
        bytes1 binary)
      PARTITIONED BY (ds string);
    

    【讨论】:

    • 好的,谢谢你的建议。您能否显示脚本或发送链接,如何使用 Hive 版本> = 0.14
    • 响应中的示例是针对 hive 版本的>= .14,您尝试过吗?
    • 无法理解它是如何工作的,示例没有镶木地板文件的位置
    • 只需在查询末尾添加,列名应与 parquet 中的名称相同:STORED AS PARQUET LOCATION '/path/to/parquet';
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-19
    • 2021-10-14
    • 2018-08-02
    • 2015-05-18
    • 1970-01-01
    相关资源
    最近更新 更多