-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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(sqllab): TRINO_EXPAND_ROWS: expand columns from ROWs #25809
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @giftig for the PR. The one question that I have is whether this is the best UI treatment for displaying complex/nested types as it's somewhat difficult to grok and/or can be somewhat overwhelming without the ability to expand/collapse these rows.
@justinpark is actually working on a SIP which would address the UI treatment for handling these nested types (using a tree structure). I think it's fine (from a UI perspective) as is, based on knowledge that the UI will be improved in the future.
@john-bodley there are some difficulties in expanding out the data to be more readable which I thought about while working on this:
There's more, I left a fair few notes on some challenges I found on the related discussion if you're interested. But I think this fixes a good chunk of the problem and I have no prejudice on whether we also add on some display improvements as well; it's fairly well-encapsulated so hopefully it'll work fine with what @justinpark is working on. Currently from our end we consider it acceptable that querying a
which is a lot easier to understand than |
f45ad23
to
7763c01
Compare
fbdcc42
to
302c036
Compare
Reimplement, in a simpler way, part of the PRESTO_EXPAND_DATA feature for trino. Make use of the trino library's type expansion logic added since the original feature was introduced, as we now have sqla ROW types parsed out recursively in a way we can analyse. Analyse those ROWs and expand our definition of get_columns out to include dotted.path references to all fields it's possible to query by dotted path (i.e. all ROWs, nested arbitrarily deep). Add an extra optional query_as field to the column definition so that we can override the way it's queried: otherwise sqlalchemy is going to quote the whole thing as a single column name, which isn't correct, it should actually be quoted per dotted segment, and we'll want to alias it to the full dotted string. Add a setting in the database modal to enable this feature.
302c036
to
c9c5eba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the entry in the UI. I've cc'ed in some frontend engineers to review said portion of the code.
Hi @john-bodley @villebro @michael-s-molina gentle nudge about this one when you have some time. |
The backend changes LGTM. @michael-s-molina or @villebro would you mind taking a look at the frontend changes? |
@justinpark Should we test this PR with our database to see how the data is displayed? |
Hi @michael-s-molina, @justinpark have you had chance to test this one? Happy to merge? |
@giftig LGTM with the current UI design. |
1 similar comment
@giftig LGTM with the current UI design. |
SUMMARY
Reimplement, in a simpler way, part of the PRESTO_EXPAND_DATA feature for trino.
Make use of the trino library's type expansion logic added since the original feature was introduced, as we now have sqla ROW types parsed out recursively in a way we can analyse.
Analyse those ROWs and expand our definition of get_columns out to include dotted.path references to all fields it's possible to query by dotted path (i.e. all ROWs, nested arbitrarily deep).
Add an extra optional query_as field to the column definition so that we can override the way it's queried: otherwise sqlalchemy is going to quote the whole thing as a single column name, which isn't correct, it should actually be quoted per dotted segment, and we'll want to alias it to the full dotted string.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before / without feature flag
Schema
Preview
After
Schema
Preview
Database config
Last checkbox is new, to enable this feature:
TESTING INSTRUCTIONS
To easily construct some data containing nested rows, you can use the following instructions:
trinodb/trino:latest
in dockerdocker exec -it trino trino
to cli into ittrino://root@trino:8080/memory/default
ADDITIONAL INFORMATION