Repository navigation
fix(sql): support cross-type numeric coercion and 3-valued NULL logic in IN list (#1659) - #2546
Open
zaidrain06 wants to merge 1 commit into
Open
zaidrain06 wants to merge 1 commit into
zaidrain06 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1659
/claim #1659
This PR resolves SQLLogicTest
IN/NOT INevaluation failures indozer-sql/expression/src/in_list.rswhere cross-type numeric comparisons (Int,UInt,Float,Decimal, numericString) and three-valued SQLNULLsemantics previously returned incorrect results.Root Cause
evaluate_in_listpreviously evaluated each candidate expressioniteminlistand compared it againstexpr.evaluate(record, schema)?using Rust's strict enum equality (item.evaluate(record, schema)? == expr_val):Field::Int(1) == Field::Float(OrderedFloat(1.0))andField::Int(1) == Field::Decimal(Decimal::new(1, 0))evaluated tofalsebecause the enum variants differ, even thoughcomparison::evaluate_eqalready implements Dozer's cross-type numeric/string coercion rules.NULLlogic: Under SQL-92 three-valued logic:NULL IN (1, 2)and1 IN (2, NULL)must evaluate toNULL(notFALSE).1 NOT IN (2, NULL)must evaluate toNULL(notTRUE), whereas1 IN (1, NULL)isTRUEand1 NOT IN (1, NULL)isFALSE.NULL IN ()isFALSEandNULL NOT IN ()isTRUE.Solution
evaluate_in_listtocrate::comparison::evaluate_eq(schema, &mut left, item, record)?soIN/NOT INshares identical type coercion semantics with=.has_nullacross candidate evaluations to implement three-valued SQLNULLsemantics when no candidate matchesField::Boolean(true).in_list::tests:test_in_list_cross_type_numeric_coerciontest_in_list_three_valued_null_semanticsVerification
Bounty Payout Details (if direct crypto transfer is preferred alongside Algora):
0x9d66D9cf93776B5244B3C1F39C77696B80199dE2bydelibozok@gmail.com