Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql AWS Athena-使用“创建为选择”时添加新列_Sql_Amazon Web Services_Presto_Amazon Athena - Fatal编程技术网

Sql AWS Athena-使用“创建为选择”时添加新列

Sql AWS Athena-使用“创建为选择”时添加新列,sql,amazon-web-services,presto,amazon-athena,Sql,Amazon Web Services,Presto,Amazon Athena,我想在现有表的基础上创建一个新表,但要有一些新的/附加的列。 在AWS雅典娜如何做到这一点?目前看起来就是这样,但它抱怨new\u id不在源表中(显然) 如果不存在“dst_订单”,则创建表格 使用(format='PARQUET',PARQUET_compression='SNAPPY',partitioned_by=ARRAY['new_id','year','month','day',外部位置='s3://dev bucket/api/dst/dst_orders/')作为 选择帐单地址

我想在现有表的基础上创建一个新表,但要有一些新的/附加的列。 在AWS雅典娜如何做到这一点?目前看起来就是这样,但它抱怨
new\u id
不在源表中(显然)

如果不存在“dst_订单”,则创建表格
使用(format='PARQUET',PARQUET_compression='SNAPPY',partitioned_by=ARRAY['new_id','year','month','day',外部位置='s3://dev bucket/api/dst/dst_orders/')作为
选择帐单地址,
总价,
uuid,
小时,

新的\u id,您需要为查询提供列类型和名称

假设新字段是
int

不要指定
new\u id
(因为它不存在),而是使用
0作为新的\u id


这将创建一个名为
new\u id
的列,类型为
int
。由于您已使用NOT DATA指定了
,因此零将不会被存储--它只是用来帮助识别列类型。

首先创建表,然后将数据插入表中。正是因为如此,“无数据”
CREATE TABLE IF NOT EXISTS "dst_orders"
WITH ( format='PARQUET', parquet_compression='SNAPPY', partitioned_by=ARRAY['new_id','year','month','day'], external_location = 's3://dev-bucket/api/dst/dst_orders/') AS
SELECT billing_address,
        totalprice,
        uuid,
        hour,
        new_id, <== This is the new column I need, also in 'partitioned_by'
        year,
        month,
        day
FROM "src_orders"
WITH NO DATA