fix: handle compare_vals turn into str when parse IgnoreColumnType #50205
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.
when I parse ignoreColumnType=True when call the function, it cast all values to be 'str' which causing the comparison between val1 and val2 to be failed.
for example
val1 = 1505.76189560
val2= 1505.761896
assertDataFrameEqual(source_df, databricks_df, ignoreColumnType=True,)
I will convert the original data into string with this clause first
it will become string comparison instead of compare by using the tolerance equation
'1505.76189560' != '1505.761896'
Hence assertError, even if the atol and rtol already assigned
What changes were proposed in this pull request?
add more elif case to convert str to float and parse into tolerant calculations
Why are the changes needed?
I think it might not be the only way to fix it, but just to be your ideas Thank you !
Does this PR introduce any user-facing change?
No
How was this patch tested?
Test on my local data source, comparing 2 dataframes
by patch the code into my local env.
Was this patch authored or co-authored using generative AI tooling?
No