calcite icon indicating copy to clipboard operation
calcite copied to clipboard

[CALCITE-6300] Function MAP_VALUES/MAP_KEYS gives exception when mapVauleType and mapKeyType not equals map Biggest mapKeytype or mapValueType

Open caicancai opened this issue 11 months ago • 9 comments

https://issues.apache.org/jira/browse/CALCITE-6300

caicancai avatar Mar 08 '24 08:03 caicancai

I may need to add some comments, but the code structure is basically determined

caicancai avatar Mar 08 '24 09:03 caicancai

Before I readadjustTypeForMapFunctionConstructor, I want to know why we need this method? If MAP function throw an exception when component type not equal? Like map('k1', cast(1 as tinyint), 'k2', cast(1 as bigint))

Thank you for such a quick review, I will write a plan to illustrate it

caicancai avatar Mar 08 '24 12:03 caicancai

Here you need to convert mapKeyType and mapValueType into the corresponding Biggest Type. According to the initial method, there is definitely no conversion of mapKeyType and mapValueType into the corresponding Biggest Type. Why add an adjustTypeForMapFunctionConstructor method? Here I will give an example:

map_values(map('foo', 1, 'bar', cast(1 as tinyint)))

When performing node parsing, map('foo', 1, 'bar', cast(1 as tinyint)) will be regarded as a node, that is, ((SqlBasicCall) call.getOperandList().get(0)) == map('foo', 1, 'bar', cast(1 as tinyint)),

I have to go through ((SqlBasicCall) call.getOperandList().get(0)).getOperandList() to get what I want, to typecast mapKeyType and mapValueType.

2024-03-09 15-49-09屏幕截图

I didn't find the corresponding method, so I wrote a new method

caicancai avatar Mar 09 '24 07:03 caicancai

@macroguo-ghy I'm sorry, I made the wrong request. I thought I should resolve the conflict first

caicancai avatar Mar 13 '24 13:03 caicancai

@macroguo-ghy If you have time, you can help me take a look. I think it is reasonable to only recognize map. Thank you.

caicancai avatar Mar 19 '24 02:03 caicancai

@macroguo-ghy If you have time, you can help me take a look. I think it is reasonable to only recognize map. Thank you.

@caicancai Sorry, I'm very busy this week, I will review at the earliest this weekend. And you can ask others for help.

macroguo-ghy avatar Mar 19 '24 06:03 macroguo-ghy

@macroguo-ghy If you have time, you can help me take a look. I think it is reasonable to only recognize map. Thank you.

@caicancai Sorry, I'm very busy this week, I will review at the earliest this weekend. And you can ask others for help.

Small question, this is open source, thank you very much for taking the time to review it for me, I really appreciate it

caicancai avatar Mar 19 '24 08:03 caicancai

@mihaibudiu Sorry for following up on this PR so late. If you have time, can you help me review this PR, thank you

caicancai avatar Apr 24 '24 12:04 caicancai