- Explicitly test/support python 3.13 and 3.14 (#490). The acceptance workflow has been enhanced to support Python versions 3.13 and 3.14, in addition to existing versions, by updating environment variables and dependencies. The workflow now utilizes Hatch version 1.16.5, installed using the
HATCH_VERSIONenvironment variable, and the latest versions ofactions/checkoutandactions/setup-python, specifically version 6. The Python version used in the Install Python step has been updated to 3.14, and the types of pull requests that trigger this workflow have been modified to excludeready_for_reviewevents. Additionally, the condition to run the integration job has been simplified, and environment variablesHATCH_VERBOSEandHATCH_VERSIONhave been added to the workflow. These changes aim to extend the CI/CD pipeline and project metadata to cover Python 3.13 and 3.14, with incidental updates to dependencies, including upgrading Hatch and GitHub actions, to improve the overall testing and installation process. - Fixed dashboard serialisation:
queryis nowqueryLineson upstream REST API (#491). TheDatasetclass has been enhanced with improved serialization and deserialization functionality, allowing it to handle compatibility issues with dashboard APIs. Thefrom_dictmethod now checks for bothqueryandqueryLinesattributes in the input dictionary, using thequeryattribute directly and joiningqueryLinesinto a single string, while setting the query to None if neither attribute is found. This change enables the method to load datasets from various sources, including previously saved files, while maintaining compatibility. Additionally, the class's serialization and deserialization functionality has been thoroughly tested with the introduction of several new test methods, which verify its ability to correctly handle different query formats, including cases where the query is represented asqueryLinesor "query", and when the query is absent, ensuring accurate conversion between the object and dictionary representations. - Limit
sqlglotto releases earlier than 26.30.0 (#410). The library has undergone several updates to improve its functionality and robustness. The dependency on a key library has been updated to prevent the use of a version that introduced a breaking change, while also incorporating type-hinting fixes to accommodate newer versions of a static type checker. TheTileclass has been enhanced with various changes, including input validation, improved position calculation, and better handling of potential issues, such as missing or invalid values. Additionally, numerous data classes have been modified to allow for optional values in various fields, enabling greater flexibility in the data models and facilitating the representation of incomplete or missing data. These changes aim to improve the overall reliability and adaptability of the library, allowing it to handle a wider range of scenarios and input data. - Updated the minimum version of
databricks-labs-pytesterto 0.7.2 (#408). The minimum required version of a testing library has been updated to 0.7.2, which resolves an issue caused by a breaking change in the Databricks SDK version 0.51. This update ensures compatibility and prevents import failures when using older versions of the testing library with the new Databricks SDK. As a result, test dependencies must be at version 0.7.2 or later, although this change does not impact normal installs or new development environments, which will automatically use the latest version.
- Let page name adhere to naming restrictions (#370). In this release, a new method
_clean_resource_namehas been introduced to modify resource names according to the updated naming convention, allowing only alphanumeric characters, hyphens, and underscores. Theas_lakeviewmethod in theBaseHandlerclass now uses this new method to ensure thePageclass name adheres to the new restrictions. Furthermore, test files for dashboards have been updated to reflect the change, with a new test functiontest_dashboard_metadata_as_lakeview_cleans_page_nameverifying that page names are free of special characters, and an existing test function modified to handle invalid dashboard YAML files. These changes improve consistency, reliability, and adherence to best practices in dashboard naming within the project.
- remove duplicate changelog entry (#366). In this update, we've improved resource name validation in the
ucxproject, first introduced in version 0.14.2. The validation now restricts resource names to alphanumeric characters, hyphens, and underscores, addressing usability issues and preventing problems caused by special characters. A new internal method,_is_valid_resource_name, checks if a name is valid according to the defined pattern. TheTileMetadataclass has been updated to ensure itsidattribute follows the new validation rules, andTile,Section, andDashboardclasses now call thevalidatemethod of theTileMetadatainstance if it exists. These changes promote consistency and correctness in dashboard resources, simplifying management and interaction for users. As a part of this commit, we also removed a duplicate changelog entry related to this feature that was previously present in version 0.15.0.
- Validate resource names (#357). The recent change in the
ucxproject enhances resource name validation to adhere to a new naming convention, restricting names to alphanumeric characters, hyphens, and underscores. A new method,_is_valid_resource_name(name: str) -> bool, is introduced for validating resource names, and theTileMetadataclass has been updated with a__post_init__method and avalidatemethod for validation purposes. TheTileandFilterTileclasses also receive avalidatemethod to raiseValueErrorfor invalid tiles and metadata issues. This commit introduces new tests for validating tile IDs, tile metadata, and filter specs while improving error messages for better user understanding. It also raisesValueErrorfor tiles with empty content, tiles with names containing spaces, and filter tiles with invalid widget types, ensuring stricter validation for dashboard metadata and tile metadata in theucxproject.
- Validate resource names (#357). This pull request introduces a validation feature to the
ucxproject for resource names, specifically for dashboard tile IDs. The new naming convention restricts resource names to alphanumeric characters, hyphens, and underscores, enhancing usability and reducing potential issues caused by special characters. A new method,_is_valid_resource_name, is implemented to check if a name is valid based on the defined pattern. TheTileMetadataclass is updated to ensure itsidattribute adheres to the new validation rules, and avalidatemethod is added to raise aValueErrorif the tile metadata is invalid. This method checks if theidattribute is not empty and if it is a valid resource name. Additionally, thevalidatemethod is updated in theTile,Section, andDashboardclasses to call thevalidatemethod of theTileMetadatainstance, if it exists. The pull request also includes tests for the new validation functionality, ensuring that tile IDs cannot be empty, must contain only alphanumeric characters, hyphens, and underscores, and that thevalidatemethod detects duplicate query IDs and widget IDs. This validation helps maintain consistency and correctness in dashboard resources, making it easier for users to manage and interact with their dashboards. - Updated runner (#360). In this release, we have updated the GitHub Actions workflow for releasing the project to utilize a protected runner group with the label
linux-ubuntu-latestin thepublishjob'sruns-onfield. This change enhances control and security over the execution environment, as the protected runner group,databrickslabs-protected-runner-group, ensures that only specified runners that meet specific criteria are allowed to execute jobs. Thelinux-ubuntu-latestlabel specifies the desired runner configuration. Furthermore, the workflow now utilizes an environment namedreleaseand retains the existing permissions configuration for authenticating to PyPI via OIDC and signing release artifacts withsigstore-python. This upgrade to the execution environment preserves essential authentication and security features, providing improved reliability, maintainability, and security for the release process while ensuring continued compatibility and security for publishing activities. - Explicitly install Python 3.12 before running fmt in CI (#358). In this release, we have made significant enhancements to our open-source library aimed at improving reliability, consistency, and usability for software engineers. A new step installing Python 3.12 explicitly before executing the formatting process in the CI system has been implemented, ensuring compatibility and consistency with the chosen Python version. The 'backends.py' file's
save_tablefunction syntax has been updated for better code readability and maintainability, addressing potential SQL injection issues. The 'model.py' file has undergone refactoring, updatingKeyErrorexceptions to f-strings for improved consistency and readability, and the 'polymorphism.py' file has been improved with new functions and refined error messages for better debugging and understanding of type assignment issues. Lastly, the 'structs.py' file in the 'databricks/labs/lsql' package has received updates to ensure consistent Python version usage, improved error messages, and better SQL type inference from Python types, enhancing the overall development experience for adopting engineers.
- Changes to work with Databricks SDK
v0.38.0(#350). In this release, we have upgraded the Databricks SDK to version 0.38.0 from version 0.37.0 to ensure compatibility with the latest SDK and address several issues. The update includes changes to make the code compatible with the new SDK version, removing the need for.as_dict()method calls when creating or updating dashboards and utilizing asdk_dashboardvariable for interacting with the Databricks workspace. We also updated the dependencies to "databricks-labs-blueprint[yaml]" package version greater than or equal to 0.4.2 andsqlglotpackage version greater than or equal to 22.3.1. Thetest_core.pyfile has been updated to address multiple issues (#349 to #332) related to the Databricks SDK and thetest_dashboards.pyfile has been revised to work with the new SDK version. These changes improve integration with Databricks' lakeview dashboards, simplify the code, and ensure compatibility with the latest SDK version, resolving issues #349 to #332. - Specify the minimum required version of
databricks-sdkas 0.37.0 (#331). In this release, we have updated the minimum required version of thedatabricks-sdkpackage to 0.37.0 from 0.29.0 in thepyproject.tomlfile to ensure compatibility with the latest version. This change was made necessary due to updates made in issue #320. To accommodate any patch release ofdatabricks-sdkwith a major and minor version of 0.37, we have updated the dependency constraint to use the~=operator, resolving issue #330. These changes are intended to enhance the compatibility and stability of our software.
- Added nightly tests run at 4:45am UTC (#318). A new nightly workflow has been added to the codebase, designed to automate a series of jobs every day at 4:45am UTC on the
largerenvironment. The workflow includes permissions for writing id-tokens, accessing issues, reading contents and pull-requests. It checks out the code with a full fetch-depth, installs Python 3.10, and uses hatch 1.9.4. The key step in this workflow is the execution of nightly tests using the databrickslabs/sandbox/acceptance action, which creates issues if necessary. The workflow utilizes several secrets, including VAULT_URI, GITHUB_TOKEN, ARM_CLIENT_ID, and ARM_TENANT_ID, and sets the TEST_NIGHTLY environment variable to true. Additionally, the workflow is part of a concurrency group called "single-acceptance-job-per-repo", ensuring that only one acceptance job runs at a time per repository. - Bump codecov/codecov-action from 4 to 5 (#319). In this version update, the Codecov GitHub Action has been upgraded from 4 to 5, bringing improved functionality and new features. This new version utilizes the Codecov Wrapper to encapsulate the CLI, enabling faster updates. Additionally, an opt-out feature has been introduced for tokens in public repositories, allowing contributors and other members to upload coverage reports without requiring access to the Codecov token. The upgrade also includes changes to the arguments:
fileis now deprecated and replaced withfiles, andpluginis deprecated and replaced withplugins. New arguments have been added, includingbinary,gcov_args,gcov_executable,gcov_ignore,gcov_include,report_type,skip_validation, andswift_project. Comprehensive documentation on these changes can be found in the release notes and changelog. - Fixed
RuntimeBackendexception handling (#328). In this release, we have made significant improvements to the exception handling in theRuntimeBackendcomponent, addressing issues reported in tickets #328, #327, #326, and #325. We have updated theexecuteandfetchmethods to handle exceptions more gracefully and changed exception handling from catchingExceptionto catchingBaseExceptionfor more comprehensive error handling. Additionally, we have updated thepyproject.tomlfile to use a newer version of thedatabricks-labs-pytesterpackage (0.2.1 to 0.5.0) which may have contributed to the resolution of these issues. Furthermore, thetest_backends.pyfile has been updated to improve the readability and user-friendliness of the test output for the functions testing if aNotFound,BadRequest, orUnknownexception is raised when executing and fetching statements. Thetest_runtime_backend_use_statementsfunction has also been updated to printPASSEDorFAILEDinstead of returning those values. These changes enhance the robustness of the exception handling mechanism in theRuntimeBackendclass and update related unit tests.
Dependency updates:
- Bump codecov/codecov-action from 4 to 5 (#319).
- Added
escape_namefunction to escape individual SQL names andescape_full_namefunction to escape dot-separated full names (#316). Two new functions,escape_nameandescape_full_name, have been added to thedatabricks.labs.lsql.escapesmodule for escaping SQL names. Theescape_namefunction takes a single name as an input and returns it enclosed in backticks, whileescape_full_namehandles dot-separated full names by escaping each individual component. These functions have been ported from thedatabrickslabs/ucxrepository and are designed to provide a consistent way to escape names and full names in SQL statements, improving the robustness of the system by preventing issues caused by unescaped special characters in SQL names. The test suite includes various cases, including single names, full names with different combinations of escaped and unescaped components, and special characters, with a specific focus on the scenario where the column name contains a period. - Bump actions/checkout from 4.2.0 to 4.2.1 (#304). In this pull request, the
actions/checkoutdependency is updated from version 4.2.0 to 4.2.1 in the.github/workflows/release.ymlfile. This update includes a new feature whererefs/*are checked out by commit if provided, falling back to the ref specified by the@orhantoyuser. This change improves the flexibility of the action, allowing users to specify a commit or branch for checkout. The pull request also introduces a new contributor,@Jcambass, who added a workflow file for publishing releases to an immutable action package. The commits for this release include changes to prepare for the 4.2.1 release, add a workflow file for publishing releases, and check out otherrefs/*by commit if provided, falling back to ref. This pull request has been reviewed and approved by Dependabot. - Bump actions/checkout from 4.2.1 to 4.2.2 (#310). This is a pull request to update the
actions/checkoutdependency from version 4.2.1 to 4.2.2, which includes improvements to theurl-helper.tsfile that now utilize well-known environment variables and expanded unit test coverage for theisGhesfunction. Theactions/checkoutaction is commonly used in GitHub Actions workflows for checking out a repository at a specific commit or branch. The changes in this update are internal to theactions/checkoutaction and should not affect the functionality of the project utilizing this action. The pull request also includes details on the commits and compatibility score for the upgrade, and reviewers can manage and merge the request using Dependabot commands once the changes have been verified. - Bump databrickslabs/sandbox from acceptance/v0.3.0 to 0.3.1 (#307). In this release, the
databrickslabs/sandboxdependency has been updated from versionacceptance/v0.3.0to0.3.1. This update includes previously tagged commits, bug fixes for git-related libraries, and resolution of theunsupported protocol schemeerror. The README has been updated with more information on using thedatabricks labs sandboxcommand, and installation instructions have been improved. Additionally, there have been dependency updates forgo-gitlibraries andgolang.org/x/cryptoin the/go-libsand/runtime-packagesdirectories. New commits in this release allow larger logs from acceptance tests and implement experimental OIDC refresh functionality. Ignore conditions have been applied to prevent conflicts with previous versions of the dependency. This update is recommended for users who want to take advantage of the latest bug fixes and improvements. - Bump databrickslabs/sandbox from acceptance/v0.3.1 to 0.4.2 (#315). In this release, the
databrickslabs/sandboxdependency has been updated from versionacceptance/v0.3.1to0.4.2. This update includes bug fixes, dependency updates, and additional go-git libraries. Specifically, theRun integration testsjob in the GitHub Actions workflow has been updated to use the new version of thedatabrickslabs/sandbox/acceptanceDocker image. The updated version also includes install instructions, usage instructions in the README, and a modification to provide more git-related libraries. Additionally, there were several updates to dependencies, includinggolang.org/x/cryptoversion0.16.0to0.17.0. Dependabot, a tool that manages dependencies in GitHub projects, is responsible for the update and provides instructions for resolving any conflicts or merging the changes into the project. This update is intended to improve the functionality and reliability of thedatabrickslabs/sandboxdependency. - Deprecate
Row.as_dict()(#309). In this release, we are introducing a deprecation warning for theas_dict()method in theRowclass, which will be removed in favor of theasDict()method. This change aims to maintain consistency with Spark'sRowbehavior and prevent subtle bugs when switching between different backends. The deprecation warning will be implemented using Python's warnings mechanism, including the new annotation in Python 3.13 for static code analysis. The existing functionality of fetching values from the database throughStatementExecutionExtremains unchanged. We recommend that clients update their code to use.asDict()instead of.as_dict()to avoid any disruptions. A new test casetest_row_as_dict_deprecated()has been added to verify the deprecation warning forRow.as_dict(). - Minor improvements for
.save_table(mode="overwrite")(#298). In this release, the.save_table()method has been improved, particularly when using theoverwritemode. If no rows are supplied, the table will now be truncated, ensuring consistency with the mock backend behavior. This change has been optimized for SQL-based backends, which now perform truncation as part of the insert for the first batch. Type hints on the abstract method have been updated to match the concrete implementations. Unit tests and integration tests have been updated to cover the new functionality, and new methods have been added to test the truncation behavior in overwrite mode. These improvements enhance the consistency and efficiency of the.save_table()method when usingoverwritemode across different backends. - Updated databrickslabs/sandbox requirement to acceptance/v0.3.0 (#305). In this release, we have updated the requirement for the
databrickslabs/sandboxpackage to versionacceptance/v0.3.0in thedownstreams.ymlfile. This update is necessary to use the latest version of the package, which includes several bug fixes and dependency updates. Thedatabrickslabs/sandboxpackage is used in the acceptance tests, which are run as part of the CI/CD pipeline. It provides a set of tools and utilities for developing and testing code in a sandbox environment. The changelog for this version includes the addition of install instructions, more git-related libraries, and the modification of the README to include information about how to use it with thedatabricks labs sandboxcommand. Specifically, the version of thedatabrickslabs/sandboxpackage used in theacceptancejob has been updated fromacceptance/v0.1.4toacceptance/v0.3.0, allowing the integration tests to be run using the latest version of the package. The ignore conditions for this PR ensure that Dependabot will resolve any conflicts that may arise and can be manually triggered with the@dependabot rebasecommand.
Dependency updates:
- Bump actions/checkout from 4.2.0 to 4.2.1 (#304).
- Updated databrickslabs/sandbox requirement to acceptance/v0.3.0 (#305).
- Bump databrickslabs/sandbox from acceptance/v0.3.0 to 0.3.1 (#307).
- Bump actions/checkout from 4.2.1 to 4.2.2 (#310).
- Bump databrickslabs/sandbox from acceptance/v0.3.1 to 0.4.2 (#315).
- Bump actions/checkout from 4.1.7 to 4.2.0 (#295). In this version 4.2.0 release of the
actions/checkoutlibrary, the team has addedRefandCommitoutputs, which provide the ref and commit that were checked out, respectively. The update also includes dependency updates tobraces,minor-npm-dependencies,docker/build-push-action, anddocker/login-action, all of which were automatically resolved by Dependabot. These updates improve compatibility and stability for users of the library. This release is a result of contributions from new team members @yasonk and @lucacome. Users can find a detailed commit history, pull requests, and release notes in the associated links. The team strongly encourages all users to upgrade to this new version to access the latest features and improvements. - Set catalog on
SchemaDeployerto overwrite the defaulthive_metastore(#296). In this release, the default catalog forSchemaDeployerhas been changed fromhive_metastoreto a user-defined catalog, allowing for more flexibility in deploying resources to different catalogs. A new dependency,databricks-labs-pytester, has been added with a version constraint of>=0.2.1, which may indicate the introduction of new testing functionality. TheSchemaDeployerclass has been updated to accept acatalogparameter and the tests for deploying and deleting schemas, tables, and views have been updated to reflect these changes. Thetest_deploys_schema,test_deploys_dataclass, andtest_deploys_viewtests have been updated to accept ainventory_catalogparameter, and thecaplogfixture is used to capture log messages and assert that they contain the expected messages. Additionally, a new test functiontest_statement_execution_backend_overwrites_tablehas been added to thetests/integration/test_backends.pyfile to test the functionality of theStatementExecutionBackendclass in overwriting a table in the database and retrieving the correct data. Issue #294 has been resolved, and progress has been made on issue #278, but issue #280 has been marked as technical debt and issue #287 is required for the CI to pass.
Dependency updates:
- Bump actions/checkout from 4.1.7 to 4.2.0 (#295).
- Added method to detect rows are written to the
MockBackend(#292). In this commit, theMockBackendclass in the 'backends.py' file has been updated with a new method, 'has_rows_written_for', which allows for differentiation between a table that has never been written to and one with zero rows. This method checks if a specific table has been written to by iterating over the table stubs in the_save_tableattribute and returningTrueif the given full name matches any of the stub full names. Additionally, the class has been supplemented with therows_written_formethod, which takes a table name and mode as input and returns a list of rows written to that table in the given mode. Furthermore, several new test cases have been added to test the functionality of theMockBackendclass, including checking if thehas_rows_written_formethod correctly identifies when there are no rows written, when there are zero rows written, and when rows are written after the first and second write operations. These changes improve the overall testing coverage of the project and aid in testing the functionality of theMockBackendclass. The new methods are accompanied by documentation strings that explain their purpose and functionality.
- Added filter spec implementation (#276). In this commit, a new
FilterHandlerclass has been introduced to handle filter files with the suffix.filter.json, which can parse filter specifications in the header of the filter file and validate the filter columns and types. The commit also adds support for three types of filters:DATE_RANGE_PICKER,MULTI_SELECT, andDROPDOWN, which can be linked with multiple visualization widgets. Additionally, aFilterTileclass has been added to theTileclass, which represents a filter tile in the dashboard and includes methods to validate the tile, create widgets, and generate filter encodings and queries. TheDashboardMetadataclass has been updated to include a new methodget_datasets()to retrieve the datasets for the dashboard. These changes enhance the functionality of the dashboard by adding support for filtering data using various filter types and linking them with multiple visualization widgets, improving the customization and interactivity of the dashboard, and making it more user-friendly and efficient. - Bugfix:
MockBackendwasn't mockingsavetableproperly when the mode isappend(#289). This release includes a bugfix and enhancements for theMockBackendcomponent, which is used to mock theSQLBackend. The.savetable()method failed to function as expected inappendmode, writing all rows to the same table instead of accumulating them. This bug has been addressed, ensuring that rows accumulate correctly inappendmode. Additionally, a new test function,test_mock_backend_save_table_overwrite(), has been added to demonstrate the corrected behavior ofoverwritemode, showing that it now replaces only the existing rows for the given table while preserving other tables' contents. The type signature for.save_table()has been updated, restricting themodeparameter to accept only two string literals:"append"and"overwrite". TheMockBackendbehavior has been updated accordingly, and rows are now filtered to exclude anyNoneorNULLvalues prior to saving. These improvements to theMockBackendfunctionality and test suite increase reliability when using theMockBackendas a testing backend for the system. - Changed filter spec to use YML instead of JSON (#290). In this release, the filter specification files have been converted from JSON to YAML format, providing a more human-readable format for the filter specifications. The schema for the filter file includes flags for column, columns, type, title, description, order, and id, with the type flag taking on values of DROPDOWN, MULTI_SELECT, or DATE_RANGE_PICKER. This change impacts the FilterHandler, is_filter method, and _from_dashboard_folder method, as well as relevant parts of the documentation. Additionally, the parsing methods have been updated to use yaml.safe_load instead of json.loads, and the is_filter method now checks for .filter.yml suffix. A new file, '00_0_date.filter.yml', has been added to the 'tests/integration/dashboards/filter_spec_basic' directory, containing a sample date filter definition. Furthermore, various tests have been added to validate filter specifications, such as checking for invalid type and both
columnandcolumnskeys being present. These updates aim to enhance readability, maintainability, and ease of use for filter configuration. - Increase testing of generic types storage (#282). A new commit enhances the testing of generic types storage by expanding the test suite to include a list of structs, ensuring more comprehensive testing of the system. The
Foostruct has been renamed toNestedfor clarity, and two new structs,NestedWithDictandNesting, have been added. TheNestingstruct contains aNestedobject, whileNestedWithDictincludes a string and an optional dictionary of strings. A new test case demonstrates appending complex types to a table by creating and saving a table with two rows, each containing aNestingstruct. The test then fetches the data and asserts the expected number of rows are returned, ensuring the proper functioning of the storage system with complex data types. - Minor Changes to avoid redundancy in code and follow code patterns (#279). In this release, we have made significant improvements to the
dashboards.pyfile to make the code more concise, maintainable, and in line with the standard library's recommended usage. Theexport_to_zipped_csvmethod has undergone major changes, including the removal of theBytesIOmodule import and the use ofStringIOfor handling strings as files. The method no longer creates a separate ZIP file for the CSV files, instead using the providedexport_path. Additionally, the method skips tiles that don't contain queries. We have also introduced a new method,dataclass_transform, which transforms a given dataclass into a new one with specific attributes and behavior. This method creates a new dataclass with a custom metaclass and adds a new method,to_dict(), which converts the instances of the new dataclass to dictionaries. These changes promote code reusability and reduce redundancy in the codebase, making it easier for software engineers to work with. - New example with bar chart in dashboards-as-code (#281). A new example of a dashboard featuring a bar chart has been added to the
dashboards-as-codefeature using the existing metadata overrides feature to support the new widget type, without bloating the TileMetadata structure. An integration test was added to demonstrate the creation of a bar chart, and the resulting dashboard can be seen in the attached screenshot. Additionally, a new SQL file has been added for theProduct Salesdashboard, showcasing sales data for different product categories. This approach can potentially be used to support other widget types such as Bar, Pivot, Area, etc. The team is encouraged to provide feedback on this proposed solution.
- Added Functionality to export any dashboards-as-code into CSV (#269). The
DashboardMetadataclass now includes a new method,export_to_zipped_csv, which enables exporting any dashboard as CSV files in a ZIP archive. This method acceptssql_backendandexport_pathas parameters and exports dashboard queries to CSV files in the specified ZIP archive by iterating through tiles and fetching dashboard queries if the tile is a query. To ensure the proper functioning of this feature, unit tests and manual testing have been conducted. A new test,test_dashboards_export_to_zipped_csv, has been added to verify the correct export of dashboard data to a CSV file. - Added support for generic types in
SqlBackend(#272). In this release, we've added support for using rich dataclasses, including those with optional and generic types, in theSqlBackendof theStatementExecutionBackendclass. The new functionality is demonstrated in thetest_supports_complex_typesunit test, which creates aNesteddataclass containing various complex data types, such as nested dataclasses,datetimeobjects,dict,list, and optional fields. This enhancement is achieved by updating thesave_tablemethod to handle the conversion of complex dataclasses to SQL statements. To facilitate type inference, we've introduced a newStructInferenceclass that converts Python dataclasses and built-in types to their corresponding SQL Data Definition Language (DDL) representations. This addition simplifies data definition and manipulation operations while maintaining type safety and compatibility with various SQL data types.
- Added documentation for exclude flag (#265). A new
excludeflag has been added to the configuration file for our lab tool, allowing users to specify a path to exclude from formatting during lab execution. This release also includes corrections to grammatical errors in the descriptions of existing flags related to catalog and database settings, such as updatingseperatedto "separate". Additionally, the flag descriptions forpublishandopen-browserhave been updated for clarification:publishnow clearly controls whether the dashboard is published after creation, whileopen-browsercontrols whether the dashboard is opened in a web browser. These changes are aimed at improving user experience and ease of use for our lab tool. - Fixed dataclass field type in _row_to_sql (#266). In this release, we have addressed an issue related to #257 by fixing the dataclass field type in the
_row_to_sqlmethod of thebackends.pyfile. Additionally, we have made updates to the_schema_formethod to use a new_field_typeclass method. This change resolves a rare problem where thefield.typeis a string instead of a type and ensures compatibility with a pull request from an external repository (databrickslabs/ucx#2526). The new_field_typemethod attempts to load the type from__builtins__if it's a string and logs a warning if it fails. The_row_to_sqlmethod now consistently uses the_field_typemethod to get the field type. This ensures that the library functions seamlessly and consistently, avoiding any potential issues in the future.
- Make hatch a prerequisite (#259). In this commit, Eric Vergnaud has introduced a change to make the installation of
hatchversion 1.9.4 a prerequisite for the project to avoid errors related topipcommand recognition. The Makefile has been updated to handle the installation of hatch automatically, and thehatch env createcommand is now used instead ofpip install hatch==1.7.0. This change ensures that the development environment is consistent and reliable by maintaining the correct version of hatch and automatically handling its installation. Additionally, the.venv/bin/pythonanddevtargets have been updated accordingly to reflect these changes. This commit also formats all files using themake dev fmtcommand, which helps maintain consistent code formatting throughout the project. - add support for exclusions in
fmtcommand (#263). In this release, we have added support for exclusions to thefmtcommand in the 'databricks/labs/lsql/cli.py' module. This feature allows users to specify a list of directories or files to exclude while formatting SQL files, which is particularly useful when verifying SQL notebooks in ucx. Thefmtcommand now accepts a new optional parameter 'exclude', which accepts an iterable of strings that specify the relative paths to exclude. Anysql_filethat is a descendant of anyexclusionis skipped during formatting. The exclusions are implemented by converting the relative paths intoPathobjects. This change addresses the issue where single line comments are converted into inlined comments, causing misinterpretation. The added unit test is manually verified, and this pull request fixes issue #261. This feature was authored and co-authored by Eric Vergnaud.
- Fixed dataclass field types (#257). This PR introduces a workaround to a Python bug affecting the
dataclasses.fields()function, which sometimes returns field types as string type names instead of types. This can cause the ORM to malfunction. The workaround involves checking if the returnedf.typeis a string, and if so, converting it to a type by looking it up in the__builtins__dictionary. This change is global and affects the_schema_forfunction in thebackends.pyfile, which is responsible for creating a schema for a given dataclass, taking into account any necessary type conversions. This change ensures consistent and accurate type handling in the face of the Python bug, improving the reliability of our ORM. - Fixed missing EOL when formatting SQL files (#260). In this release, we have addressed an issue related to the inconsistent addition of end-of-line (EOL) characters in formatted SQL files. The
QueryTile.format()method has been updated to ensure that an EOL character is always added, except when the input query already ends with a newline. This change enhances the reliability of the SQL formatting functionality, making the output format more predictable and improving the overall user experience. The new implementation is demonstrated in thetest_query_format_preserves_eol()test case, and existing test cases have been updated to check for the presence of EOL characters, further ensuring consistent and correct formatting. - Fixed normalize case input in cli (#258). In this release, we have updated the
fmtcommand in thecli.pyfile to allow users to specify whether they want to normalize the case of SQL files when formatting. Thenormalize_caseparameter now defaults to the string"true"and checks if it is in theSTRING_AFFIRMATIVESlist to determine whether to normalize the case of SQL files. Additionally, we have introduced a new optionalnormalize_caseparameter in theformatmethod of thedashboards.pyfile in the Databricks CLI, which normalizes the identifiers in the query to lower case when set toTrue. We have also added support for a newnormalize_caseparameter in theQueryTile.format()method, which prevents the automatic normalization of string input to uppercase when set toFalse. This change allows for more flexibility in handling string input and ensures that the input string is preserved as-is. These updates improve the functionality and usability of the open-source library, providing more control to users over formatting and handling of string input.
- 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.jsonfile. This file allows users to specify columns to be filtered, the filter type, title, description, order, and a unique ID for each filter. Both thecolumnandcolumnsflags 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.jsonfile schema also supports optionaltitleanddescriptionstrings, as well asorderandIDflags. An example of a.filter.jsonfile is provided in the commit message. Additionally, thedashboard.ymlfile documentation has been updated to include information on how to use the new.filter.jsonfile. - adding normalize-case option to databricks labs lsql fmt cmd (#254). In this open-source library release, the
databricks labs lsqltool'sfmtcommand 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-caseflag 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_casehas been added to theformatmethod in thedashboards.pyfile, with updated method documentation. A new test function,test_query_formats_no_normalize(), has also been included to ensure consistent formatter behavior.
- Removed deploy_dashboard method (#240). In this release, the
deploy_dashboardmethod has been removed from thedashboards.pyfile and the legacy deployment method has been deprecated. Thedeploy_dashboardmethod was previously used to deploy a dashboard to a workspace, but it has been replaced with thecreatemethod of thelakeviewattribute of the WorkspaceClient object. Additionally, thetest_dashboards_creates_dashboard_via_legacy_methodmethod has been removed. A new test has been added to ensure that thedeploy_dashboardmethod is no longer being used, utilizing thedeprecated_callfunction 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_namesmethod andcreate_dashboardmethod 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 theDashboardsclass with thewsparameter, creates a dashboard using themake_dashboardfunction, and performs various actions using the created dashboard, as well as functions such astmp_pathandsql_backend. This test function aims to ensure that theDashboardsclass 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
executeandfetch_valuefunctions, which now use the newStatementResponsetype instead ofExecuteStatementResponse. A conditional import statement has been added to maintain compatibility with both Databricks SDK versions 0.30.0 and below. Theexecutefunction now raisesTimeoutErrorwhen the specified timeout is greater than 50 seconds and the statement execution hasn't finished. Additionally, thefetch_valuefunction has been updated to handle the case when theexecutefunction returnsNone. The unit test filetest_backends.pyhas also been updated to reflect these changes, with multiple test functions now using theStatementResponseclass 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.
- Fixed missing widget name suffixes (#243). In this release, we have addressed an issue related to missing widget name suffixes (#243) by adding a
_widgetsuffix 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.pyfile have been updated to check for the presence of the_widgetsuffix 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.
- 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
widgetinstance is now created with a unique name, generated by appending_widgetto the metadata ID, in theget_layoutsmethod. 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_foldermethod, the widget name is modified by removing the_widgetsuffix before writing the textbox specification to a markdown file, maintaining consistency between the widget ID and file name. These changes are localized to theget_layoutsandsave_to_foldermethods, and no new methods have been added. The existing functionality related to the creation, validation, and saving of dashboard layouts remains unaltered.
- Added publish flag to
Dashboards.create_dashboard(#233). In this release, we have added apublishflag to theDashboards.create_dashboardmethod, allowing users to publish the dashboard upon creation, thereby resolving issue #219. This flag is included in thelabs.ymlfile with a description of its functionality. Additionally, theno-openflag's description has been updated to specify that it prevents the dashboard from opening in the browser after creation. Thecreate_dashboardfunction in thecli.pyanddashboards.pyfiles has been updated to include the newpublishflag, allowing for more flexibility in how users create and manage their dashboards. TheDashboards.create_dashboardmethod now calls theWorkspaceClient.lakeview.publishmethod when thepublishflag 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 labscommand. 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 ayor 'yes'. We have modified thecreate_dashboardcommand to accept string inputs for thepublishandno_openflags, which are then converted to boolean values for internal use. Additionally, we have introduced a newopen-browsercommand, which will open the dashboard in the browser after creating when set toyor '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.pyfile'sreplace_databasefunction. 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.pyto 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.
- 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_dashboardfunction has been deprecated in favor of the more accuratecreate_dashboardfunction, which now includes apublishflag. Avalidatemethod has been added to theTile,MarkdownTile, andQueryTileclasses to raise an error if the dashboard is invalid. Thetest_dashboards.pyfile 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_dashboardmethod. These improvements ensure better dashboard creation, validation, and deployment, while also maintaining backward compatibility through the deprecation ofdeploy_dashboard.
- 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_positionfield in various classes includingTile,MarkdownTile,TableTile, andCounterTilehas been updated. Previously, a newPositionobject was explicitly created for the default value. With this update, thedefault_factoryargument of thedataclasses.fieldfunction is now used to create a newPositionobject. This change is made in anticipation of the Python 3.11 release, which modifies the field default mutability check behavior. By utilizing thedefault_factoryapproach, we ensure that a newPositionobject 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).
- Added
databricks labs lsql fmtcommand (#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 afolderflag, which specifies the directory containing SQL files to format. The change also updates the labs.yml file and includes a new method,format, in theQueryTileclass, which formats SQL queries using thesqlglotlibrary. 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 theVALUESclause. The purpose of this change is to ensure that the formatting method works correctly and does not introduce any issues in the existing functionality.
- Added method to dashboards to get dashboard url (#211). In this release, we have added a new method
get_urlto thelakeview_dashboardsobject in thelaksedashboardlibrary. 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
DashboardMetadataclass, allowing users to specify which database and catalog to replace. The enhancement includes support for catalog replacement and a newreplace_databasemethod in theDashboardMetadataclass, 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_dashboardfunction has also been updated to use the new method for replacing the database and catalog. Additionally, theTileMetadataupdate method has been replaced with a new merge method, and theQueryTileandTileclasses 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
TileMetadatadataclass now includes methods for updating and comparing tile metadata, and theDashboardMetadataclass has been removed and its functionality incorporated into theDashboardsclass. TheDashboardsclass 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 thecopymodule withdataclasses.replacefor 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.
- 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
CommandExecutionBackendclass has been implemented, which initializes aCommandExecutorinstance taking a cluster ID, workspace client, and language as parameters. Theexecutemethod runs SQL commands on the specified cluster, and thefetchmethod returns the query result as an iterator of Row objects. The existingStatementExecutionBackendclass has been updated to inherit from a new abstract base class calledExecutionBackend, which includes asave_tablemethod for saving data to tables and is meant to be a common base class for both Statement and Command Execution backends. TheStatementExecutionBackendclass has also been updated to use the newExecutionBackendabstract class and its constructor now accepts amax_records_per_batchparameter. Theexecuteandfetchmethods have been updated to use the new_only_n_bytesmethod for logging truncated SQL statements. Additionally, theCommandExecutionBackendclass has several methods,execute,fetch, andsave_tableto 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-blueprintdependency 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__.pyfile under thesrc/databricks/labs/lsql/lakeviewdirectory imports all classes and functions from themodel.pymodule, 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.gitignorefile has been added to thetests/integrationdirectory as part of the initial steps in adding integration testing to ensure compatibility with the Lakeview Dashboards platform. Lastly, thetest_dashboards.pyfile in thetests/integrationdirectory contains a function,test_load_dashboard(ws), which uses theDashboardsclass 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-dashboardcommand for creating unpublished dashboards. The functionality is available in thelsqllab and allows for specifying the order and width of widgets, overriding default widget identifiers, and supporting various SQL and markdown header arguments. Thedashboard.ymlfile 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
webbrowserandis_in_debugmodules from "databricks.labs.blueprint.entrypoint", and adding a check in thecreatefunction 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
Dashboardsclass 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_dashboardmethod has been updated to accept a newselfparameter, turning it into an instance method. A new_get_positionmethod has been introduced to calculate and return the next available position for placing a widget, and a_get_width_and_heightmethod has been added to return the width and height for a widget specification, initially handlingCounterSpecinstances. 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
Dashboardsclass 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_dashboardmethod 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.pyfile 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.ymlfiles, with.sqldefining queries and determining tile order, anddashboard.ymlspecifying 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,tilesorder 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
lsqlversion intoUser-Agentheader when it is used as library (#206). In this release, thepyproject.tomlfile has been updated to ensure that the correct version of thelsqllibrary is propagated into theUser-Agentheader when used as a library, improving attribution. Thedatabricks-sdkversion has been updated from0.22.0to0.29.0, and the__init__.pyfile of thelsqllibrary has been modified to add thewith_user_agent_extrafunction from thedatabricks.sdk.corepackage for correct attribution. Thebackends.pyfile has also been updated with improved type handling in the_row_to_sqlandsave_tablefunctions for accurate SQL insertion and handling of user-defined classes. Additionally, a test has been added to ensure that thelsqlversion is correctly propagated in theUser-Agentheader when used as a library. These changes offer improved functionality and accurate type handling, making it easier for developers to identify the library version when used in other projects. - Fixed counter encodings (#143). In this release, we have improved the encoding of counters in the lsql dashboard by modifying the
create_dashboardfunction in thedashboards.pyfile. Previously, the counter field encoding was hardcoded as "count," but has been changed to dynamically determine the first field name of the given fields, ensuring that counters are expected to have only one field. Additionally, a new integration test has been added to thetests/integration/test_dashboards.pyfile to ensure that the dashboard deployment functionality correctly handles SQL queries that do not perform a count. A new test for theDashboardsclass has also been added to check that counter field encoding names are created as expected. TheWorkspaceClientis mocked and not called in this test. These changes enhance the accuracy of counter encoding and improve the overall functionality and reliability of the lsql dashboard. - Fixed non-existing reference and typo in the documentation (#104). In this release, we've made improvements to the documentation of our open-source library, specifically addressing issue #104. The changes include fixing a non-existent reference and a typo in the
Library size comparisonsection of the "comparison.md" document. This section provides guidance for selecting a library based on factors like library size, unified authentication, and compatibility with various Databricks warehouses and SQL Python APIs. The updates clarify the required dependency size for simple applications and scripts, and offer more detailed information about each library option. We've also added a new subsection titledDetailed comparisonto provide a more comprehensive overview of each library's features. These changes are intended to help software engineers better understand which library is best suited for their specific needs, particularly for applications that require data transfer of large amounts of data serialized in Apache Arrow format and low result fetching latency, where we recommend using the Databricks SQL Connector for Python for efficient data transfer and low latency. - Fixed parsing message (#146). In this release, the warning message logged during the creation of a dashboard when a ParseError occurs has been updated to provide clearer and more detailed information about the parsing error. The new error message now includes the specific query being parsed and the exact parsing error, enabling developers to quickly identify the cause of parsing issues. This change ensures that engineers can efficiently diagnose and address parsing errors, improving the overall development and debugging experience with a more informative log format: "Parsing {query}: {error}".
- Improve dashboard as code (#108). The
Dashboardsclass in the 'dashboards.py' file has been updated to improve functionality and usability, with changes such as the addition of a type variableTfor type checking and more descriptive names for methods. Thesave_to_foldermethod now accepts aDashboardobject and returns aDashboardobject, and a new static methodcreate_dashboardhas been added. Additionally, two new methods_with_better_namesand_replace_nameshave been added for improved readability. Theget_dashboardmethod now returns aDashboardobject instead of a dictionary. Thesave_to_foldermethod now also formats SQL code before saving it to file. These changes aim to enhance the functionality and readability of the codebase and provide more user-friendly methods for interacting with theDashboardsclass. In addition to the changes in theDashboardsclass, there have been updates in the organization of the project structure. The 'queries/counter.sql' file has been moved to 'dashboards/one_counter/counter.sql' in the 'tests/integration' directory. This modification enhances the organization of the project. Furthermore, several tests for theDashboardsclass have been introduced in the 'databricks.labs.lsql.dashboards' module, demonstrating various functionalities of the class and ensuring that it functions as intended. The tests cover saving SQL and YML files to a specified folder, creating a dataset and a counter widget for each query, deploying dashboards with a given display name or dashboard ID, and testing the behavior of thesave_to_folderanddeploy_dashboardmethods. Lastly, the commit removes thetest_load_dashboardfunction and updates thetest_dashboard_creates_one_dataset_per_queryandtest_dashboard_creates_one_counter_widget_per_queryfunctions to use the updatedDashboardclass. A newreplace_recursivelyfunction is introduced to replace specific fields in a dataclass recursively. A new test functiontest_dashboards_deploys_exported_dashboard_definitionhas been added, which reads a dashboard definition from a JSON file, deploys it, and checks if it's successfully deployed using theDashboardsclass. A new test functiontest_dashboard_deploys_dashboard_the_same_as_created_dashboardhas also been added, which compares the original and deployed dashboards to ensure they are identical. Overall, these changes aim to improve the functionality and readability of the codebase and provide more user-friendly methods for interacting with theDashboardsclass, as well as enhance the organization of the project structure and add new tests for theDashboardsclass to ensure it functions as intended. - Infer fields from a query (#111). The
Dashboardsclass in thedashboards.pyfile has been updated with the addition of a new method,_get_fields, which accepts a SQL query as input and returns a list ofFieldobjects using thesqlglotlibrary to parse the query and extract the necessary information. Thecreate_dashboardmethod has been modified to call this new function when creatingQueryobjects for each dataset. If aParseErroroccurs, a warning is logged and iteration continues. This allows for the automatic population of fields when creating a new dashboard, eliminating the need for manual specification. Additionally, new tests have been added for invalid queries and for checking if the fields in a query have the expected names. These tests includetest_dashboards_skips_invalid_queryandtest_dashboards_gets_fields_with_expected_names, which utilize the caplog fixture and create temporary query files to verify functionality. Existing functionality related to creating dashboards remains unchanged. - Make constant all caps (#140). In this release, the project's 'dashboards.py' file has been updated to improve code readability and maintainability. A constant variable
_maximum_dashboard_widthhas been changed to all caps, becoming '_MAXIMUM_DASHBOARD_WIDTH'. This modification affects theDashboardsclass and its methods, particularly_get_fieldsand '_get_position'. The_get_positionmethod has been revised to use the new all caps constant variable. This change ensures better visibility of constants within the code, addressing issue #140. It's important to note that this modification only impacts the 'dashboards.py' file and does not affect any other functionalities. - Read display name from
dashboard.yml(#144). In this release, we have introduced a newDashboardMetadatadataclass that reads the display name of a dashboard from adashboard.ymlfile located in the dashboard's directory. If thedashboard.ymlfile is absent, the folder name will be used as the display name. This change improves the readability and maintainability of the dashboard configuration by explicitly defining the display name and reducing the need to specify widget information in multiple places. We have also added a new fixture calledmake_dashboardfor creating and cleaning up lakeview dashboards in the test suite. The fixture handles creation and deletion of the dashboard and provides an option to set a custom display name. Additionally, we have added and modified several unit tests to ensure the proper handling of theDashboardMetadataclass and the dashboard creation process, including tests for missing, present, or incorrectdisplay_namekeys in the YAML file. Thedashboards.deploy_dashboard()function has been updated to handle cases where onlydashboard_idis provided. - Set widget id in query header (#154). In this release, we've made significant improvements to widget metadata handling in our open-source library. We've introduced a new
WidgetMetadataclass that replaces the previousWidgetMetadatadataclass, now featuring apathattribute,spec_typeproperty, and optional parameters fororder,width,height, and_id. The_get_widgetsmethod has been updated to accept an Iterable ofWidgetMetadataobjects, and both_get_layoutsand_get_widgetsmethods now sort widgets using the order field. A new class method,WidgetMetadata.from_path, handles parsing widget metadata from a file path, replacing the removed_get_width_and_heightmethod. Additionally, theWidgetMetadataclass is now used in thedeploy_dashboardmethod, and the test suite for thedashboardsmodule has been enhanced with updatedtest_widget_metadata_replaces_width_and_heightandtest_widget_metadata_replaces_attributefunctions, as well as new tests for specific scenarios. Issue #154 has been addressed by setting the widget id in the query header, and the aforementioned changes improve flexibility and ease of use for dashboard development. - Use order key in query header if defined (#149). In this release, we've introduced a new feature to use an order key in the query header if defined, enhancing the flexibility and control over the dashboard creation process. The
WidgetMetadatadataclass now includes an optionalorderparameter of typeint, and the_get_arguments_parser()method accepts the--orderflag with typeint. Thereplace_from_arguments()method has been updated to support the neworderparameter, with a default value ofself.order. Thecreate_dashboard()method now implements a new_get_datasets()method to retrieve datasets from the dashboard folder and introduces a_get_widgets()method, which accepts a list of files, iterates over them, and yields tuples containing widgets and their corresponding metadata, including the order. These improvements enable the use of an order key in query headers, ensuring the correct order of widgets in the dashboard creation process. Additionally, a new test case has been added to verify the correct behavior of the dashboard deployment with a specified order key in the query header. This feature resolves issue #148. - Use widget width and height defined in query header (#147). In this release, the handling of metadata in SQL files has been updated to utilize the header of the file, instead of the first line, for improved readability and flexibility. This change includes a new WidgetMetadata class for defining the width and height of a widget in a dashboard, as well as new methods for parsing the widget metadata from a provided path. The release also includes updates to the documentation to cover the supported widget arguments
-w or --widthand '-h or --height', and resolves issue #114 by adding a test for deploying a dashboard with a big widget using a new functiontest_dashboard_deploys_dashboard_with_big_widget. Additionally, new test cases have been added for creating dashboards with custom-sized widgets based on query header width and height values, improving functionality and error handling.
Dependency updates:
- Bump actions/checkout from 4.1.2 to 4.1.3 (#97). The
actions/checkoutdependency has been updated from version 4.1.2 to 4.1.3 in theupdate-main-version.ymlfile. This new version includes a check to verify the git version before attempting to disablesparse-checkout, and adds an SSH user parameter to improve functionality and compatibility. The release notes and CHANGELOG.md file provide detailed information on the specific changes and improvements. The pull request also includes a detailed commit history and links to corresponding issues and pull requests on GitHub for transparency. You can review and merge the pull request to update theactions/checkoutdependency in your project. - Maintain PySpark compatibility for databricks.labs.lsql.core.Row (#99). In this release, we have added a new method
asDictto theRowclass in thedatabricks.labs.lsql.coremodule to maintain compatibility with PySpark. This method returns a dictionary representation of theRowobject, with keys corresponding to column names and values corresponding to the values in each column. Additionally, we have modified thefetchfunction in thebackends.pyfile to returnRowobjects ofpyspark.sqlwhen usingself._spark.sql(sql).collect(). This change is temporary and marked with aTODOcomment, indicating that it will be addressed in the future. We have also added error handling code in thefetchfunction to ensure the function operates as expected. TheasDictmethod in this implementation simply calls the existingas_dictmethod, meaning the behavior of theasDictmethod is identical to theas_dictmethod. Theas_dictmethod returns a dictionary representation of theRowobject, with keys corresponding to column names and values corresponding to the values in each column. The optionalrecursiveargument in theasDictmethod, when set toTrue, enables recursive conversion of nestedRowobjects to nested dictionaries. However, this behavior is not currently implemented, and therecursiveargument is alwaysFalseby default.
Dependency updates:
- Bump actions/checkout from 4.1.2 to 4.1.3 (#97).
- Added more
NotFounderror type (#94). In the latest update, thecore.pyfile in thedatabricks/labs/lsqlpackage has undergone enhancements to the error handling functionality. The_raise_if_neededfunction has been modified to raise aNotFounderror when the error message includes the phrase "does not exist". This update enables the system to categorize specific SQL query errors asNotFounderror messages, thereby improving the overall error handling and reporting capabilities. This change was a collaborative effort, as indicated by the co-authored-by statement in the commit.
- Fixing ovewrite integration tests (#92). A new enhancement has been implemented for the
overwritefeature's integration tests, addressing a concern with write operations. Two new variables,catalogand "schema", have been incorporated using theenv_or_skipfunction. These variables are utilized in thesave_tablemethod, which is now invoked twice with the same table, once with theappendand once with theoverwriteoption. The data in the table is retrieved and checked for accuracy after each call, employing the updatedRowclass with revised field namesfirstand "second", formerlynameand "id". This modification ensures the proper operation of theoverwritefeature during integration tests and resolves any related issues. The commit messageFixing overwrite integration testssignifies this change.
- Added catalog and schema parameters to execute and fetch (#90). In this release, we have added optional
catalogandschemaparameters to theexecuteandfetchmethods in theSqlBackendabstract base class, allowing for more flexibility when executing SQL statements in specific catalogs and schemas. These updates include new method signatures and their respective implementations in theSparkSqlBackendandDatabricksSqlBackendclasses. The new parameters control the catalog and schema used by theSparkSessioninstance in theSparkSqlBackendclass and theSqlClientinstance in theDatabricksSqlBackendclass. This enhancement enables better functionality in multi-catalog and multi-schema environments. Additionally, this change comes with unit tests and integration tests to ensure proper functionality. The new parameters can be used when calling theexecuteandfetchmethods. For example, with aSparkSqlBackendinstancespark_backend, you can execute a SQL statement in a specific catalog and schema with the following code:spark_backend.execute("SELECT * FROM my_table", catalog="my_catalog", schema="my_schema"). Similarly, thefetchmethod can also be used with the new parameters.
- Check UCX and LSQL for backwards compatibility (#78). In this release, we introduce a new GitHub Actions workflow, downstreams.yml, which automates unit testing for downstream projects upon changes made to the upstream project. The workflow runs on pull requests, merge groups, and pushes to the main branch and sets permissions for id-token, contents, and pull-requests. It includes a compatibility job that runs on Ubuntu, checks out the code, sets up Python, installs the toolchain, and accepts downstream projects using the databrickslabs/sandbox/downstreams action. The job matrix includes two downstream projects, ucx and remorph, and uses the build cache to speed up the pip install step. This feature ensures that changes to the upstream project do not break compatibility with downstream projects, maintaining a stable and reliable library for software engineers.
- Fixed
Builderobject has no attributesdk_configerror (#86). In this release, we've resolved aBuilderobject has no attributesdk_configerror that occurred when initializing a Spark session using theDatabricksSession.buildermethod. The issue was caused by using dot notation to access thesdk_configattribute, which is incorrect. This has been updated to the correct syntax ofsdkConfig. This change enables successful creation of the Spark session, preventing the error from recurring. TheDatabricksSessionclass and its methods, such asgetOrCreate, continue to be used for interacting with Databricks clusters and workspaces, while theWorkspaceClientclass manages Databricks resources within a workspace.
Dependency updates:
- Bump codecov/codecov-action from 1 to 4 (#84).
- Bump actions/setup-python from 4 to 5 (#83).
- Bump actions/checkout from 2.5.0 to 4.1.2 (#81).
- Bump softprops/action-gh-release from 1 to 2 (#80).
- Added support for
save_table(..., mode="overwrite")toStatementExecutionBackend(#74). In this release, we've added support for overwriting a table when saving data using thesave_tablemethod in theStatementExecutionBackend. Previously, attempting to use theoverwritemode would raise aNotImplementedError. Now, when this mode is specified, the method first truncates the table before inserting the new rows. The truncation is done using theexecutemethod to run aTRUNCATE TABLESQL command. Additionally, we've added a new integration test,test_overwrite, to thetest_deployment.pyfile to verify the newoverwritemode functionality. A new option,mode="overwrite", has been added to thesave_tablemethod, allowing for the existing data in the table to be deleted and replaced with the new data being written. We've also added two new test cases,test_statement_execution_backend_save_table_overwrite_empty_tableandtest_mock_backend_overwrite, to verify the new functionality. It's important to note that the method signature has been updated to include a default value for themodeparameter, setting it toappendby default. This change does not affect the functionality and only provides a more convenient default behavior for users of the method.
- Fixed PyPI badge (#72). In this release, we have implemented a fix to the PyPI badge in the README file of our open-source library. The PyPI badge displays the version of the package and serves as a quick reference for users. This fix ensures the accuracy and proper functioning of the badge, without involving any changes to the functionality or methods within the project. Software engineers can be assured that this update is limited to the README file, specifically the PyPI badge, and will not affect the overall functionality of the library.
- Fixed
no-cheatcheck (#71). In this release, we have made improvements to theno-cheatverification process for new code. Previously, the check for disabling the linter was prone to false positives when the string '# pylint: disable' appeared for reasons other than disabling the linter. The updated code now includes an additional filter to exclude the stringCHEATfrom the search, and the number of characters in the output is counted using thewc -ccommand. If the count is not zero, the script will terminate with an error message. This change enhances the accuracy of theno-cheatcheck, ensuring that the linter is being used correctly and that all new code meets our quality standards. - Removed upper bound on
sqlglotdependency (#70). In this update, we have removed the upper bound on thesqlglotdependency version in the project'spyproject.tomlfile. Previously, the version constraint requiredsqlglotto be at least 22.3.1 but less than 22.5.0. With this modification, there will be no upper limit, enabling the project to utilize any version greater than or equal to 22.3.1. This change provides the project with the flexibility to take advantage of future bug fixes, performance improvements, and new features available in newersqlglotpackage versions. Developers should thoroughly test the updated package version to ensure compatibility with the existing codebase.
- Fixed
Builderobject is not callable error (#67). In this release, we have made an enhancement to theBackendsclass in thedatabricks/labs/lsql/backends.pyfile. TheDatabricksSession.builder()method call in the__init__method has been changed toDatabricksSession.builder. This update uses thebuilderattribute to create a new instance ofDatabricksSessionwithout calling it like a function. Thesdk_configmethod is then used to configure the instance with the required settings. Finally, thegetOrCreatemethod is utilized to obtain aSparkSessionobject, which is then passed as a parameter to the parent class constructor. This modification simplifies the code and eliminates the error caused by treating thebuilderattribute as a callable object. Software engineers may benefit from this change by having a more streamlined and error-free codebase when working with the open-source library. - Prevent silencing of
pylint(#65). In this release, we have introduced a new job, "no-lint-disabled", to the GitHub Actions workflow for the repository. This job runs on the latest Ubuntu version and checks out the codebase with a full history. It verifies that no new instances of code suppressingpylintchecks have been added, by filtering the differences between the current branch and the main branch for new lines of code, and then checking if any of those new lines contain apylintdisable comment. If any such lines are found, the job will fail and print a message indicating the offending lines of code, thereby ensuring that the codebase maintains a consistent level of quality by not allowing linting checks to be bypassed. - Updated
_SparkBackend.fetch()to return iterator instead of list (#62). In this release, thefetch()method of the_SparkBackendclass has been updated to return an iterator instead of a list, which can result in reduced memory usage and improved performance, as the results of the SQL query can now be processed one element at a time. A new exception has been introduced to wrap any exceptions that occur during query execution, providing better debugging and error handling capabilities. Thetest_runtime_backend_fetch()unit test has been updated to reflect this change, and users of thefetch()method should be aware that it now returns an iterator and must be consumed to obtain the desired data. Thorough testing is recommended to ensure that the updated method still meets the needs of the application.
- Added support for common parameters in StatementExecutionBackend (#59). The
StatementExecutionBackendclass in thedatabricks.labs.lsqlpackage'sbackends.pyfile now supports the passing of common parameters through keyword arguments (kwargs). This enhancement allows for greater customization and flexibility in the backend's operation, as the kwargs are passed to theStatementExecutionExtconstructor. This change empowers users to control the behavior of the backend, making it more adaptable to various use cases. The key modification in this commit is the addition of the**kwargsparameter in the constructor signature and passing it toStatementExecutionExt, with no changes made to any methods within the class.
- Updating packages. In this update, the dependencies specified in the pyproject.toml file have been updated to more recent versions. The outdated packages "databricks-labs-blueprint~=0.4.0" and "databricks-sdk~=0.21.0" have been replaced with "databricks-labs-blueprint>=0.4.2" and "databricks-sdk>=0.22.0", respectively. These updates are expected to bring new features and bug fixes to the software. The dependency
sqlglotremains unchanged, with the same version requirement range of "sqlglot>=22.3.1,<22.5.0". These updates ensure that the software will function as intended, while also taking advantage of the enhancements provided by the more recent versions of the packages.
- Fixed row converter to properly handle nullable values (#53). In this release, the row converter in the
databricks.labs.lsql.coremodule has been updated to handle nullable values correctly. A new methodStatementExecutionExthas been added, which manages the handling of nullable values during SQL statement execution. TheRowclass has also been modified to include nullable values, improving the robustness and flexibility of SQL execution in dealing with various data types, including null values. These enhancements increase the overall reliability of the system, making it more production-ready. - Improved integration test coverage (#52). In this release, the project's integration test coverage has been significantly improved through several changes. A new function,
make_random(), has been added to theconftest.pyfile to generate a random string of fixed length, aiding in the creation of more meaningful and readable random strings for integration tests. A new file,test_deployment.py, has been introduced, containing a test function for deploying a database schema and verifying successful data retrieval via a view. Thetest_integration.pyfile has been renamed totest_core.py, with updates to thetest_fetch_onefunction to test thefetch_onemethod using a SQL query with an aliased value. Additionally, a newFoodataclass has been added to thetests/integration/views/__init__.pyfile, supporting integration test coverage. Lastly, a new SQL query has been added to the integration test suite, located in thesome.sqlfile, which retrieves data from a table namedfooin theinventoryschema. These changes aim to enhance the overall stability, reliability, and coverage of the project's integration tests. Note: The changes to the.gitignorefile and the improvements to theStatementExecutionBackendclass in thebackends.pyfile are not included in this summary, as they were described in the opening statement. - Rely on
hatchbeing present on the build machine (#54). In this release, we have made significant changes to how we manage our build process and toolchain configuration. We have removed the need to manually installhatchversion 1.7.0 in the build machine, and instead, rely on its presence, adding it to the list of required tools in the toolchain configuration. The command to create a virtual environment usinghatchhas also been added, and thepre_setupsection no longer includes installinghatch, assuming its availability. We have also updated thehatchpackage version from 1.7.0 to 1.9.4, which may include bug fixes, performance improvements, or new features. This change may impact the behavior of any existing functionality that relies onhatch. Thepyproject.tomlfile has been modified to update thefmtandverifysections, withruff check . --fixreplacingruff . --fixand the removal ofblack --check .andisort . --check-only. A new configuration forisorthas also been added to specify thedatabricks.labs.blueprintpackage as a known first-party package, enabling more precise management of imports related to that package. These changes simplify the build process and ensure that the project is using a more recent version of thehatchpackage for packaging and distributing Python projects. - Updated sqlglot requirement from ~=22.3.1 to >=22.3.1,<22.5.0 (#51). In this release, we have updated the version constraint for the
sqlglotpackage in our project'spyproject.tomlfile. Previously, we had set the constraint to~=22.3.1, allowing for any version with the same major and minor numbers but different patch numbers. With this update, we have changed the constraint to>=22.3.1,<22.5.0. This change enables our project to utilize bug fixes and improvements made in the latest patch versions ofsqlglot, while still preventing it from inadvertently using any breaking changes introduced in version 22.5.0 or later versions. This modification allows us to take advantage of the latest features and improvements insqlglotwhile maintaining compatibility and stability in our project.
Dependency updates:
- Updated sqlglot requirement from ~=22.3.1 to >=22.3.1,<22.5.0 (#51).
- Added
MockBackend.rows("col1", "col2")[(...), (...)]helper (#49). In this release, we have added a new helper methodMockBackend.rows("col1", "col2")[(...), (...)]to simplify testing withMockBackend. This method allows for the creation of rows using a more concise syntax, taking in the column names and a list of values to be used for each column, and returning a list ofRowobjects with the specified columns and values. Additionally, a__eq__method has been introduced to check if two rows are equal by converting the rows to dictionaries using the existingas_dictmethod and comparing them. The__contains__method has also been modified to improve the behavior of theinkeyword when used with rows, ensuring columns can be checked for membership in the row in a more intuitive and predictable manner. These changes make it easier to test and work withMockBackend, improving overall quality and maintainability of the project.
- Updated project metadata (#46). In this release, the project metadata has been updated to reflect changes in the library's capabilities and dependencies. The project now supports lightweight SQL statement execution using the Databricks SDK for Python, setting it apart from other solutions. The library size comparison in the documentation has been updated, reflecting an increase in the compressed and uncompressed size of Databricks Labs LightSQL, as well as the addition of a new direct dependency, SQLglot. The project's dependencies and URLs in the
pyproject.tomlfile have also been updated, including a version update fordatabricks-labs-blueprintand the removal of a specific range forPyYAML.
Dependency updates:
- Updated sqlglot requirement from ~=22.2.1 to ~=22.3.1 (#43).
- Ported
StatementExecutionExtfrom UCX (#31).
Initial commit