[
https://issues.apache.org/jira/browse/CALCITE-7827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated CALCITE-7827:
------------------------------------
Labels: pull-request-available (was: )
> commonTypeForBinaryComparison narrows DECIMAL vs. FLOAT/REAL comparisons
> ------------------------------------------------------------------------
>
> Key: CALCITE-7827
> URL: https://issues.apache.org/jira/browse/CALCITE-7827
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.42.0
> Reporter: Sean Broeder
> Assignee: Sean Broeder
> Priority: Major
> Labels: pull-request-available
>
> AbstractTypeCoercion#commonTypeForBinaryComparison picks the approximate
> numeric operand's own type (FLOAT/REAL) as the common type for a comparison
> between an exact numeric DECIMAL and an approximate numeric operand,
> resulting in a loss of precision.
> A 32-bit FLOAT/REAL carries only ~7 significant decimal digits. When the
> validator uses this common type to insert an implicit CAST on the DECIMAL
> operand, two genuinely different DECIMAL values can collapse onto the same
> float value and incorrectly compare equal.
> commonTypeForBinaryComparison should consider the exact numeric's type before
> blindly returning the approximate numeric's type.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)