使用presto创建嵌套表?

wecizke3  于 2021-05-27  发布在  Spark
关注(0)|答案(1)|浏览(691)

如果我有这种结构的Spark模式,

root
 |-- id: long (nullable = true)
 |-- firstname: string (nullable = true)
 |-- lastname: string (nullable = true)
 |-- orders: array (nullable = true)
 |    |-- element: struct (containsNull = true)
 |    |    |-- id: long (nullable = true)
 |    |    |-- price: double (nullable = true)
 |    |    |-- userid: long (nullable = true)

如何用这个模式创建一个表,我试着用这个查询,

CREATE TABLE iceberg.test.order (
id BIGINT,
firstName VARCHAR,
lastName VARCHAR,
orders ROW(
    id BIGINT,
    price double,
    userid BIGINT
        )
                )
WITH (
  format = 'PARQUET'
)
v2g6jxz6

v2g6jxz61#

如果要创建表。要读取s3上现有的Parquet文件,语法如下例所示。我将它改编为您正在显示的模式:orders是一个struct数组。

create external table mytable (
   id bigint,
   firstname varchar, 
   lastname varchar, 
   orders array[struct<id:bigint, price:double, userid:bigint>]
) stored as parquet
location 's3://...'

以下是更多示例:https://aws.amazon.com/blogs/big-data/create-tables-in-amazon-athena-from-nested-json-and-mappings-using-jsonserde/

相关问题