简体   繁体   English

DolphinDB 中使用 TSDB 引擎创建分区表失败:必须为 TSDB 引擎指定排序键

[英]Failed to create a partitioned table using TSDB engine in DolphinDB: The sort keys must be specified for TSDB engine

I wrote this script to create a partitioned table using a TSDB storage engine in DolphinDB.我编写此脚本是为了在 DolphinDB 中使用 TSDB 存储引擎创建分区表。

dbName = "dfs://tsdb_value_int"
n = 10000
t = table(n:n, [`int,`long,`short,`float,`double,`string,`char,`bool,`timestamp], [INT, LONG, SHORT,FLOAT, DOUBLE, STRING, CHAR, BOOL, TIMESTAMP])
pt1 = db.createPartitionedTable(table=t, tableName=`pt1, partitionColumns=`int,compressMethods=dict(`timestamp`long,`delta`delta),keepDuplicates=ALL)

It raises an exception:它引发了一个异常:

The sort keys must be specified for TSDB engine.

How can I create a partitioned table in DolphinDB?如何在 DolphinDB 中创建分区表?

To use the TSDB storage engine, you must specify sortColumns of function createPartitionedTable .要使用 TSDB 存储引擎,您必须指定 function createPartitionedTable的 sortColumns。 The TSDB engine maintains an index based on the order of sort columns, so you can specify those frequently-queried columns as sort columns. TSDB引擎根据排序列的顺序维护一个索引,因此您可以将那些经常查询的列指定为排序列。

dbName = "dfs://tsdb_value_int"
if(existsDatabase(dbName)){
dropDatabase(dbName)
}
db = database(directory=dbName, partitionType=VALUE, partitionScheme=1..10,engine="TSDB")
n = 10000
t = table(n:n, [`int,`long,`short,`float,`double,`string,`char,`bool,`timestamp], [INT, LONG, SHORT,FLOAT, DOUBLE, STRING, CHAR, BOOL, TIMESTAMP])
pt1 = db.createPartitionedTable(table=t, tableName=`pt1, partitionColumns=`int,compressMethods=dict(`timestamp`long,`delta`delta),sortColumns=`short`int, keepDuplicates=ALL)
t[`int] = rand(100,n)
t[`long] = rand(100000l,n)
t[`short] = rand(10h,n)
t[`float] = rand(100.0f,n)
t[`double] = rand(100.0,n)
t[`string] = rand("A"+string(1..1000),n)
t[`char] = rand(100,n)
t[`bool] = rand([true,false],n)
tem = 2012.06.13T13:30:10.000
ts = array(timestamp,0,n)
for(i in 1..n){
tem=temporalAdd(tem, 1, `s)
ts.append!(tem)
 }
t[`timestamp] = ts
pt1.append!(t)

See createPartitionedTable — DolphinDB 2.0 documentation for details.有关详细信息,请参阅createPartitionedTable — DolphinDB 2.0 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM