mindsdb_sql icon indicating copy to clipboard operation
mindsdb_sql copied to clipboard

Planner: Support "select from model where input in (...)"

Open ea-rus opened this issue 1 year ago • 0 comments

Support multiple model calls in selecting from predictor with using IN statement.

This select

SELECT * FROM model 
WHERE a IN (100,101) 

Should call model twice, with two inputs and return two records in output. Equivalent calls:

SELECT * FROM model WHERE a = 100;
SELECT * FROM model WHERE a = 101;

Edge cases

  1. second field is constant
SELECT * FROM model WHERE a IN (100,101) and b = 1

is converted to:

SELECT * FROM model WHERE a = 100 and b = 1;
SELECT * FROM model WHERE a = 101 and b = 1;
  1. second field is list of equal length
SELECT * FROM model WHERE a IN (100,101) and b IN (1,2)

is converted to:

SELECT * FROM model WHERE a = 100 and b = 1;
SELECT * FROM model WHERE a = 101 and b = 2;
  1. second field is list of different length
SELECT * FROM model WHERE a IN (100,101) and b IN (1,2,3)

raises an error

  1. first field is subselect
SELECT * FROM model WHERE a IN (select a from table1)

Raise not supported ? To be able to handle this case this logic should be implemented in mindsdb.

ea-rus avatar Jul 04 '23 16:07 ea-rus