Open TennyZhuang opened 10 months ago
I suggest performing this optimization in the binder phase because it is more straightforward and easier to implement. https://github.com/risingwavelabs/risingwave/blob/b9b35190a73e0d3e9ad8a99e17d30a163d1036f6/src/frontend/src/binder/expr/mod.rs#L457
This issue has been open for 60 days with no activity. Could you please update the status? Feel free to continue discussion or close as not planned.
Some future to-dos:
bind_case
, some branches are pretty similar and could be potentially combined together.This issue has been open for 60 days with no activity. Could you please update the status? Feel free to continue discussion or close as not planned.
PostgreSQL supports a simple-form case-when expression:
In such case, if there is a large number of arms (e.g. 500+), it's better to optimize it to a constant lookup.
In addition, if users write a case-when expression that can be converted to the simple form, we can also normalize it in optimizer easily:
Note: the corner cases should be covered: