How to store Array or Blob in SnappyData?

↘锁芯ラ 提交于 2019-12-08 04:00:38

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/47052483/how-to-store-array-or-blob-in-snappydata

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