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

feat: Support remove_blink to remove blink table semantics in server-side Python #5958

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions py/server/deephaven/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,16 @@ def flatten(self) -> Table:
"""Returns a new version of this table with a flat row set, i.e. from 0 to number of rows - 1."""
return Table(j_table=self.j_table.flatten())

def remove_blink(self) -> Table:
"""Returns a new version of this table without specialized blink table aggregation semantics."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to document what happens if this table is not a blink table?

if self.is_blink:
try:
return Table(j_table=self.j_table.removeBlink())
except Exception as e:
raise DHError(e, "failed to remove blink table semantics.") from e
else:
raise RuntimeError("Table is not a blink table, so blink table semantics cannot be removed.")
Copy link
Member

Choose a reason for hiding this comment

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

Should this:

  1. Error (like here)?
  2. return self?

I'm not sure which provides the most natural behavior in the wild or what is most consistent with other API operations we have. I might guess 2 is more consistent, but I'm not sure.
@rcaudy @jmao-denver @rbasralian

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should just return self.j_table.removeBlink() without 'thinking about it' (i.e. remove the if and lean on the behavior of the Java implementation, which the javadocs say happens to be option 2: @return A non-blink child table, or this table if it is not a blink table)


def snapshot(self) -> Table:
"""Returns a static snapshot table.

Expand Down
9 changes: 9 additions & 0 deletions py/server/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,15 @@ def test_attributes(self):
self.assertEqual(len(attrs), len(rt_attrs) + 1)
self.assertIn("BlinkTable", set(attrs.keys()) - set(rt_attrs.keys()))

def test_remove_blink(self):
t_blink = time_table("PT1s", blink_table=True)
t_no_blink = t_blink.remove_blink()
self.assertEqual(t_blink.is_blink, True)
self.assertEqual(t_no_blink.is_blink, False)

with self.assertRaises(RuntimeError):
t_no_blink.remove_blink()

def test_grouped_column_as_arg(self):
t1 = empty_table(100).update(
["id = i % 10", "Person = random() > 0.5 ? true : random() > 0.5 ? false : true"]).sort(
Expand Down
Loading