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

Create table from query with multiple columns and introduce tiles #150

Merged

Conversation

JCZuurmond
Copy link
Contributor

@JCZuurmond JCZuurmond commented Jun 12, 2024

Resolves #127
Resolves #137
Stacked on top of #154

Screenshot 2024-06-12 at 17 13 17

Copy link

github-actions bot commented Jun 12, 2024

✅ 29/29 passed, 2 skipped, 7m11s total

Running from acceptance #175

widget = Widget(name=dataset.name, queries=[named_query], spec=counter_spec)
spec: WidgetSpec
if len(fields) == 1: # Counters are expected to have one field
counter_encodings = CounterFieldEncoding(field_name=fields[0].name, display_name=fields[0].name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you refactor this code to introduce three new classes: CounterTile, TableTile, and MarkdownTile. Those classes should have a widget_spec() -> WidgetSpec and size() -> tuple[int, int] methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, do you want each of them to receive the fields on initialisation? And the WidgetMetdata, how should that be merged with the size?

@JCZuurmond
Copy link
Contributor Author

Probably #154 has preference over this one

src/databricks/labs/lsql/dashboards.py Outdated Show resolved Hide resolved
src/databricks/labs/lsql/dashboards.py Show resolved Hide resolved
JCZuurmond added a commit that referenced this pull request Jun 14, 2024
Resolves #110 
Stacked upon #150
@JCZuurmond JCZuurmond force-pushed the feat/create-table-from-query branch from 892de1a to eb5a33a Compare June 14, 2024 08:00
@JCZuurmond JCZuurmond changed the base branch from main to feat/add-widget-id-to-query-header June 14, 2024 08:00
@JCZuurmond JCZuurmond changed the title Create table from query with multiple columns Create table from query with multiple columns and introduce tiles Jun 14, 2024
Copy link
Contributor Author

@JCZuurmond JCZuurmond left a comment

Choose a reason for hiding this comment

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

Refactor to remove the Tiler class

src/databricks/labs/lsql/dashboards.py Outdated Show resolved Hide resolved
width, height = self._default_size
self.position = dataclasses.replace(position, width=position.width or width, height=position.height or height)

@property
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't use property

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nfx : And the size on WidgetMetdata? Should that also not be a property? I recall the reasoning was that it is better to avoid in case of inherentence

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For consistency I remove the property there as well

src/databricks/labs/lsql/dashboards.py Outdated Show resolved Hide resolved
src/databricks/labs/lsql/dashboards.py Outdated Show resolved Hide resolved
Base automatically changed from feat/add-widget-id-to-query-header to main June 16, 2024 01:30
@JCZuurmond
Copy link
Contributor Author

This is what happens with an invalid query

Screenshot 2024-06-17 at 11 18 38

@JCZuurmond
Copy link
Contributor Author

Dashboard with table still renders after all changes:

Screenshot 2024-06-17 at 11 27 46

widget_metadata = WidgetMetadata(query_file, 1, 1, 1)
tile = QueryTile(widget_metadata)

fields = tile._find_fields() # pylint: disable=protected-access
Copy link
Contributor Author

@JCZuurmond JCZuurmond Jun 17, 2024

Choose a reason for hiding this comment

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

@nfx : I prefer to keep this unit test as is, i.e. with protected access, it is logic which lends itself well for such a unit test and it should be tested well

@JCZuurmond JCZuurmond changed the base branch from main to feat/dashboard-as-code-for-ucx June 19, 2024 06:42
@JCZuurmond JCZuurmond merged commit 4677acb into feat/dashboard-as-code-for-ucx Jun 19, 2024
9 of 10 checks passed
@JCZuurmond JCZuurmond deleted the feat/create-table-from-query branch June 19, 2024 06:43
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.

[FEATURE] Create TableV2Spec from query [FEATURE] Infer widget spec from query
2 participants