【问题标题】:Trino Create table from JsonTrino 从 Json 创建表
【发布时间】:2021-07-26 00:49:48
【问题描述】:

我正在尝试在 Trino 上创建一个表 使用 Hive 连接器将 Json 作为数据源。

create table if not exists test.json_table
(
    "timestamp" STRING,
    "header" array[STRUCT<id:STRING, type:STRING, name:STRING, timestamp:STRING, name2:STRING, version:STRING>],
    "data" array[STRUCT<subtype:STRING, acc_number:STRING>]
)
WITH (
  external_location = 's3a://path/json-file',
  format = 'JSON'
);

这在 Trino 中不起作用。由于语法似乎与 Presto / Athena 不同。

谁能给点建议!谢谢

【问题讨论】:

  • 您遇到的错误是什么?如果可能的话,还为您的问题发布一些示例 JSON 记录

标签: json trino


【解决方案1】:

设法解决了这个问题。

如果您有其他方法可以进行 SerDe,请分享

CREATE TABLE IF NOT EXISTS test.data(
    timestamp varchar, 
    header ROW(id varchar, type VARCHAR, client varchar)
    )
 WITH (
 format='json',
 external_location='s3a://path/json-file'
 );

然后使用 header.id ,例如 header.type 查询您的数据。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-28
    • 2022-01-24
    • 2022-10-30
    相关资源
    最近更新 更多