โ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...
โ09-09-2024 09:19 AM
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
โ09-09-2024 09:51 AM
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.
โ11-12-2024 01:16 PM
I was getting same error in python notebook and I found typo in my sql:
Changing from
ALTER TABLE table_name SET OWNER TO 'principal'
to below fixed the issue.
ALTER TABLE table_name SET OWNER TO `principal`
Passionate about hosting events and connecting people? Help us grow a vibrant local communityโsign up today to get started!
Sign Up Now