TorQ:如何对具有不同日期范围的单独表使用数据加载器分区?
TorQ: How to use dataloader partitioning with separate tables that have different date ranges?
我正在尝试使用 AquaQ 的 TorQ 填充价格和报价数据库。为此,我使用 .loader.loadallfiles function。不同之处在于 prices
是每日数据,而 quotes
更多是日内数据,例如汇率。
我按如下方式加载:
/- check the location of database directory
hdbdir:hsym `$getenv[`KDBHDB]
/hdbdir:@[value;`hdbdir;`:hdb]
rawdatadir:hsym `$getenv[`KDBRAWDATA]
target:hdbdir;
rawdatadir:hsym `$("" sv (getenv[`KDBRAWDATA]; "prices"));
.loader.loadallfiles[`headers`types`separator`tablename`dbdir`partitioncol`partitiontype`dataprocessfunc!(`date`sym`open`close`low`high`volume;"DSFFFFF";enlist ",";`prices;target;`date;`year;{[p;t] `date`sym`open`close`low`high`volume xcols update volume:"i"$volume from t}); rawdatadir];
rawdatadir:hsym `$("" sv (getenv[`KDBRAWDATA]; "quotes"));
.loader.loadallfiles[`headers`types`separator`tablename`dbdir`partitioncol`partitiontype`dataprocessfunc!(`date`sym`bid`ask;"ZSFF";enlist ",";`quotes;target;`date;`year;{[p;t] `date`sym`bid`ask`mid xcols update mid:(bid+ask)%2.0 from t}); rawdatadir];
这很好用。但是,在加载数据库时,我在从 table 尝试 select 时遇到错误。原因是对于某些分区,没有任何 prices
或 quotes
数据。例如试图:
quotes::`date`sym xkey select from quotes;
失败并出现错误,指出年份的分区,例如hdb/2000/
不存在这是真的,2000 年只有 prices
而没有 quotes
据我所知,有两种可能的解决方案,但我都不知道如何实施:
- 告诉
.loader.loadallfiles
为没有任何数据的分区中的报价和价格创建空架构。
- 加载数据库时,优雅地处理给定分区没有数据的情况,即
select from ... where ignore empty partitions
尝试使用 .Q.chk[`:hdb]
其中 `:hdb
是您的 HDB 的文件路径
这会填充缺失的表格,然后您可以执行查询。
或者您可以使用 .Q.bv
,其中 wiki 指出:
If your table exists in the latest partition (so there is a prototype
for the schema), then you could use .Q.bv[]
to create empty tables
on the fly at run-time without having to create those empties on disk.
我正在尝试使用 AquaQ 的 TorQ 填充价格和报价数据库。为此,我使用 .loader.loadallfiles function。不同之处在于 prices
是每日数据,而 quotes
更多是日内数据,例如汇率。
我按如下方式加载:
/- check the location of database directory
hdbdir:hsym `$getenv[`KDBHDB]
/hdbdir:@[value;`hdbdir;`:hdb]
rawdatadir:hsym `$getenv[`KDBRAWDATA]
target:hdbdir;
rawdatadir:hsym `$("" sv (getenv[`KDBRAWDATA]; "prices"));
.loader.loadallfiles[`headers`types`separator`tablename`dbdir`partitioncol`partitiontype`dataprocessfunc!(`date`sym`open`close`low`high`volume;"DSFFFFF";enlist ",";`prices;target;`date;`year;{[p;t] `date`sym`open`close`low`high`volume xcols update volume:"i"$volume from t}); rawdatadir];
rawdatadir:hsym `$("" sv (getenv[`KDBRAWDATA]; "quotes"));
.loader.loadallfiles[`headers`types`separator`tablename`dbdir`partitioncol`partitiontype`dataprocessfunc!(`date`sym`bid`ask;"ZSFF";enlist ",";`quotes;target;`date;`year;{[p;t] `date`sym`bid`ask`mid xcols update mid:(bid+ask)%2.0 from t}); rawdatadir];
这很好用。但是,在加载数据库时,我在从 table 尝试 select 时遇到错误。原因是对于某些分区,没有任何 prices
或 quotes
数据。例如试图:
quotes::`date`sym xkey select from quotes;
失败并出现错误,指出年份的分区,例如hdb/2000/
不存在这是真的,2000 年只有 prices
而没有 quotes
据我所知,有两种可能的解决方案,但我都不知道如何实施:
- 告诉
.loader.loadallfiles
为没有任何数据的分区中的报价和价格创建空架构。 - 加载数据库时,优雅地处理给定分区没有数据的情况,即
select from ... where ignore empty partitions
尝试使用 .Q.chk[`:hdb]
其中 `:hdb
是您的 HDB 的文件路径
这会填充缺失的表格,然后您可以执行查询。
或者您可以使用 .Q.bv
,其中 wiki 指出:
If your table exists in the latest partition (so there is a prototype for the schema), then you could use
.Q.bv[]
to create empty tables on the fly at run-time without having to create those empties on disk.