更新到未加密的 kdb table

upsert into unkeyed kdb table

我正在尝试修改与提供的日期相对应的因素列中的条目。

我找不到关于 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.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

当您从输入参数定义 table 时,函数 query 中存在一个小语法错误 -

query: {[table;dates;factors] table upsert (date:dates factor:factors);}

应该是:

query:{[table;dates;factors] table upsert ([] date:dates; factor:factors);}

请注意 table 定义开头 ( 之后的附加 []。此外,列值需要用 ;

分隔
    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)