โ09-09-2024 03:45 AM
It's not possible to use the ALTER TABLE tblname OWNER TO serviceprinc1 command in Azure Databricks, as this isn't supported. I was trying to set a catalog table's ownership, but it resulted in an error. How can I achieve this using a script
โ09-09-2024 04:08 AM
Hi @Nid-cbs ,
Are you sure that you're using correct syntax? According to documentation it should be:
ALTER TABLE table_name SET OWNER TO principal
โ09-09-2024 05:32 AM
ALTER TABLE catalogue.schema.table OWNER TO GUID
the rror is [PARSE_SYNTAX_ERROR] Syntax error at or near 'OWNER'.(line 1, pos 43)
โ09-09-2024 05:38 AM
I still think that you're using bad synxtax. You're missing SET keyword before OWNER. Try as below:
ALTER TABLE catalogue.schema.table SET OWNER TO GUID
โ09-09-2024 05:47 AM
Thanks. Still the same error
[PARSE_SYNTAX_ERROR] Syntax error at or near 'OWNER'.(line 1, pos 35)
โ09-09-2024 06:54 AM - edited โ09-09-2024 06:57 AM
Hi @Nid-cbs ,
It depends on how you are using the code.
Make sure you are using .sql notebook type or %sql magic command, and not spark.sql.
Also, the owner should be wrapped in ` backtick characters:
%sql
ALTER TABLE test_table SET OWNER TO `owner`
More on that:
https://stackoverflow.com/questions/68804903/databricks-alter-table-owner-to-userid-is-not-working-w...
a month ago
it turns out that The ALTER TABLE statement in Databricks SQL does not support changing the owner of a table directly.It seems we need to use REST API to do the same
a month ago
Thanks for the information. This is very strange though. I'll check it tommorrow. It should work in a notebook with %sql cell.
It won't work if use spark.sql("ALTER TABLE test_table SET OWNER TO `owner_name`") though.
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโt want to miss the chance to attend and share knowledge.
If there isnโt a group near you, start one and help create a community that brings people together.
Request a New Group