如何在 SnappyData 中存储数组或 Blob? [英] How to store Array or Blob in SnappyData?

查看:29
本文介绍了如何在 SnappyData 中存储数组或 Blob?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个包含两列的表格,如下所示:

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..

请帮忙!

推荐答案

有一个关于这个的公开票:https://jira.snappydata.io/browse/SNAP-1284 将在下一个版本中解决 VALUES 字符串(JSON 字符串和 Spark 兼容字符串)的问题.

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).

Spark Catalyst 兼容格式将起作用:

The Spark Catalyst compatible format will work:

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

选择时,数据默认以序列化形式发送并显示为二进制.现在你必须使用complexTypeAsJson"提示来显示为 JSON:

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.

在您的示例中可以注意到的另一件事是存储桶的主要值.这在以前的版本中被记录为首选,但从 1.0 版本开始,建议使用 2 或偶数的幂(例如,集群中的核心总数可能是一个不错的选择)——也许一些示例仍在使用较旧的建议.

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.

这篇关于如何在 SnappyData 中存储数组或 Blob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆