SNOW-1753336: [Local testing] Merge
and update
fail when target table's index is not RangeIndex
#2481
Labels
Merge
and update
fail when target table's index is not RangeIndex
#2481
Please answer these questions before submitting your issue. Thanks!
What version of Python are you using?
Python 3.11.6 (tags/v3.11.6:8b6ee5b, Oct 2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)]
What operating system and processor architecture are you using?
Windows-10-10.0.22631-SP0
What are the component versions in the environment (
pip freeze
)?pandas==2.2.3
snowflake-snowpark-python==1.23.0
What did you do?
Both
table.merge
andtable.update
fail with the same error because they both use this linetarget_index = target.loc[rows_to_update[ROW_ID]].index
, which uses pandas.loc
whererows_to_update[ROW_ID]
correspond to indices of a dataframe with defaultRangeIndex
. But when that's not the case, it fails. Solutions are: either change all the.loc
for.iloc
, reset the indices of the target tables before merging/updating, or reset the index of every table read or reset the index of every table written (since I think the index is always assumed to beRangeIndex
).Example
What did you expect to see?
No error. Should return
but got:
The text was updated successfully, but these errors were encountered: