databricks / cli

Databricks CLI
Other
132 stars 50 forks source link

No overwrite option for "databricks lakeview create", cli v0.225.0 #1692

Closed topcat9131 closed 1 month ago

topcat9131 commented 1 month ago

Describe the issue

No overwrite option for "databricks lakeview create". User cannot update a lakeview dashboard if a dashboard with the same name already exists.

Steps to reproduce the behavior

Please list the steps required to reproduce the issue, for example:

  1. Run databricks lakeview create SmartDashName --serialized-dashboard "$dashJsonRaw" -o json
  2. Run same command again: databricks lakeview create SmartDashName --serialized-dashboard "$dashJsonRaw" -o json
  3. Error: >'Error: Unable to register dashboard [dashboards/xxxxxxx00000yyyyyyyy]. Caused by Node named 'SmartDashName .lvdash.json' already exists'

Expected Behavior

An overwrite option should exist if by default overwrite is not allowed.

Actual Behavior

No overwrite option. User must:

  1. List all dashboards by running databricks lakeview list.
  2. Parse the list to get the dashboard ID of the dashboard to update.
  3. Run databricks lakeview trash xxxxxxx00000yyyyyyyy to delete it.
  4. Finally run command: databricks lakeview create SmartDashName --serialized-dashboard "$dashJsonRaw" -o json

OS and CLI version

Windows, Linux, CLi v0.225.0

Is this a regression?

Did this work in a previous version of the CLI?: No

Debug Logs

Output logs if you run the command with debug logs enabled. Example: databricks clusters list --log-level=debug. Redact if needed

INFO start pid=12340 version=0.225.0 args="C:\ProgramData\chocolatey\lib\databricks-cli\tools\databricks.exe, lakeview, create, SmartDashName, --serialized-dashboard, {###RAW JSON REMOVED###}, -o, json, --log-level=debug" 14:17:34 DEBUG Loading DEFAULT profile from C:\Users\00000/.databrickscfg pid=12340 sdk=true 14:17:36 DEBUG POST /api/2.0/lakeview/dashboards > { > "display_name": "SmartDashName", > "serialized_dashboard": "{###RAW JSON REMOVED###}... (16610 more bytes)" > } < HTTP/2.0 400 Bad Request < { < "error_code": "RESOURCE_ALREADY_EXISTS", < "message": "Unable to register dashboard [dashboards/xxxxxxx00000yyyyyyyy]. Caused by Node named... (54 more bytes)" < } pid=12340 sdk=true 14:17:36 DEBUG non-retriable error: Unable to register dashboard [dashboards/xxxxxxx00000yyyyyyyy]. Caused by Node named 'SmartDashName.lvdash.json' already exists pid=12340 sdk=true Error: Unable to register dashboard [dashboards/xxxxxxx00000yyyyyyyy]. Caused by Node named 'SmartDashName.lvdash.json' already exists 14:17:36 ERROR failed execution pid=12340 exit_code=1 error="Unable to register dashboard [dashboards/xxxxxxx00000yyyyyyyy]. Caused by Node named 'SmartDashName.lvdash.json' already exists"

andrewnester commented 1 month ago

You can use databricks lakeview update command to update existing Lakeview dashboard

topcat9131 commented 1 month ago

You can use databricks lakeview update command to update existing Lakeview dashboard

That's not much better, you still need to check if the dashboard exists before using update.

  1. List all dashboards by running databricks lakeview list.
  2. Parse the list to get the dashboard ID of the dashboard to update.
  3. Run databricks lakeview update xxxxxxx00000yyyyyyyy to update it.
andrewnester commented 1 month ago

I see, indeed, unfortunately API does not support updating dashboard by name and only accept ID as names might be duplicated. We'll pass on the feedback to corresponding API team