Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix normalize case input in cli #258

Merged
merged 2 commits into from
Aug 27, 2024
Merged

Conversation

JCZuurmond
Copy link
Member

@JCZuurmond JCZuurmond commented Aug 27, 2024

The Databricks cli currently only supports string input

  • Tested manually

The Databricks cli currently only supports string input
Copy link

github-actions bot commented Aug 27, 2024

✅ 34/34 passed, 3 skipped, 9m4s total

Running from acceptance #360

@HariGS-DB
Copy link
Contributor

is this still required given we merged databrickslabs/ucx#2495

Copy link
Collaborator

@nfx nfx left a comment

Choose a reason for hiding this comment

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

lgtm

@JCZuurmond JCZuurmond force-pushed the fix/normalize-case-parsing-in-cli branch from ae391bc to 4b08983 Compare August 27, 2024 14:23
@JCZuurmond
Copy link
Member Author

is this still required given we merged databrickslabs/ucx#2495

Not required, but more consistent with the other cli command

@JCZuurmond JCZuurmond merged commit e6006ae into main Aug 27, 2024
8 checks passed
@JCZuurmond JCZuurmond deleted the fix/normalize-case-parsing-in-cli branch August 27, 2024 14:36
nfx added a commit that referenced this pull request Aug 30, 2024
* Fixed dataclass field types ([#257](#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 returned `f.type` is 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_for` function in the `backends.py` file, 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](#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 the `test_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](#258)). In this release, we have updated the `fmt` command in the `cli.py` file to allow users to specify whether they want to normalize the case of SQL files when formatting. The `normalize_case` parameter now defaults to the string `"true"` and checks if it is in the `STRING_AFFIRMATIVES` list to determine whether to normalize the case of SQL files. Additionally, we have introduced a new optional `normalize_case` parameter in the `format` method of the `dashboards.py` file in the Databricks CLI, which normalizes the identifiers in the query to lower case when set to `True`. We have also added support for a new `normalize_case` parameter in the `QueryTile.format()` method, which prevents the automatic normalization of string input to uppercase when set to `False`. 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.
@nfx nfx mentioned this pull request Aug 30, 2024
nfx added a commit that referenced this pull request Aug 30, 2024
* Fixed dataclass field types
([#257](#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 returned `f.type`
is 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_for` function in the `backends.py` file, 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](#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
the `test_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](#258)). In this
release, we have updated the `fmt` command in the `cli.py` file to allow
users to specify whether they want to normalize the case of SQL files
when formatting. The `normalize_case` parameter now defaults to the
string `"true"` and checks if it is in the `STRING_AFFIRMATIVES` list to
determine whether to normalize the case of SQL files. Additionally, we
have introduced a new optional `normalize_case` parameter in the
`format` method of the `dashboards.py` file in the Databricks CLI, which
normalizes the identifiers in the query to lower case when set to
`True`. We have also added support for a new `normalize_case` parameter
in the `QueryTile.format()` method, which prevents the automatic
normalization of string input to uppercase when set to `False`. 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants