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

perf: add_rows follow-up, also check for empty table (no rows) #607

Closed

Conversation

WinPlay02
Copy link
Contributor

See #606

  • another way to check for empty tables (no rows)

@WinPlay02 WinPlay02 requested a review from a team as a code owner April 3, 2024 20:37
@WinPlay02
Copy link
Contributor Author

@Marsmaennchen221 Here is the check for amount of rows equals 0

@@ -1059,7 +1059,7 @@ def add_rows(self, rows: list[Row] | Table) -> Table:
if isinstance(rows, Table):
if rows.number_of_rows == 0:
return self
if self.number_of_columns == 0:
if self.number_of_columns == 0 or self.number_of_rows == 0:
return rows
different_column_names = set(self.column_names) - set(rows.column_names)
Copy link
Member

@lars-reimann lars-reimann Apr 3, 2024

Choose a reason for hiding this comment

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

Not something that must be fixed in this PR (and not by you in general, since we do this wrong a few times):

Don't we need to compute the symmetric difference here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Symmetric difference seems correct

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (e555b85) to head (60e78a5).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #607   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           53        53           
  Lines         3208      3208           
=========================================
  Hits          3208      3208           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1057,9 +1057,9 @@ def add_rows(self, rows: list[Row] | Table) -> Table:
2 5 6
"""
if isinstance(rows, Table):
if rows.number_of_rows == 0:
if rows.number_of_columns == 0 or rows.number_of_rows == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

The second check is not really necessary since number_of_colums == 0 => number_of_rows == 0

return self
if self.number_of_columns == 0:
if self.number_of_columns == 0 or self.number_of_rows == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

We should check after comparing columns to check for different schemas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Marsmaennchen221 But is the schema relevant, if there is nothing changed either way?

@Marsmaennchen221
Copy link
Contributor

Marsmaennchen221 commented Apr 3, 2024

See #608 with an added test

@WinPlay02
Copy link
Contributor Author

Superseded by #608

@WinPlay02 WinPlay02 closed this Apr 3, 2024
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.

3 participants