【问题标题】:Skipping header rows in AWS Redshift External Tables跳过 AWS Redshift 外部表中的标题行
【发布时间】:2017-12-16 22:54:45
【问题描述】:

我在 S3 中有一个文件,其中包含以下数据:

name,age,gender
jill,30,f
jack,32,m

还有一个红移external table 使用spectrum 查询该数据:

create external table spectrum.customers ( 
 "name" varchar(50),
 "age" int,
 "gender" varchar(1))
row format delimited
fields terminated by ','
lines terminated by \n'
stored as textfile 
location 's3://...';

查询数据时,我得到以下结果:

select * from spectrum.customers;
name,age,g
jill,30,f
jack,32,m

是否有一种优雅的方法可以跳过作为外部表定义的一部分的标题行,类似于 Hive 中的 tblproperties ("skip.header.line.count"="1") 选项?或者是我唯一的选择(至少现在)作为选择语句的一部分过滤掉标题行?

【问题讨论】:

    标签: amazon-web-services amazon-redshift amazon-redshift-spectrum


    【解决方案1】:

    回答于:How to skip headers when we are reading data from a csv file in s3 and creating a table in aws athena.

    这适用于 Redshift:

    你想使用table properties ('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');
    

    【讨论】:

    【解决方案2】:

    目前,AWS Redshift Spectrum 不支持跳过标题行。如果可以,您可以提出支持问题,以便跟踪此功能的可用性。

    可以将此请求转发给开发团队以供考虑。

    【讨论】:

    • 看看@TheWalkingData 的回答 - 现在有可能(可能是同时添加的)。
    猜你喜欢
    • 2018-03-09
    • 2018-09-26
    • 2019-08-19
    • 2013-03-23
    • 1970-01-01
    • 1970-01-01
    • 2021-07-07
    • 2017-11-23
    • 1970-01-01
    相关资源
    最近更新 更多