<?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 Re: SQL Warehouse REST statement execution validation fails with DECLARE SET in Warehousing &amp; Analytics</title>
    <link>https://community.databricks.com/t5/warehousing-analytics/sql-warehouse-rest-statement-execution-validation-fails-with/m-p/86235#M1512</link>
    <description>&lt;P&gt;Had to try for myself and it seems the sql execution context in the REST API is different than that of an *.sql script, notebook or query made against an sql warehouse through the ui. The error stems from the fact that the SET command can also be used to set a session parameter as well (without the var) and the runtime gets confused because there is the extra var between set and the value assignment.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Obviously the are at least several other ways to achieve the above query without using an sql variable, but it would probably be nice to have a warning in the docs that the set var statement isn't supported through the rest api.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Aug 2024 08:01:03 GMT</pubDate>
    <dc:creator>adriennn</dc:creator>
    <dc:date>2024-08-29T08:01:03Z</dc:date>
    <item>
      <title>SQL Warehouse REST statement execution validation fails with DECLARE SET</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/sql-warehouse-rest-statement-execution-validation-fails-with/m-p/84189#M1503</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm using the REST API for SQL Warehouse in order to execute queries. I have experienced multiple times that query validation fails over the REST API, while executing the same query in the Databricks UI on the same cluster succeeds. An example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[PARSE_SYNTAX_ERROR] Syntax error at or near 'SET': extra input 'SET'. SQLSTATE: 42601 (line 3, pos 8)

== SQL ==

DECLARE VARIABLE max_offset int;
SET VAR max_offset = (
--------^^^
select MAX(_Offset) from mycatalog.myschema.mytable
);

SELECT * from mycatalog.myschema.mytable
WHERE `_Offset` = max_offset&lt;/LI-CODE&gt;&lt;P&gt;If I paste the same code into the UI it executes without issues.&lt;/P&gt;&lt;P&gt;I have had other types of queries failing in a similar manner when using the CACHE keyword over the REST API.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2024 08:26:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/sql-warehouse-rest-statement-execution-validation-fails-with/m-p/84189#M1503</guid>
      <dc:creator>mathiaskvist</dc:creator>
      <dc:date>2024-08-26T08:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Warehouse REST statement execution validation fails with DECLARE SET</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/sql-warehouse-rest-statement-execution-validation-fails-with/m-p/86209#M1510</link>
      <description>&lt;P&gt;The only times I have seen errors with SET VARIABLE is when the result of the query that is supposed to give the value of the variable is throwing an error; in this case the actual error is hidden by the error raised by SET.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 07:02:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/sql-warehouse-rest-statement-execution-validation-fails-with/m-p/86209#M1510</guid>
      <dc:creator>adriennn</dc:creator>
      <dc:date>2024-08-29T07:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Warehouse REST statement execution validation fails with DECLARE SET</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/sql-warehouse-rest-statement-execution-validation-fails-with/m-p/86221#M1511</link>
      <description>&lt;P&gt;Thanks for your reply. However, I don't think that is the case here, since I can manually run the exact same query without issue.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 07:30:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/sql-warehouse-rest-statement-execution-validation-fails-with/m-p/86221#M1511</guid>
      <dc:creator>mathiaskvist</dc:creator>
      <dc:date>2024-08-29T07:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Warehouse REST statement execution validation fails with DECLARE SET</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/sql-warehouse-rest-statement-execution-validation-fails-with/m-p/86235#M1512</link>
      <description>&lt;P&gt;Had to try for myself and it seems the sql execution context in the REST API is different than that of an *.sql script, notebook or query made against an sql warehouse through the ui. The error stems from the fact that the SET command can also be used to set a session parameter as well (without the var) and the runtime gets confused because there is the extra var between set and the value assignment.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Obviously the are at least several other ways to achieve the above query without using an sql variable, but it would probably be nice to have a warning in the docs that the set var statement isn't supported through the rest api.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 08:01:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/sql-warehouse-rest-statement-execution-validation-fails-with/m-p/86235#M1512</guid>
      <dc:creator>adriennn</dc:creator>
      <dc:date>2024-08-29T08:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Warehouse REST statement execution validation fails with DECLARE SET</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/sql-warehouse-rest-statement-execution-validation-fails-with/m-p/87188#M1520</link>
      <description>&lt;P&gt;Okay, that does make some sense. However, it is strange that the execution context is different, I would expect it to be equivalent with the UI.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would be really great to document how the execution context differs. As mentioned I had the same issue with the CACHE statement. There might be more cases that are handled differently.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 10:08:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/sql-warehouse-rest-statement-execution-validation-fails-with/m-p/87188#M1520</guid>
      <dc:creator>mathiaskvist</dc:creator>
      <dc:date>2024-09-02T10:08:22Z</dc:date>
    </item>
  </channel>
</rss>

