Skip to content

[CALCITE-7464] Refactor type coercion in array/map functions to avoid mutating operands as side effects#4869

Open
caicancai wants to merge 1 commit intoapache:mainfrom
caicancai:7464
Open

[CALCITE-7464] Refactor type coercion in array/map functions to avoid mutating operands as side effects#4869
caicancai wants to merge 1 commit intoapache:mainfrom
caicancai:7464

Conversation

@caicancai
Copy link
Copy Markdown
Member

@caicancai caicancai force-pushed the 7464 branch 2 times, most recently from bc1634b to d6e97f7 Compare April 5, 2026 09:24
@caicancai caicancai marked this pull request as draft April 5, 2026 09:24
@caicancai caicancai marked this pull request as ready for review April 6, 2026 06:46
@caicancai caicancai requested review from NobiGo and mihaibudiu April 7, 2026 14:46
@caicancai caicancai force-pushed the 7464 branch 2 times, most recently from b6e8227 to aa37529 Compare April 7, 2026 15:05
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 7, 2026

@caicancai
Copy link
Copy Markdown
Member Author

@mihaibudiu If you have time, could you please help follow up on this PR? You should be very clear about the context.

opBinding.getTypeFactory(), opBinding.collectOperandTypes());

// explicit cast elements to component type if they are not same
SqlValidatorUtil.adjustTypeForMapConstructor(type, opBinding);
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 SqlValidatorUtil.adjustTypeForArrayConstructor is not considered in this PR?

Comment on lines +98 to +101
if (callBinding.isTypeCoercionEnabled()) {
callBinding.getValidator().getTypeCoercion()
.collectionFunctionCoercion(callBinding);
}
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.

might be a breaking change for downstream projects who do not use typeCoercion
imho need at least put info about this in release notes

Copy link
Copy Markdown
Contributor

@mihaibudiu mihaibudiu left a comment

Choose a reason for hiding this comment

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

Can we discuss the design first in Jira?

List<RelDataType> operandTypes,
List<SqlTypeFamily> expectedFamilies);

/**
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.

Type coercion can depend on functions, it's the other way around: functions can use some services from type coercion.

So I don't understand what this function means.

@Override public boolean collectionFunctionCoercion(SqlCallBinding binding) {
final SqlCall call = binding.getCall();
switch (call.getKind()) {
case MAP_VALUE_CONSTRUCTOR:
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.

Type coercion cannot depend on various functions like ARRAY_APPEND.

@caicancai caicancai added the discussion-in-jira There's open discussion in JIRA to be resolved before proceeding with the PR label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discussion-in-jira There's open discussion in JIRA to be resolved before proceeding with the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants