我在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")
选项?或者是我唯一的选择(至少目前为止)过滤掉标题行作为select语句的一部分?
答案 0 :(得分:9)
这适用于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');
答案 1 :(得分:3)
目前,AWS Redshift Spectrum不支持跳过标题行。如果可以,您可以提出支持问题,以便跟踪此功能的可用性。
可以将此请求转发给开发团队进行考虑。