我有一个tsv如下(只是格式化更好的报告)在s4桶
col_1 | col_2 | col_3
2017/12/01 | 1996 | 20101201
.. | .. | ..
以上列均为DATE
类型
我创建了一个舞台来从s3
加载这个文件现在我已经创建了表
CREATE OR REPLACE TABLE
"test"
(
col_1 Date,
col_2 Date,
col_3 Date
);
现在我想把上面的csv输入到这个表
-- create file_format
create or replace file format my_file_format
type = csv
field_delimiter = '|'
skip_header = 1
-- create stage
CREATE or replace STAGE my_stage
URL='s3://xxxx/yyyy'
CREDENTIALS=(AWS_KEY_ID='XXXXXXXXXXXXXX' AWS_SECRET_KEY='YYYYY');
-- copy into
copy into "TEST"
from @my_stage
file_format = (format_name = my_file_format);
-- or insert into
insert INTO "test" (select $1,$2,$3 from @my_stage (file_format => my_file_format));
I get error
Can't parse '2017/12/01' as date with format 'AUTO'
我不能更改csv。有什么方法可以让我在摄取时提到每个颜色的日期格式。
您可以尝试使用基于值的适当日期格式吗?
insert INTO "test" (select TO_DATE($1,'YYYY/MM/DD'),TO_DATE($2,'YYYY'),
TO_DATE($3,'YYYYMMDD') from @my_stage (file_format => my_file_format));