Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NearestNeighbors _ensureIdCol to check whether id_col in df.columns instead of relying on isSet(idCol) #642

Merged
merged 3 commits into from
May 9, 2024

Conversation

lijinf2
Copy link
Collaborator

@lijinf2 lijinf2 commented May 8, 2024

No description provided.

@lijinf2
Copy link
Collaborator Author

lijinf2 commented May 8, 2024

build

@@ -151,7 +151,7 @@ def _ensureIdCol(self, df: DataFrame) -> DataFrame:
id_col_name = self.getIdCol()
df_withid = (
df
if self.isSet("idCol")
if id_col_name in df.columns
Copy link
Collaborator

Choose a reason for hiding this comment

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

The following case is still broken it seems. idCol was not set, but queryDf contains a column with the same name as the default id column. The above check for this case on self.isSet("idCol") would not work as expected because of the copy. Seems like relying on isSet leads to very confusing and convoluted logic because of its behavior under copy. Any alternative?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Revised. The alternative first checks whether getIdCol() is inside the df.
And it throws a ValueError if query_df has a column with the same default name but idCol was not set.

@lijinf2
Copy link
Collaborator Author

lijinf2 commented May 8, 2024

build

@eordentlich
Copy link
Collaborator

build

Copy link
Collaborator

@eordentlich eordentlich left a comment

Choose a reason for hiding this comment

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

👍

@lijinf2 lijinf2 merged commit 1788e9d into NVIDIA:branch-24.04 May 9, 2024
2 checks passed
@lijinf2 lijinf2 deleted the knn_fix_idcol branch June 26, 2024 21:52
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.

2 participants