'Select data of a partition with DolphinDB?
This is the table I used for querying.
dbName = "dfs://trade"
tbName = "trade"
if(existsDatabase(dbName)){
dropDatabase(dbName)
}
db1 = database(, VALUE, 2020.01.01..2022.01.01)
db2 = database(, HASH, [SYMBOL, 5])
db = database(dbName, COMPO, [db1, db2], , "TSDB")
schemaTable = table(
array(SYMBOL, 0) as SecurityID,
array(SYMBOL, 0) as Market,
array(TIMESTAMP, 0) as TradeTime,
array(DOUBLE, 0) as TradePrice,
array(INT, 0) as TradeQty,
array(DOUBLE, 0) as TradeAmount,
array(INT, 0) as BuyNum,
array(INT, 0) as SellNum
)
db.createPartitionedTable(schemaTable, tbName, `TradeTime`SecurityID, {TradeTim:"delta"}, sortColumns=`SecurityID`TradeTime, keepDuplicates=ALL)
With TradeTime and SecurityID as the partitioning columns, how can I retrieve data for each stock in a specified partition on a day?
Solution 1:[1]
To obtain the data of the HASH 1 partition of SecurityID on the date 2020.01.02:
select count(*) from loadTable("dfs://trade", "trade") where date(TradeTime)=2020.01.02, partition(SecurityID, 1)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | dbaa9948 |