Currently Calcite translate "IN" to "OR" expression when the count of IN's operands less than "inSubQueryThreshold" or to "Join" when the operands count greater than "inSubQueryThreshold" to get better performance.
However this translation to "JOIN" is so complex. Especially when the "IN" expression located in the "select" or "join on condition".
the logical plan generated as follow:
The generated logical plan is so complex for such a simple sql！
I think we can treat "IN" as a function like "plus" and "minus".So there is no translation on "IN" and just keep it as it is.This would be much clear in the logical plan!
In the execute stage,We can provide a "InExpression":
We can put all the constant conditions to a "Set".In that way,the computational complexity can reduce from O（n）to O(1).
It would be much clear and have a good performance.
PS: "In sub-query" is not included in our talk.