2

I have been trying to load array column data to neo4j from snowflake but it is loaded as a string instead of an array.

I am using apoc.load.jdbc command to connect snowflake and trying to retrieve array column.

WITH "jdbc:snowflake://xxxx.xxxx.xxxx.com:xxx/?user=xxxxxxxxxxx&password=xxxxxxxxxxx&db=xxxx&warehouse=xxxx&schema=xxxx" as url CALL apoc.load.jdbc(url,"select array_column from TABLE') YIELD row create (c:arraytest) set c=row

Neo4j Output:

(:arraytest {array_column: "[
  \"55232d8cac\"
]"})

I want to load as an array instead of a string like below:

(:arraytest {array_column: ["55232d8cac"]})

Is there any way to load as an array to neo4j as mentioned above?

VarYaz
  • 119
  • 2
  • 12

1 Answers1

0

The Snowflake JDBC driver does not support the getArray method:

https://github.com/snowflakedb/snowflake-jdbc/blob/520584ee0ee77888319f39dbd75aaec3a8c393e3/src/main/java/net/snowflake/client/jdbc/SnowflakeBaseResultSet.java#L1314

You can get the array as a string using the to_varchar() function and use something in Neo4J to parse it as an array:

create temp table T1 (A array);
insert into T1 select array_construct(1, 2, 3);
select to_varchar(A) from T1;  -- Returns [1,2,3] in string form
Greg Pavlik
  • 10,089
  • 2
  • 12
  • 29