gpt4 book ai didi

csv - 当我们从 s3 中的 csv 文件读取数据并在 aws athena 中创建表时如何跳过标题。

转载 作者:行者123 更新时间:2023-12-02 03:02:19 26 4
gpt4 key购买 nike

我正在尝试从 s3 存储桶读取 csv 数据并在 AWS Athena 中创建一个表。我的表在创建时无法跳过 CSV 文件的标题信息。

查询示例:

CREATE EXTERNAL TABLE IF NOT EXISTS table_name (   `event_type_id`
string, `customer_id` string, `date` string, `email` string )
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH
SERDEPROPERTIES ( "separatorChar" = "|", "quoteChar" = "\"" )
LOCATION 's3://location/'
TBLPROPERTIES ("skip.header.line.count"="1");

skip.header.line.count 似乎不起作用。但这是行不通的。我认为 Aws 对此有一些问题。还有其他方法可以解决这个问题吗?

最佳答案

这就是 Redshift 中的工作原理:

您想要使用表属性 ('skip.header.line.count'='1')如果您愿意的话,还可以与其他属性一起使用,例如'numRows'='100'。这是一个示例:

create external table exreddb1.test_table
(ID BIGINT
,NAME VARCHAR
)
row format delimited
fields terminated by ','
stored as textfile
location 's3://mybucket/myfolder/'
table properties ('numRows'='100', 'skip.header.line.count'='1');

关于csv - 当我们从 s3 中的 csv 文件读取数据并在 aws athena 中创建表时如何跳过标题。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45488792/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com