Skip to content
Advertisement

Got invalid expression error , while inserting JSON data into VARIANT column

Trying to insert multiple rows into a snowflake table

insert into sample_table  (a, b, c) values ('foo','bar',parse_json($${"def": 1}$$)),('doo','bam',parse_json($${"def": 1}$$));

Have tried replacing ‘$$’ with single quotes

Getting error:

SQL compilation error: Invalid expression [PARSE_JSON(‘{“def”:1}’)] in VALUES clause

What am I doing wrong?

Advertisement

Answer

You cannot use PARSE_JSON in the values section. But you can do a

create table sample_table(a text, b text, c variant);
insert into sample_table 
  select column1, column2, parse_json(column3) from values
    ('foo', 'bar', '{"def": 1}'),
    ('doo', 'bam', '{"def": 1}');
number of rows inserted
2
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement