-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate IF and CASE to ConnectorExpression #11699
Comments
Martin and I discussed possible options to represent CASE. An important property of CASE expression is that is has conditional evaluation for the values. One option is to model CASE as a function call. This would mean that either this function call is "special", as it defines conditional evaluation of it some of its parameters, of we model the laziness using lambda expressions. There is a conclusion that we want ConnectorExpressions to support parametric lambdas (eg array reduction, or pushdown filter through UNNEST), but we don't want to add this complexity now. Thus, the CASE should be modeled as a new class of Now, actually there are these forms of case
So, let's introduce new classes
|
Now, regarding IF: |
I would name it
IF has a different code generator (IfCodeGenerator vs SwitchCodeGenerator), but if I recall correctly, it produces the same (or very similar) bytecode for an equivalent expression. It's been too long since I wrote it :) |
good idea, updated above
@sopel39 @lukasz-stec please chime in on this |
I'm not 100% sure that the current generated code for IF and CASE representing IF have the same performance (though it looks like it), but since those two are logically equivalent, there is nothing stopping us from generating the same bytecode in both cases if necessary. |
Thanks @lukasz-stec for chiming in. So for this issue, let's not try to preserve IF troundtip from Expression to ConnectorExpression and back. |
Open question - Should both be translated to a "$case" function or should we use separated functions?
The text was updated successfully, but these errors were encountered: