向上插入未对齐的kdb表
我正在尝试修改“系数”列中与提供的日期相对应的条目 我找不到任何关于KDB的upsert函数的好文档,我不知道我在这里做错了什么向上插入未对齐的kdb表,kdb,upsert,q-lang,Kdb,Upsert,Q Lang,我正在尝试修改“系数”列中与提供的日期相对应的条目 我找不到任何关于KDB的upsert函数的好文档,我不知道我在这里做错了什么 query: {[table;dates;factors] table upsert (date:dates factor:factors);} table: `test dates: (2016.01.04T01:30:00.000; 2016.01.04T01:31:00.000) factors: (0.9340078471263533; 0.934007847
query: {[table;dates;factors] table upsert (date:dates factor:factors);}
table: `test
dates: (2016.01.04T01:30:00.000; 2016.01.04T01:31:00.000)
factors: (0.9340078471263533; 0.9340078471263533)
query[table; dates; factors]
date price original factor askVol bidVol
-----------------------------------------------------------------------
....
2017.04.19T07:28:00.000 6.105 6.105 1 2.176407e+07 1.907746e+07
2017.04.19T07:29:00.000 6.105 6.105 1 2.274138e+07 1.893807e+07
2017.04.19T07:30:00.000 6.105 6.105 1 2.629207e+07 2.030017e+07
....
An error occurred during execution of the query.
The server sent the response:
type
Studio Hint: Possibly this error refers to wrong type, e.g `a+1
当您从输入参数定义表时,函数
query
中有一个小语法错误-
query: {[table;dates;factors] table upsert (date:dates factor:factors);}
应该是:
query:{[table;dates;factors] table upsert ([] date:dates; factor:factors);}
请注意,在打开
(
用于表定义)之后还有一个额外的[]
。此外,列值需要用分隔;
这很有效。谢谢!但我不完全理解其原因。是否可以给我链接一个参考?请参阅创建表的语法和
q)show table:([] dates:.z.D+til 3;factors:3?.1; something:3?`2)
dates factors something
-------------------------------
2017.04.20 0.09441671 hj
2017.04.21 0.07833686 lh
2017.04.22 0.04099561 mg
q)show factormap:(.z.D,.z.D+2)!10000.1 20000.2
2017.04.20| 10000.1
2017.04.22| 20000.2
q)update factors:factors^factormap[dates]from table
dates factors something
-------------------------------
2017.04.20 10000.1 hj
2017.04.21 0.07833686 lh
2017.04.22 20000.2 mg
q)