<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Permission Error When Running DELETE FROM in Warehousing &amp; Analytics</title>
    <link>https://community.databricks.com/t5/warehousing-analytics/permission-error-when-running-delete-from/m-p/61433#M1207</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to remove duplicate rows from my managed delta table in my unity catalog. I use a query on a SQL warehouse similar to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WITH cte AS (
SELECT 
id, ROW_NUMBER() OVER (PARTITION BY id,##,##,## ORDER BY ts) AS row_num
FROM 
    catalog.schema.table
) DELETE FROM cte WHERE row_num &amp;gt; 1;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using this I get following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Could not verify permissions for DeleteFromTable (row_num#734 &amp;gt; 1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I checked the grants where I have ALL PRIVILEGES and the IAM Role (we are on AWS) for the external location and I have permissions to delete from S3. Is there anything else I have to set to be able to delete rows or is there anything wrong with my query? I couldn't find anything online.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Feb 2024 09:53:33 GMT</pubDate>
    <dc:creator>Carsten03</dc:creator>
    <dc:date>2024-02-22T09:53:33Z</dc:date>
    <item>
      <title>Permission Error When Running DELETE FROM</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/permission-error-when-running-delete-from/m-p/61433#M1207</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to remove duplicate rows from my managed delta table in my unity catalog. I use a query on a SQL warehouse similar to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WITH cte AS (
SELECT 
id, ROW_NUMBER() OVER (PARTITION BY id,##,##,## ORDER BY ts) AS row_num
FROM 
    catalog.schema.table
) DELETE FROM cte WHERE row_num &amp;gt; 1;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using this I get following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Could not verify permissions for DeleteFromTable (row_num#734 &amp;gt; 1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I checked the grants where I have ALL PRIVILEGES and the IAM Role (we are on AWS) for the external location and I have permissions to delete from S3. Is there anything else I have to set to be able to delete rows or is there anything wrong with my query? I couldn't find anything online.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 09:53:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/permission-error-when-running-delete-from/m-p/61433#M1207</guid>
      <dc:creator>Carsten03</dc:creator>
      <dc:date>2024-02-22T09:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Permission Error When Running DELETE FROM</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/permission-error-when-running-delete-from/m-p/61448#M1208</link>
      <description>&lt;P&gt;I have first tried to use _metadata.row_index to delete the correct rows but also this resulted in an error. My solution was now to use spark and overwrite the table.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;table_name = "catalog.schema.table"
df = spark.read.table(table_name)
count_df = df.count()
dedup = df.drop_duplicates()
count_dedup = dedup.count()
count_df - count_dedup
dedup.write.mode("overwrite").saveAsTable(table_name)
assert spark.read.table(table_name).count() == count_dedup&lt;/LI-CODE&gt;&lt;P&gt;I would still be interested if anyone has a good approach using SQL for this.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 11:15:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/permission-error-when-running-delete-from/m-p/61448#M1208</guid>
      <dc:creator>Carsten03</dc:creator>
      <dc:date>2024-02-22T11:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Permission Error When Running DELETE FROM</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/permission-error-when-running-delete-from/m-p/65026#M1254</link>
      <description>&lt;P&gt;Pitching in here since i had the same problem: the issue you can't delete from a CTE; you need to delete from the actual table which can be joined to the CTE.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2024 18:24:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/permission-error-when-running-delete-from/m-p/65026#M1254</guid>
      <dc:creator>ac0</dc:creator>
      <dc:date>2024-03-29T18:24:30Z</dc:date>
    </item>
  </channel>
</rss>

