Skip to content

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

Closed
caicancai wants to merge 1 commit intoapache:mainfrom
caicancai:6300-2
Closed

Conversation

@caicancai
Copy link
Copy Markdown
Member

@caicancai caicancai commented Sep 18, 2024

…auleType and mapKeyType not equals map Biggest mapKeytype or mapValueType
@caicancai
Copy link
Copy Markdown
Member Author

caicancai commented Sep 18, 2024

@rubenada Looks like my local git crashed for me, I open a new PR. Sorry.
previous discussion: #3847

I have to admit that this solution is a bit ad hoc, my goal is to find a unified solution, since there are many similar questions

@sonarqubecloud
Copy link
Copy Markdown

operandsmap.add(i, operands.get(i));
}
}
call.setOperand(0, castMapTo(operandsmap));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the question we haven't resolved properly is whether the type checker is allowed to mutate the expression that is being checked.

Copy link
Copy Markdown
Contributor

@rubenada rubenada Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right @mihaibudiu .
Looking a bit in detail, it seems there is already some existing code that calls call.setOperand on this file, e.g. inside adjustTypeForArrayFunctions or adjustTypeForMultisetConstructor; however, these methods seem to be called from a SqlReturnTypeInference (not from a SqlOperandTypeInference). Am I correct?
@caicancai would it be possible to adapt this patch so that the new code is contained in a SqlReturnTypeInference (where there is precedence on Calcite about such modifications)?

Copy link
Copy Markdown
Member Author

@caicancai caicancai Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rubenada ok, My first version of the solution is actually to modify SqlOperandTypeInference. I will fix this pr later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to think these changes were not wrong as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the ReturnTypeInference is allowed to change the arguments, hopefully this fact is documented somewhere

Copy link
Copy Markdown
Member Author

@caicancai caicancai Sep 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will send an email to discuss later. If it is not suitable, I will remove 1.38.0 from this jira.

@caicancai caicancai closed this Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants