techie95
techie95

Reputation: 515

How to store Array or Blob in SnappyData?

I'm trying to create a table with two columns like below:

CREATE TABLE test (col1 INT ,col2 Array<Decimal>) USING column options(BUCKETS '5');

It is creating successfully but when i'm trying to insert data into it, it is not accepting any format of array. I've tried the following queries:

insert into test1 values(1,Array(Decimal("1"), Decimal("2")));

insert into test1 values(1,Array(1,2));

insert into test1 values(1,[1,2,1]);

insert into test1 values(1,"1,2,1");

insert into test1 values(1,<1,2,1>);

etc..

Please help!

Upvotes: 1

Views: 200

Answers (1)

Sumedh
Sumedh

Reputation: 383

There is an open ticket for this: https://jira.snappydata.io/browse/SNAP-1284 which will be addressed in next release for VALUES strings (JSON string and Spark compatible strings).

The Spark Catalyst compatible format will work:

insert into test1 select 1, array(1, 2);

When selecting the data is by default shipped in serialized form and shown as binary. For now you have to use "complexTypeAsJson" hint to show as JSON:

select * from test1 --+complexTypeAsJson(true);

Support for displaying in simpler string format by default will be added in next release.

One other thing that can be noticed in your example is a prime value for buckets. This was documented as preferred in previous releases but as of 1.0 release it is recommended to use a power of two or some even number (e.g the total number of cores in your cluster can be a good choice) -- perhaps some examples are still using the older recommendation.

Upvotes: 1

Related Questions