Skip to content

Adding uc name validation in cli and demo's#260

Open
ravi-databricks wants to merge 3 commits intofeature/v0.0.11from
issue_225
Open

Adding uc name validation in cli and demo's#260
ravi-databricks wants to merge 3 commits intofeature/v0.0.11from
issue_225

Conversation

@ravi-databricks
Copy link
Contributor

@ravi-databricks ravi-databricks commented Feb 11, 2026

Added validation as per sql_ref_identifiers for uc catalog name in demo and cli

@ravi-databricks ravi-databricks added the enhancement New feature or request label Feb 11, 2026
@ravi-databricks ravi-databricks added this to the v0.0.11 milestone Feb 11, 2026
@ravi-databricks ravi-databricks linked an issue Feb 11, 2026 that may be closed by this pull request
@ravi-databricks ravi-databricks self-assigned this Feb 11, 2026
@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.81%. Comparing base (de5e897) to head (cfe5122).
⚠️ Report is 1 commits behind head on feature/v0.0.11.

Additional details and impacted files
@@                 Coverage Diff                 @@
##           feature/v0.0.11     #260      +/-   ##
===================================================
+ Coverage            89.73%   89.81%   +0.07%     
===================================================
  Files                   10       10              
  Lines                 2094     2110      +16     
  Branches               405      411       +6     
===================================================
+ Hits                  1879     1895      +16     
  Misses                 116      116              
  Partials                99       99              
Flag Coverage Δ
unittests 89.81% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The initialized runner configuration.
"""
run_id = uuid.uuid4().hex
self.validate_uc_catalog_name(self.args["uc_catalog_name"])
Copy link

Choose a reason for hiding this comment

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

Maybe we can do self.args.GET("uc_catalog_name") instead of self.args["uc_catalog_name"] and then in validate_uc_catalog_name throw an explicit error when catalog name is None? Because if it isn't present we'll get generic Python error that key isn't found

"""
if not name or not name.strip():
raise ValueError("'uc_catalog_name' must not be empty.")
if not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*$', name):
Copy link

Choose a reason for hiding this comment

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

No. It's incorrect - per documentation, we can use any unicode character:

Copy link

@lammic lammic Feb 27, 2026

Choose a reason for hiding this comment

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

only delimited identifiers can use any unicode character. Non delimited identifiers have restrictions.

Instead of rejecting the input, we can have another approach: if we spot a character not allowed in the non-delimited version, we automatically add backticks to convert to delimited identifier

src/cli.py Outdated
if self.onboard_layer.lower() not in ["bronze", "silver", "bronze_silver"]:
raise ValueError("onboard_layer must be one of bronze, silver, bronze_silver")
if self.uc_enabled and self.uc_catalog_name:
if not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*$', self.uc_catalog_name):
Copy link

Choose a reason for hiding this comment

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

Why we have duplicate code?

logger = logging.getLogger('databricks.labs.dltmeta')


def validate_uc_catalog_name(name):
Copy link

Choose a reason for hiding this comment

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

Why do we have the same implementation in the two places?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix hyphen catalog name

3 participants