简体   繁体   中英

Intersection between two tables in DolphinDB server

I'm trying to use the intersection function in DolphinDB as follows:

n=1000000
ID=rand(100, n)
dates=2017.08.07..2017.08.11
date=rand(dates, n)
x=rand(10.0, n)
t=table(ID, date, x)
dbDate = database(, VALUE, 2017.08.07..2017.09.11)
dbID = database(, RANGE, 0 50 100)
db = database("dfs://compodb", COMPO, [dbDate, dbID])
pt = db.createPartitionedTable(t, `pt, `date`ID).append!(t)
dfsTable=loadTable("dfs://compodb","pt")

A = select * from dfsTable where date = 2017.08.07
B = select * from dfsTable where date = 2017.08.08
intersection(A[`x],B[`x])

But I am getting the error:

The both arguments for 'bitAnd'(&) must be integers

Apparently something doesn't work in this query... any idea?

This document section says this about how to create a vector:

  1. A vector from a table column. For example, trades.qty indicates column qty from table trades.

And it looks like intersection is an alias for & , which for vectors is treated as bitAnd , as said here :

Arguments

  • Set Operation: X and Y are sets.
  • Bit Operation: X and Y are equal sized vectors, or Y is a scalar.

So you need to convert vector to set with set(A[`x]) function .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM