Skip to content

How to filter by an array of specs #244

Answered by jheer
mationai asked this question in Q&A
Discussion options

You must be logged in to vote

I think you want to perform a semijoin with a custom predicate. Here is one possibility:

const specs = aq.from([
  { date: new Date('2020-01-01'), val: 'a' },
  { date: new Date('2020-01-01'), val: 'b' }
]);

table.semijoin(specs, (a, b) => a.date < b.date && op.equal(a.val, b.val))

Using a custom predicate will fallback to an O(n*m) nested loop join, so watch out if the product of the table sizes is huge...

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mationai
Comment options

Answer selected by jheer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants