admin管理员组文章数量:1391000
I'm trying to transform and load a CSV using the COPY INTO command in Snowflake. I keep getting the SQL compilation error in the screen capture below. I've also included an image of the code. How do you address this error for a CSV file?
I'm trying to transform and load data using the COPY INTO command in Snowflake. I get the error in the screen capture.
I'm trying to transform and load a CSV using the COPY INTO command in Snowflake. I keep getting the SQL compilation error in the screen capture below. I've also included an image of the code. How do you address this error for a CSV file?
I'm trying to transform and load data using the COPY INTO command in Snowflake. I get the error in the screen capture.
Share Improve this question asked Mar 16 at 19:07 Robert CrumpRobert Crump 1 4 |1 Answer
Reset to default 0so using VALES as rows from a CSV:
select $1
from values ('col1', 'col2', 'col3');
gives:
$1 |
---|
col1 |
but:
select $1:col1
from values ('col1', 'col2', 'col3');
gives:
001044 (42P13): SQL compilation error: error line 1 at position 9
Invalid argument types for function 'GET': (VARCHAR(4), VARCHAR(4))
so you ether should accept all values are text, and name the columns:
select $1 as col1
from values ('col1', 'col2', 'col3');
or if the objects really are JSON and you are accessing subobjects use JSON_EXTRACT_PATH_TEXT for one value per object or PARSE_JSON and then access fields using the :field_name
pattern or GET explicitly.
select
JSON_EXTRACT_PATH_TEXT($1, 'col1') as col1
from values ('{"col1":"I am a col1"}', 'col2', 'col3');
COL1 |
---|
I am a col1 |
本文标签:
版权声明:本文标题:copy - Snowflake Invalid argument types for function 'GET': (VARCHAR(134217728), VARCHAR(11)) using a CSV file - 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744589024a2614367.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
$1
should be the first column, and it will be a string from CSV, because it's a pure string format. So using the JSON access pattern:EMPLOYEE_ID
is the same asget($1, 'EMPLOYEE_ID')
form, and it is correctly complaining the it does not takestring, string
as it takesvariant, string
. I suspect should drop all the:WORD
parts you are doing and then you will have success. If your format has a header section, you should be able to use the named columns from that directly. – Simeon Pilgrim Commented Mar 17 at 0:50