Snowflake - COPY INTO … ignores DATE_INPUT_FORMAT setting

北城以北 提交于 2021-02-11 12:32:27

问题


The following instruction aims at using a specific format to import DATEs

alter session set DATE_INPUT_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF';

However, it seems to have no effect on the following:

copy into schema.table
    from s3://bucket/file.parquet
    credentials=(aws_key_id='...' aws_secret_key='...')
    match_by_column_name=case_insensitive
    file_format=(type=parquet);

Which results in errors like below:

sqlalchemy.exc.ProgrammingError: (snowflake.connector.errors.ProgrammingError) 100071 (22000):
Failed to cast variant value "2020-06-16 00:00:00.000" to DATE

When a column in the imported Parquet file has a format as specified above for a date field.

This really sounds like a bug, as the above COPY INTO scenario should in theory be a typical use case for altering the DATE_INPUT_FORMAT.

Is there a way to address this?


回答1:


The DATE_INPUT_FORMAT should affect the copy command. The documentation talks about not supporting a timestamp from a variant column on a date conversion.

Although TO_DATE accepts a TIMESTAMP value, it does not accept a TIMESTAMP inside a VARIANT.



来源:https://stackoverflow.com/questions/62939636/snowflake-copy-into-ignores-date-input-format-setting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!