Kdb 表转换,表作为目录列表

Kdb 表转换,表作为目录列表,kdb,k,Kdb,K,请通过以下路径帮助我进行t1转换: t1:enlist `a`b!1 2; t2:exec val from ([]val:t1); -3!t1 // +`a`b!(,1;,2) -3!t2 // ,`a`b!1 2 t1~t2[;] // 1b 我希望第二行(exec)返回与t1相同的对象,但事实并非如此。出于某种原因,只有[;]从t2获取t1 那么,第2行和第5行发生了什么(以及为什么发生) UPD 为什么登记如此富有成效?它为每个元素创建登记,并翻转整个对象 -3!enli

请通过以下路径帮助我进行
t1
转换:

t1:enlist `a`b!1 2;
t2:exec val from ([]val:t1);
-3!t1    // +`a`b!(,1;,2)
-3!t2    // ,`a`b!1 2
t1~t2[;] // 1b
我希望第二行(
exec
)返回与
t1
相同的对象,但事实并非如此。出于某种原因,只有
[;]
t2
获取
t1

那么,第2行和第5行发生了什么(以及为什么发生)


UPD 为什么
登记
如此富有成效?它为每个元素创建登记,并翻转整个对象

-3!enlist `a`b!1 2           // +`a`b!(,1;,2)
-3!enlist each `a`b!1 2      //  `a`b!(,1;,2)
-3!flip enlist each `a`b!1 2 // +`a`b!(,1;,2)

我认为这里发生的事情是,当一个表成为一个表的列时,(一致性)字典列表的特殊提升本质上是“撤消”的。它可以追溯到字典列表,就好像它们是不一致的,尽管终端仍然错误地显示它,就好像它是一张表。要看到这个,请考虑这个例子:

/promoted to table
q)-3!(`a`b!4 5;`a`b!1 2)
"+`a`b!(4 1;5 2)"
/still a table (embedded)
q)-3!enlist(`a`b!4 5;`a`b!1 2)
",+`a`b!(4 1;5 2)"
/still a table (embedded)
q)-3!(1#`val)!enlist(`a`b!4 5;`a`b!1 2)
"(,`val)!,+`a`b!(4 1;5 2)"
/no longer a table, now a list of dictionaries
q)-3!flip(1#`val)!enlist(`a`b!4 5;`a`b!1 2)
"+(,`val)!,(`a`b!4 5;`a`b!1 2)"
/extracting the column gives an "un-promoted" list of dictionaries
q)-3!exec val from flip(1#`val)!enlist(`a`b!4 5;`a`b!1 2)
"(`a`b!4 5;`a`b!1 2)"
/even though there are two of them and they both have type 99h, it is not a table
q)count exec val from flip(1#`val)!enlist(`a`b!4 5;`a`b!1 2)
2
q)type each exec val from flip(1#`val)!enlist(`a`b!4 5;`a`b!1 2)
99 99h
q)type exec val from flip(1#`val)!enlist(`a`b!4 5;`a`b!1 2)
0h

/so it is not comparable to something that has the promotion, even though the terminal makes them appear the same
q)((`a`b!4 5;`a`b!1 2))~exec val from flip(1#`val)!enlist(`a`b!4 5;`a`b!1 2)
0b
q)(`a`b!4 5;`a`b!1 2)
a b
---
4 5
1 2
q)exec val from flip(1#`val)!enlist(`a`b!4 5;`a`b!1 2)
a b
---
4 5
1 2
你的情况是一样的,只是一本字典而不是两本,但我认为两本字典更容易看