[Enhancement] Implement Subfield visitor in ScalarOperatorsReuse #51991
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why I'm doing:
For now, ScalarOperatorsReuse has a lack of a implement of Subfield visitor. So for the sql below, the common expr will be computed multiple times:
select
(
case
when "hero_row.hero_level" < 0 then '10000->-∞
0'10'when "hero_row.hero_level" >= 0
and "hero_row.hero_level" < 10 then '10001->0
when "hero_row.hero_level" >= 10
and "hero_row.hero_level" < 20 then '10002->10~20'
else NULL
end
) group_3
from
(
select
CAST(parse_json(hero_row) as row(hero_equipment array, hero_if_support varchar, begin_time datetime, hero_level double, hero_name varchar))."hero_level" "hero_row.hero_level"
from
kudu.t.user_3
)
What I'm doing:
Implement ScalarOperatorRewriter#visitSubfield to make the common operator mechanism works well.
Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: