Skip to content

[CALCITE-6457] The ARRAY_CONTAINS function wrongly returns false when arrayComponentType and op1 type are different#3844

Closed
caicancai wants to merge 1 commit intoapache:mainfrom
caicancai:6457
Closed

[CALCITE-6457] The ARRAY_CONTAINS function wrongly returns false when arrayComponentType and op1 type are different#3844
caicancai wants to merge 1 commit intoapache:mainfrom
caicancai:6457

Conversation

@caicancai
Copy link
Member

@caicancai caicancai commented Jul 4, 2024

@caicancai caicancai changed the title [CALCITE-6457] The array_contains function return false when arrayCom… [CALCITE-6457] The array_contains function return false when arrayComponentType and op1 type are different Jul 4, 2024
@caicancai caicancai changed the title [CALCITE-6457] The array_contains function return false when arrayComponentType and op1 type are different [CALCITE-6457] The ARRAY_CONTAINS function return false when arrayComponentType and op1 type are different Jul 5, 2024
… arrayComponentType and op1 type are different
@caicancai caicancai changed the title [CALCITE-6457] The ARRAY_CONTAINS function return false when arrayComponentType and op1 type are different [CALCITE-6457] The ARRAY_CONTAINS function wrongly returns false when arrayComponentType and op1 type are different Jul 6, 2024
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 6, 2024

return false;
}

if (!arrayComponentType.equalsSansFieldNames(biggest)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

the adjustTypeForArrayFunctions is used in the return type inference in the other places, and not in the operand type checker. This is related to the same question I had which is whether the type checker can modify the expression.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mihaibudiu I think it is appropriate to do type casting in the type checker, such as checkOperandTypes from FamilyOperandTypeChecker which implements ImplicitCastOperandTypeChecker
some background

Copy link
Contributor

Choose a reason for hiding this comment

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

It is appropriate to insert casts in the TypeCoercion phase, but in type checking it's too late.
See https://issues.apache.org/jira/browse/CALCITE-6743 for the kinds of problems this creates: the types computed by the validator no longer reflect the expression tree that is being type checked.

@caicancai caicancai marked this pull request as draft July 23, 2024 01:16
@caicancai caicancai closed this Nov 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