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: Create UI to Display Partitioned Tables #1663

Merged
merged 40 commits into from
Jan 18, 2024

Conversation

georgecwan
Copy link
Contributor

@georgecwan georgecwan commented Nov 29, 2023

Testing Instructions

PartitionedTable

  1. Run the code and open the table pt
    from deephaven import empty_table
    
    _t = empty_table(100).update(["verylongcolumn=(int)Math.floor(i/5)", "veryveryverylongcolumn=i"])
    pt = _t.partition_by(["verylongcolumn", "veryveryverylongcolumn"])
  2. Check that the features specified in the spec are present:
    • Resizing the panel horizontally wraps the dropdown without wrapping the '>'
    • Hovering over the 'Key' and 'Merge' buttons displays the correct labels
    • The initial partition should be the first valid partition available when all columns are sorted in descending order
    • Options in the dropdown are displayed in descending order
  3. Clicking the 'Key' and 'Merge' tables should correctly display the respective table and the button should visually indicate if one of them is being displayed. All the dropdowns should show empty values while one of the buttons is active.
    • While one of the toggle buttons is active, only the leftmost dropdown should be enabled
  4. After clearing the dropdowns by clicking either the 'Key' or 'Merge' button, selecting any value on any dropdown should automatically set the remaining dropdowns and display a valid partition.
  5. Dropdowns should only contain values that are valid with respect to the selected values of all the dropdowns left of it
  6. Changing the value of a dropdown should try to preserve dropdowns to the right of it. If this is not possible, the values of the dropdowns right of it should be changed so that a valid partition can be displayed.

Parquet Tables

  1. Run the following code and verify that all tables display and function correctly for every data type
    from deephaven import empty_table
    part = empty_table(4).update("II=ii")
    
    from deephaven.parquet import write, read
    
    write(part, "/tmp/pt-test/intCol=0/part.parquet")
    write(part, "/tmp/pt-test/intCol=1/part.parquet")
    int_partition = read("/tmp/pt-test")
    
    write(part, "/tmp/string-test/stringCol=hello/part.parquet")
    write(part, "/tmp/string-test/stringCol=world/part.parquet")
    string_partition = read("/tmp/string-test")
    
    write(part, "/tmp/double-test/doubleCol=1.5/part.parquet")
    write(part, "/tmp/double-test/doubleCol=2.5/part.parquet")
    double_partition = read("/tmp/double-test")
    
    write(part, "/tmp/char-test/charCol=a/part.parquet")
    write(part, "/tmp/char-test/charCol=b/part.parquet")
    char_partition = read("/tmp/char-test")
    
    write(part, "/tmp/long-test/longCol=2147483648/part.parquet")
    write(part, "/tmp/long-test/longCol=2147483650/part.parquet")
    long_partition = read("/tmp/long-test")
    
    write(part, "/tmp/bool-test/boolCol=true/part.parquet")
    write(part, "/tmp/bool-test/boolCol=false/part.parquet")
    bool_partition = read("/tmp/bool-test")
    
    write(part, "/tmp/multi_test/x=0/y=0/part.parquet")
    write(part, "/tmp/multi_test/x=0/y=1/part.parquet")
    write(part, "/tmp/multi_test/x=1/y=0/part.parquet")
    write(part, "/tmp/multi_test/x=1/y=1/part.parquet")
    write(part, "/tmp/multi_test/x=1/y=2/part.parquet")
    multi_partition = read("/tmp/multi_test")

@georgecwan georgecwan self-assigned this Nov 29, 2023
Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Attention: 407 lines in your changes are missing coverage. Please review.

Comparison is base (c6a099d) 46.48% compared to head (681bc24) 46.05%.

Files Patch % Lines
packages/iris-grid/src/EmptyIrisGridModel.ts 0.00% 91 Missing ⚠️
...ckages/iris-grid/src/IrisGridPartitionSelector.tsx 30.95% 87 Missing ⚠️
packages/iris-grid/src/IrisGrid.tsx 22.03% 46 Missing ⚠️
packages/jsapi-components/src/TableDropdown.tsx 0.00% 41 Missing ⚠️
packages/iris-grid/src/IrisGridProxyModel.ts 31.57% 39 Missing ⚠️
...ges/iris-grid/src/IrisGridPartitionedTableModel.ts 0.00% 30 Missing ⚠️
packages/iris-grid/src/IrisGridTableModel.ts 61.11% 21 Missing ⚠️
packages/iris-grid/src/IrisGridUtils.ts 25.00% 21 Missing ⚠️
packages/jsapi-utils/src/TableUtils.ts 0.00% 9 Missing ⚠️
...ode-studio/src/styleguide/MockIrisGridTreeModel.ts 0.00% 6 Missing ⚠️
... and 9 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1663      +/-   ##
==========================================
- Coverage   46.48%   46.05%   -0.44%     
==========================================
  Files         617      621       +4     
  Lines       37289    37430     +141     
  Branches     9378     9399      +21     
==========================================
- Hits        17335    17237      -98     
- Misses      19900    20139     +239     
  Partials       54       54              
Flag Coverage Δ
unit 46.05% <23.78%> (-0.44%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@georgecwan georgecwan marked this pull request as ready for review December 1, 2023 21:15
packages/iris-grid/src/IrisGridPartitionedTableModel.ts Outdated Show resolved Hide resolved
packages/iris-grid/src/IrisGridProxyModel.ts Outdated Show resolved Hide resolved
packages/iris-grid/src/IrisGridPartitionedTableModel.ts Outdated Show resolved Hide resolved
packages/iris-grid/src/IrisGridPartitionedTableModel.ts Outdated Show resolved Hide resolved
packages/iris-grid/src/IrisGridProxyModel.ts Outdated Show resolved Hide resolved
packages/iris-grid/src/IrisGridProxyModel.ts Outdated Show resolved Hide resolved
packages/iris-grid/src/IrisGridProxyModel.ts Outdated Show resolved Hide resolved
packages/iris-grid/src/IrisGridPartitionedTableModel.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@dsmmcken dsmmcken left a comment

Choose a reason for hiding this comment

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

Boolean and Char columns don't seem to work in the UI as parition keys, even though they are supported by the engine:
image

@georgecwan
Copy link
Contributor Author

georgecwan commented Dec 7, 2023

Boolean and Char columns don't seem to work in the UI as parition keys, even though they are supported by the engine: image

Currently breaks when partition columns are not in order, looking into it

Also seems to not handle empty and null well

Copy link
Contributor

@dsmmcken dsmmcken left a comment

Choose a reason for hiding this comment

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

Something awful is happening with the performance here. I can only replicate it with the parition viewer, but it might be something in core. I don't know.

Steps to reproduce:

  1. run this, time_table, creating new a parition on each tick
from deephaven import empty_table, time_table

simple_ticking = time_table("PT00:00:01").update([
        "MyString=new String(`a`+i)",
        "MyInt=new Integer(i)",
        "MyLong=new Long(i)",
        "MyDouble=new Double(i+i/10)",
        "MyFloat=new Float(i+i/10)",
        "MyBoolean=new Boolean(i%2==0)",
        "MyChar= new Character((char) ((i%26)+97))",
        "MyShort=new Short(Integer.toString(i%32767))",
        "MyByte= new java.lang.Byte(Integer.toString(i%127))"])

p = simple_ticking.partition_by("MyString")
  1. Wait like a minute or two then take a performance snapshot. You'll get a million little nano-second locks too the point of it breaking everything.
    image

@georgecwan
Copy link
Contributor Author

georgecwan commented Dec 7, 2023

The key columns passed in by the js api has incorrect order, going to fix that issue in core first. This should be the cause of dropdowns not showing any options for certain column orderings independent of type. There might still more issues when dealing with null or empty values and some type-dependent issues unrelated to this.

Update: fix opened at deephaven/deephaven-core#4931

- Use EMPTY_ARRAY instead of returning a new array each time from the EmptyGridModel
  - Reduces re-renders
- Save the current viewport in IrisGridProxyModel, and apply it to the new model if the columns haven't changed
- Clean up hydration/dehydration
  - Needed to dehydrate the value correctly
- Return the partitioned tables columns instead of no columns, so rehydration will succeed
- Fix char type partitions - needed to create the raw filter value better
function makeModel(
columns = irisGridTestUtils.makeColumns()
): PartitionedGridModel {
const model = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not worth changing, but createMockProxy could make this a bit cleaner

Copy link
Contributor

@bmingles bmingles left a comment

Choose a reason for hiding this comment

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

Left 2 minor comments about missing async

- Add async to methods for consistency
@mofojed mofojed requested a review from bmingles January 8, 2024 14:41
bmingles
bmingles previously approved these changes Jan 8, 2024
Copy link
Contributor

@bmingles bmingles left a comment

Choose a reason for hiding this comment

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

LGTM

@mofojed mofojed enabled auto-merge (squash) January 8, 2024 15:06
mofojed
mofojed previously approved these changes Jan 8, 2024
mofojed added a commit to deephaven/deephaven-core that referenced this pull request Jan 12, 2024
…le (#5009)

- Memoizing it is inconsistent with other methods like `WorkerConnection.getTable`, which always returns a new table
- Was unclear who the "owner" of the returned table was
- Memoization can happen at the client level if they need it
- Tested with deephaven/web-client-ui#1663
Copy link
Contributor

@dsmmcken dsmmcken left a comment

Choose a reason for hiding this comment

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

image

String column not working. Boolean column not working.

And I get this error occasionally:
image

Tried testing using dx.stocks and mostdatatypes queries.

- Was referencing the columns from the original table instead of the actual table
- Was causing a mismatch when fetching the viewport, where it would just stall instead of throwing an error
@mofojed mofojed requested a review from dsmmcken January 16, 2024 20:27
@mofojed
Copy link
Member

mofojed commented Jan 16, 2024

@dsmmcken should be fixed. Also, you'll need to make sure you're on the latest main that includes both deephaven/deephaven-core#5033 and deephaven/deephaven-core#5009

@mofojed mofojed dismissed stale reviews from bmingles and themself via 02542dd January 16, 2024 21:20
@mofojed
Copy link
Member

mofojed commented Jan 18, 2024

Don's found two errors that are still occurring, both of them are because it is a ticking table starting with no partition. Using this snippet you can reproduce both issues:

from deephaven import empty_table, time_table

simple_ticking = time_table("PT00:00:01").update([
        "MyString=new String(`a`+i)",
        "MyInt=new Integer(i)",
        "MyLong=new Long(i)",
        "MyDouble=new Double(i+i/10)",
        "MyFloat=new Float(i+i/10)",
        "MyBoolean=new Boolean(i%2==0)",
        "MyChar= new Character((char) ((i%26)+97))",
        "MyShort=new Short(Integer.toString(i%32767))",
        "MyByte= new java.lang.Byte(Integer.toString(i%127))"])

p = simple_ticking.partition_by(["MyString", "MyInt", "MyBoolean"])
  1. Run the snippet above. Wait a couple of ticks, then run the snippet again. Sometimes you get stuck with a "Rebuilding Filters..." message in the bottom corner.
  • In the logs there is a "Table does not have any data" message. The issue is we're trying to load the first partition key, but there are no partition keys. The fix is to instead wait for an "updated" event to get the first key.
  1. Run the snippet above and let it go a few ticks. Then change partitions, wait a second, then run the snippet above again. You'll get an error message saying layoutHints is null:
    image
IrisGrid.tsx:2885 [IrisGrid] request failed: TypeError: Cannot read properties of null (reading 'layoutHints')
    at get layoutHints [as layoutHints] (IrisGridTableModel.ts:124:23)
    at new IrisGridTableModelTemplate (IrisGridTableModelTemplate.ts:251:12)
    at new IrisGridTableModel (IrisGridTableModel.ts:57:5)
    at makeModel (IrisGridProxyModel.ts:65:10)
    at IrisGridProxyModel.ts:551:26
  • The JsPartitionedTable.getTable API can return null instead of rejecting. I have a PR to fix that: fix: Mark JsPartitionedTable.getTable as nullable deephaven-core#5050
  • The main issue is that we re-open the table with the previously selected key, which is no longer valid (since the table started from scratch). We could handle that error more gracefully.

Workaround for both issues is to re-open the table.

mofojed and others added 3 commits January 18, 2024 11:42
- Wait for a key to be added to the keys table if one does not initially exist
- If the reloaded partition config is invalid, will reload the initial partition config
Copy link
Contributor

@dsmmcken dsmmcken left a comment

Choose a reason for hiding this comment

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

Looks good, all working now. Changed a couple color variables to theme better.

@mofojed mofojed merged commit db219ca into deephaven:main Jan 18, 2024
4 of 5 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI for PartitionedTable
4 participants