Releases: databrickslabs/lsql
Releases · databrickslabs/lsql
v0.9.0
- Added design for filter file (#251). A new feature has been added to enable the creation of filters for multiple widgets in a dashboard using a
.filter.json
file. This file allows users to specify columns to be filtered, the filter type, title, description, order, and a unique ID for each filter. Both thecolumn
andcolumns
flags are supported, with the former taking a single string and the latter taking a list of strings. The filter type can be set to a drop-down menu or another type as desired. The.filter.json
file schema also supports optionaltitle
anddescription
strings, as well asorder
andID
flags. An example of a.filter.json
file is provided in the commit message. Additionally, thedashboard.yml
file documentation has been updated to include information on how to use the new.filter.json
file. - adding normalize-case option to databricks labs lsql fmt cmd (#254). In this open-source library release, the
databricks labs lsql
tool'sfmt
command now supports a new flag,normalize-case
. This flag allows users to control the normalization of query text to lowercase, providing more flexibility when formatting SQL queries. By default, query text is still normalized to lowercase, but users can now prevent this behavior by setting thenormalize-case
flag toFalse
. This change addresses an issue where some queries are case sensitive, such as those using map field keys in UCX dashboards. Additionally, a new parameternormalize_case
has been added to theformat
method in thedashboards.py
file, with updated method documentation. A new test function,test_query_formats_no_normalize()
, has also been included to ensure consistent formatter behavior.
Contributors: @JCZuurmond, @HariGS-DB
v0.8.0
- Removed deploy_dashboard method (#240). In this release, the
deploy_dashboard
method has been removed from thedashboards.py
file and the legacy deployment method has been deprecated. Thedeploy_dashboard
method was previously used to deploy a dashboard to a workspace, but it has been replaced with thecreate
method of thelakeview
attribute of the WorkspaceClient object. Additionally, thetest_dashboards_creates_dashboard_via_legacy_method
method has been removed. A new test has been added to ensure that thedeploy_dashboard
method is no longer being used, utilizing thedeprecated_call
function from pytest to verify that calling the method raises a deprecation warning. This change simplifies the code and improves the overall design of the system, resolving issue #232. The_with_better_names
method andcreate_dashboard
method remain unchanged. - Skip test that fails due to insufficient permission to create schema (#248). A new test function,
test_dashboards_creates_dashboard_with_replace_database
, has been added to the open-source library, but it is currently marked to be skipped due to missing permissions to create a schema. This function creates an instance of theDashboards
class with thews
parameter, creates a dashboard using themake_dashboard
function, and performs various actions using the created dashboard, as well as functions such astmp_path
andsql_backend
. This test function aims to ensure that theDashboards
class functions as expected when creating a dashboard with a replaced database. Once the necessary permissions for creating a schema are acquired, this test function can be enabled for further testing and validation. - Updates to use the Databricks Python sdk 0.30.0 (#247). In this release, we have updated the project to use Databricks Python SDK version 0.30.0. This update includes changes to the
execute
andfetch_value
functions, which now use the newStatementResponse
type instead ofExecuteStatementResponse
. A conditional import statement has been added to maintain compatibility with both Databricks SDK versions 0.30.0 and below. Theexecute
function now raisesTimeoutError
when the specified timeout is greater than 50 seconds and the statement execution hasn't finished. Additionally, thefetch_value
function has been updated to handle the case when theexecute
function returnsNone
. The unit test filetest_backends.py
has also been updated to reflect these changes, with multiple test functions now using theStatementResponse
class instead ofExecuteStatementResponse
. These changes improve the system's compatibility with the latest version of the Databricks SDK, ensuring that the core functionality of the SDK continues to work as expected.
Contributors: @JCZuurmond
v0.7.5
- Fixed missing widget name suffixes (#243). In this release, we have addressed an issue related to missing widget name suffixes (#243) by adding a
_widget
suffix to the name of the widget object in the dashboards.py file. This change ensures consistency between the widget name and the id of the query, facilitating user understanding of the relationship between the two. A new method, _get_query_widget_spec, has also been added, although its specific functionality requires further investigation. Additionally, the unit tests in thetests/unit/test_dashboards.py
file have been updated to check for the presence of the_widget
suffix in widget names, ensuring that the tests accurately reflect the desired behavior. These changes improve the consistency of dashboard widget naming, thus benefiting software engineers utilizing or extending the project's widget-ordering functionalities.
Contributors: @nfx
v0.7.4
- Fixed dataset/widget name uniqueness requirement that was preventing dashboards being deployed (#241). A fix has been implemented to address a uniqueness requirement issue with the dataset/widget name that was preventing dashboard deployment. A new
widget
instance is now created with a unique name, generated by appending_widget
to the metadata ID, in theget_layouts
method. This ensures that multiple widgets with the same ID but different content can exist in a single dashboard, thereby meeting the name uniqueness requirement. In thesave_to_folder
method, the widget name is modified by removing the_widget
suffix before writing the textbox specification to a markdown file, maintaining consistency between the widget ID and file name. These changes are localized to theget_layouts
andsave_to_folder
methods, and no new methods have been added. The existing functionality related to the creation, validation, and saving of dashboard layouts remains unaltered.
Contributors: @nfx
v0.7.3
- Added publish flag to
Dashboards.create_dashboard
(#233). In this release, we have added apublish
flag to theDashboards.create_dashboard
method, allowing users to publish the dashboard upon creation, thereby resolving issue #219. This flag is included in thelabs.yml
file with a description of its functionality. Additionally, theno-open
flag's description has been updated to specify that it prevents the dashboard from opening in the browser after creation. Thecreate_dashboard
function in thecli.py
anddashboards.py
files has been updated to include the newpublish
flag, allowing for more flexibility in how users create and manage their dashboards. TheDashboards.create_dashboard
method now calls theWorkspaceClient.lakeview.publish
method when thepublish
flag is set toTrue
, which publishes the created dashboard. This behavior is covered in the updated tests for the method. - Fixed boolean cli flags (#235). In this release, we have improved the handling of command-line interface (CLI) flags in the
databricks labs
command. Specifically, we have addressed the limitation that pure boolean flags are not supported. Now, when using boolean flags, the user will be prompted to confirm with ay
or 'yes'. We have modified thecreate_dashboard
command to accept string inputs for thepublish
andno_open
flags, which are then converted to boolean values for internal use. Additionally, we have introduced a newopen-browser
command, which will open the dashboard in the browser after creating when set toy
or 'yes'. These changes have been tested manually to ensure correct behavior. This improvement provides a more flexible input experience and better handling of boolean flags in the CLI command for software engineers using the open-source library. - Fixed format breaks widget (#238). In this release, we've made significant changes to the 'databricks/labs/lsql' directory's 'dashboards.py' file to address formatting breaks in the widget that could occur with Call to Action (CTA) presence in a query. These changes include the addition of new class variables, including _SQL_DIALECT and _DIALECT, and their integration into existing methods such as _parse_header, validate, format, _get_abstract_syntax_tree, and replace_catalog_and_database_in_query. Furthermore, we have developed new methods for creating and deleting schemas and getting the current test purge time. We have also implemented new integration tests to demonstrate the fix for the formatting issue and added new test cases for the query handler's header-splitting functionality, query formatting, and CTE handling. These enhancements improve the library's handling of SQL queries and query tiles in the context of dashboard creation, ensuring proper parsing, formatting, and metadata extraction for a wide range of query scenarios.
- Fixed replace database when catalog or database is None (#237). In this release, we have addressed an issue where system tables disappeared in ucx dashboards when replacing the placeholder database. To rectify this, we have developed a new method,
replace_catalog_and_database_in_query
, in thedashboards.py
file'sreplace_database
function. This method checks if the catalog or database in a query match the ones to be replaced and replaces them with new ones, ensuring that system tables are not lost during the replacement process. Additionally, we have introduced new unit tests intest_dashboards.py
to verify that queries are correctly transformed when replacing the database or catalog in the query. These tests include various scenarios, using two parametrized test functions, to ensure the correct functioning of the feature. This change provides a more robust and reliable dashboard display when replacing the placeholder database in the system.
Contributors: @JCZuurmond
v0.7.2
- Fixed dashboard deployment/creation (#230). The recent changes to our open-source library address issues related to dashboard deployment and creation, enhancing their reliability and consistency. The
deploy_dashboard
function has been deprecated in favor of the more accuratecreate_dashboard
function, which now includes apublish
flag. Avalidate
method has been added to theTile
,MarkdownTile
, andQueryTile
classes to raise an error if the dashboard is invalid. Thetest_dashboards.py
file has been updated to reflect these changes. These enhancements address issues #222, #229, and partially resolve #220. The commit includes an image of a dashboard created through the deprecateddeploy_dashboard
method. These improvements ensure better dashboard creation, validation, and deployment, while also maintaining backward compatibility through the deprecation ofdeploy_dashboard
.
Contributors: @JCZuurmond
v0.7.1
- Bump sigstore/gh-action-sigstore-python from 2.1.1 to 3.0.0 (#224). In version 3.0.0 of sigstore/gh-action-sigstore-python, several changes, additions, and removals have been implemented. Notably, certain settings such as fulcio-url, rekor-url, ctfe, and rekor-root-pubkey have been removed. Additionally, the output settings signature, certificate, and bundle have also been removed. The inputs are now parsed according to POSIX shell lexing rules for better consistency. The release-signing-artifacts setting no longer causes a hard error when used under the incorrect event. Furthermore, various deprecations present in sigstore-python's 2.x series have been resolved. The default suffix has been changed from .sigstore to .sigstore.json, in line with Sigstore's client specification. The release-signing-artifacts setting now defaults to true. This version also includes several bug fixes and improvements to support CI runners that use PEP 668 to constrain global package prefixes.
- Use default factory to create
Tile._position
(#226). In this change, the default value creation for the_position
field in various classes includingTile
,MarkdownTile
,TableTile
, andCounterTile
has been updated. Previously, a newPosition
object was explicitly created for the default value. With this update, thedefault_factory
argument of thedataclasses.field
function is now used to create a newPosition
object. This change is made in anticipation of the Python 3.11 release, which modifies the field default mutability check behavior. By utilizing thedefault_factory
approach, we ensure that a newPosition
object is generated during each instance creation, rather than reusing a single default instance. This guarantees the immutability of default values and aligns with best practices for forward-compatibility with future Python versions. It is important to note that this modification does not affect the functionality of the classes but enhances their initialization process.
Dependency updates:
- Bump sigstore/gh-action-sigstore-python from 2.1.1 to 3.0.0 (#224).
Contributors: @JCZuurmond, @dependabot[bot], @nfx
v0.7.0
- Added
databricks labs lsql fmt
command (#221). The commit introduces a new command,databricks labs lsql fmt
, to the open-source library, which formats SQL files in a given folder using the Databricks SDK. This command can be used without authentication and accepts afolder
flag, which specifies the directory containing SQL files to format. The change also updates the labs.yml file and includes a new method,format
, in theQueryTile
class, which formats SQL queries using thesqlglot
library. This commit enhances the functionality of the CLI for SQL file formatting and improves the readability and consistency of SQL files, making it easier for developers to understand and maintain the code. Additionally, the commit includes changes to various SQL files to demonstrate the improved formatting, such as converting SQL keywords to uppercase, adding appropriate spacing around keywords and operators, and aligning column names in theVALUES
clause. The purpose of this change is to ensure that the formatting method works correctly and does not introduce any issues in the existing functionality.
Contributors: @nfx
v0.6.0
- Added method to dashboards to get dashboard url (#211). In this release, we have added a new method
get_url
to thelakeview_dashboards
object in thelaksedashboard
library. This method utilizes the Databricks SDK to retrieve the dashboard URL, simplifying the code and making it more maintainable. Previously, the dashboard URL was constructed by concatenating the host and dashboard ID, but this new method ensures that the URL is obtained correctly, even if the format changes in the future. Additionally, a new unit test has been added for a method that gets the dashboard URL using the workspace client. This new functionality allows users to easily retrieve the URL for a dashboard using its ID and the workspace client. - Extend replace database in query (#210). This commit extends the database replacement functionality in the
DashboardMetadata
class, allowing users to specify which database and catalog to replace. The enhancement includes support for catalog replacement and a newreplace_database
method in theDashboardMetadata
class, which replaces the catalog and/or database in the query based on provided parameters. These changes enhance the flexibility and customization of the database replacement feature in queries, making it easier for users to control how their data is displayed in the dashboard. Thecreate_dashboard
function has also been updated to use the new method for replacing the database and catalog. Additionally, theTileMetadata
update method has been replaced with a new merge method, and theQueryTile
andTile
classes have new properties and methods for handling content, width, height, and position. The commit also includes several unit tests to ensure the new functionality works as expected. - Improve object oriented dashboard-as-code implementation (#208). In this release, the object-oriented implementation of the dashboard-as-code feature has been significantly improved, addressing previous pull request comments (#201). The
TileMetadata
dataclass now includes methods for updating and comparing tile metadata, and theDashboardMetadata
class has been removed and its functionality incorporated into theDashboards
class. TheDashboards
class now generates tiles, datasets, and layouts for dashboards using the providedquery_transformer
. The code's readability and maintainability have been further enhanced by replacing the use of thecopy
module withdataclasses.replace
for creating object copies. Additionally, updates have been made to the unit tests for dashboard functionality in the project, with new methods and attributes added to check for valid dashboard metadata and handle duplicate query or widget IDs, as well as to specify the order in which tiles and widgets should be displayed in the dashboard.
Contributors: @JCZuurmond
v0.5.0
- Added Command Execution backend which uses Command Execution API on a cluster (#95). In this release, the databricks labs lSQL library has been updated with a new Command Execution backend that utilizes the Command Execution API. A new
CommandExecutionBackend
class has been implemented, which initializes aCommandExecutor
instance taking a cluster ID, workspace client, and language as parameters. Theexecute
method runs SQL commands on the specified cluster, and thefetch
method returns the query result as an iterator of Row objects. The existingStatementExecutionBackend
class has been updated to inherit from a new abstract base class calledExecutionBackend
, which includes asave_table
method for saving data to tables and is meant to be a common base class for both Statement and Command Execution backends. TheStatementExecutionBackend
class has also been updated to use the newExecutionBackend
abstract class and its constructor now accepts amax_records_per_batch
parameter. Theexecute
andfetch
methods have been updated to use the new_only_n_bytes
method for logging truncated SQL statements. Additionally, theCommandExecutionBackend
class has several methods,execute
,fetch
, andsave_table
to execute commands on a cluster and save the results to tables in the databricks workspace. This new backend is intended to be used for executing commands on a cluster and saving the results in a databricks workspace. - Added basic integration with Lakeview Dashboards (#66). In this release, we've added basic integration with Lakeview Dashboards to the project, enhancing its capabilities. This includes updating the
databricks-labs-blueprint
dependency to version 0.4.2 with the[yaml]
extra, allowing for additional functionality related to handling YAML files. A new file,dashboards.py
, has been introduced, providing a class for interacting with Databricks dashboards, along with methods for retrieving and saving dashboard configurations. Additionally, a new__init__.py
file under thesrc/databricks/labs/lsql/lakeview
directory imports all classes and functions from themodel.py
module, providing a foundation for further development and customization. The release also introduces a new file,model.py
, containing code generated from OpenAPI specs by the Databricks SDK Generator, and a template file,model.py.tmpl
, used for handling JSON data during integration with Lakeview Dashboards. A new file,polymorphism.py
, provides utilities for checking if a value can be assigned to a specific type, supporting correct data typing and formatting with Lakeview Dashboards. Furthermore, a.gitignore
file has been added to thetests/integration
directory as part of the initial steps in adding integration testing to ensure compatibility with the Lakeview Dashboards platform. Lastly, thetest_dashboards.py
file in thetests/integration
directory contains a function,test_load_dashboard(ws)
, which uses theDashboards
class to save a dashboard from a source to a destination path, facilitating testing during the integration process. - Added dashboard-as-code functionality (#201). This commit introduces dashboard-as-code functionality for the UCX project, enabling the creation and management of dashboards using code. The feature resolves multiple issues and includes a new
create-dashboard
command for creating unpublished dashboards. The functionality is available in thelsql
lab and allows for specifying the order and width of widgets, overriding default widget identifiers, and supporting various SQL and markdown header arguments. Thedashboard.yml
file is used to define top-level metadata for the dashboard. This commit also includes extensive documentation and examples for using the dashboard as a library and configuring different options. - Automate opening integration test dashboard in debug mode (#167). A new feature has been added to automatically open the integration test dashboard in debug mode, making it easier for software engineers to debug and troubleshoot. This has been achieved by importing the
webbrowser
andis_in_debug
modules from "databricks.labs.blueprint.entrypoint", and adding a check in thecreate
function to determine if the code is running in debug mode. If it is, a dashboard URL is constructed from the workspace configuration and dashboard ID, and then opened in a web browser using "webbrowser.open". This allows for a more streamlined debugging process for the integration test dashboard. No other parts of the code have been affected by this change. - Automatically tile widgets (#109). In this release, we've introduced an automatic widget tiling feature for the dashboard creation process in our open-source library. The
Dashboards
class now includes a new class variable,_maximum_dashboard_width
, set to 6, representing the maximum width allowed for each row of widgets in the dashboard. Thecreate_dashboard
method has been updated to accept a newself
parameter, turning it into an instance method. A new_get_position
method has been introduced to calculate and return the next available position for placing a widget, and a_get_width_and_height
method has been added to return the width and height for a widget specification, initially handlingCounterSpec
instances. Additionally, we've added new unit tests to improve testing coverage, ensuring that widgets are created, positioned, and sized correctly. These tests also cover the correct positioning of widgets based on their order and available space, as well as the expected width and height for each widget. - Bump actions/checkout from 4.1.3 to 4.1.6 (#102). In the latest release, the 'actions/checkout' GitHub Action has been updated from version 4.1.3 to 4.1.6, which includes checking the platform to set the archive extension appropriately. This release also bumps the version of github/codeql-action from 2 to 3, actions/setup-node from 1 to 4, and actions/upload-artifact from 2 to 4. Additionally, the minor-actions-dependencies group was updated with two new versions. Disabling extensions.worktreeConfig when disabling sparse-checkout was introduced in version 4.1.4. The release notes and changelog for this update can be found in the provided link. This commit was made by dependabot[bot] with contributions from cory-miller and jww3.
- Bump actions/checkout from 4.1.6 to 4.1.7 (#151). In the latest release, the 'actions/checkout' GitHub action has been updated from version 4.1.6 to 4.1.7 in the project's push workflow, which checks out the repository at the start of the workflow. This change brings potential bug fixes, performance improvements, or new features compared to the previous version. The update only affects the version number in the YAML configuration for the 'actions/checkout' step in the release.yml file, with no new methods or alterations to existing functionality. This update aims to ensure a smooth and enhanced user experience for those utilizing the project's push workflows by taking advantage of the possible improvements or bug fixes in the new version of 'actions/checkout'.
- Create a dashboard with a counter from a single query (#107). In this release, we have introduced several enhancements to our dashboard-as-code approach, including the creation of a
Dashboards
class that provides methods for getting, saving, and deploying dashboards. A new method,create_dashboard
, has been added to create a dashboard with a single page containing a counter widget. The counter widget is associated with a query that counts the number of rows in a specified dataset. Thedeploy_dashboard
method has also been added to deploy the dashboard to the workspace. Additionally, we have implemented a new feature for creating dashboards with a counter from a single query, including modifications to thetest_dashboards.py
file and the addition of four new tests. These changes improve the robustness of the dashboard creation process and provide a more automated way to view important metrics. - Create text widget from markdown file (#142). A new feature has been implemented in the library that allows for the creation of a text widget from a markdown file, enhancing customization and readability for users. This development resolves issue #1
- Design document for dashboards-as-code (#105). "The latest release introduces 'Dashboards as Code,' a method for defining and managing dashboards through configuration files, enabling version control and controlled changes. The building blocks include
.sql
,.md
, anddashboard.yml
files, with.sql
defining queries and determining tile order, anddashboard.yml
specifying top-level metadata and tile overrides. Metadata can be inferred or explicitly defined in the query or files. The tile order can be determined by SQL file order,tiles
order indashboard.yml
, or SQL file metadata. This project can also be used as a library for embedding dashboard generation in your code. Configuration precedence follows command-line flags, SQL file headers,dashboard.yml
, and SQL query content. The command-line interface is utilized for dashboard generation from configuration files." - Ensure propagation of
lsql
version intoUser-Agent
header when it is used as library (#206). In this release, thepyproject.toml
file has be...