<?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 Issue with filter_by in Databricks SQL Query History API (/api/2.0/sql/history/queries) in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/issue-with-filter-by-in-databricks-sql-query-history-api-api-2-0/m-p/108449#M43051</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm trying to use the &lt;STRONG&gt;filter_by&lt;/STRONG&gt; parameter in a GET request to &lt;STRONG&gt;/api/2.0/sql/history/queries&lt;/STRONG&gt;, but I keep getting a 400 Bad Request error. When I use max_results, it works fine, but adding filter_by causes the request to fail.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Example value for &lt;/SPAN&gt;filter_by&lt;SPAN&gt; in the request:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{
   "statuses":["FINISHED","CANCELED"],
   "query_start_time_range":{
       "start_time_ms" : 1640995200000, 
       "end_time_ms" : 1641081599000
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Response&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{
    "error_code": "MALFORMED_REQUEST",
    "message": "Could not parse request object: Expected 'START_OBJECT' not 'VALUE_STRING'\n at [Source: (ByteArrayInputStream); line: 1, column: 15]\n at [Source: java.io.ByteArrayInputStream@28488ac8; line: 1, column: 15]"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried several variations, but I keep getting the same error. Unfortunately, the documentation does not include an example of how to format filter_by correctly in the query string.&lt;/P&gt;&lt;P&gt;Has anyone successfully used filter_by in this API? If so, could you share a working example?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Sun, 02 Feb 2025 15:25:29 GMT</pubDate>
    <dc:creator>lukamu</dc:creator>
    <dc:date>2025-02-02T15:25:29Z</dc:date>
    <item>
      <title>Issue with filter_by in Databricks SQL Query History API (/api/2.0/sql/history/queries)</title>
      <link>https://community.databricks.com/t5/data-engineering/issue-with-filter-by-in-databricks-sql-query-history-api-api-2-0/m-p/108449#M43051</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm trying to use the &lt;STRONG&gt;filter_by&lt;/STRONG&gt; parameter in a GET request to &lt;STRONG&gt;/api/2.0/sql/history/queries&lt;/STRONG&gt;, but I keep getting a 400 Bad Request error. When I use max_results, it works fine, but adding filter_by causes the request to fail.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Example value for &lt;/SPAN&gt;filter_by&lt;SPAN&gt; in the request:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{
   "statuses":["FINISHED","CANCELED"],
   "query_start_time_range":{
       "start_time_ms" : 1640995200000, 
       "end_time_ms" : 1641081599000
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Response&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{
    "error_code": "MALFORMED_REQUEST",
    "message": "Could not parse request object: Expected 'START_OBJECT' not 'VALUE_STRING'\n at [Source: (ByteArrayInputStream); line: 1, column: 15]\n at [Source: java.io.ByteArrayInputStream@28488ac8; line: 1, column: 15]"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried several variations, but I keep getting the same error. Unfortunately, the documentation does not include an example of how to format filter_by correctly in the query string.&lt;/P&gt;&lt;P&gt;Has anyone successfully used filter_by in this API? If so, could you share a working example?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 15:25:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/issue-with-filter-by-in-databricks-sql-query-history-api-api-2-0/m-p/108449#M43051</guid>
      <dc:creator>lukamu</dc:creator>
      <dc:date>2025-02-02T15:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with filter_by in Databricks SQL Query History API (/api/2.0/sql/history/queries)</title>
      <link>https://community.databricks.com/t5/data-engineering/issue-with-filter-by-in-databricks-sql-query-history-api-api-2-0/m-p/108461#M43053</link>
      <description>&lt;P&gt;Here's how you can do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;import requests&lt;/P&gt;
&lt;P class="p1"&gt;import json&lt;/P&gt;
&lt;P class="p1"&gt;api_endpoint = "&lt;A href="https://test-1.cloud.databricks.com/api/2.0/sql/history/queries" target="_blank"&gt;https://test-1.cloud.databricks.com/api/2.0/sql/history/queries&lt;/A&gt;"&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;headers = {&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;"Authorization": "Bearer XXXXXX”&lt;/P&gt;
&lt;P class="p1"&gt;}&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;params = json.dumps({&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;"filter_by": {&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;"user_id": "5342291138747455",&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;# Example filter: queries executed by a specific user&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;"query_start_time_range": {&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;"start_time_ms": 1640995200000,&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;# Example start time in milliseconds&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;"end_time_ms": 1641081599000&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;# Example end time in milliseconds&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;}&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;}&lt;/P&gt;
&lt;P class="p1"&gt;})&lt;/P&gt;
&lt;P class="p1"&gt;response = requests.get(api_endpoint, headers=headers, params=params)&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;# Parse the response&lt;/P&gt;
&lt;P class="p1"&gt;data = response.json()&lt;/P&gt;
&lt;P class="p1"&gt;print(json.dumps(data, indent=4))&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 21:57:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/issue-with-filter-by-in-databricks-sql-query-history-api-api-2-0/m-p/108461#M43053</guid>
      <dc:creator>Alberto_Umana</dc:creator>
      <dc:date>2025-02-02T21:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with filter_by in Databricks SQL Query History API (/api/2.0/sql/history/queries)</title>
      <link>https://community.databricks.com/t5/data-engineering/issue-with-filter-by-in-databricks-sql-query-history-api-api-2-0/m-p/108593#M43090</link>
      <description>&lt;P&gt;Hi Alberto,&lt;/P&gt;&lt;P&gt;I just wanted to thank you for your suggestion. Thanks to your input, I was able to successfully use the API with filters. I really appreciate your help!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 14:32:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/issue-with-filter-by-in-databricks-sql-query-history-api-api-2-0/m-p/108593#M43090</guid>
      <dc:creator>lukamu</dc:creator>
      <dc:date>2025-02-03T14:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with filter_by in Databricks SQL Query History API (/api/2.0/sql/history/queries)</title>
      <link>https://community.databricks.com/t5/data-engineering/issue-with-filter-by-in-databricks-sql-query-history-api-api-2-0/m-p/108594#M43091</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/147391"&gt;@lukamu&lt;/a&gt;, glad that it worked for you!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 14:37:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/issue-with-filter-by-in-databricks-sql-query-history-api-api-2-0/m-p/108594#M43091</guid>
      <dc:creator>Alberto_Umana</dc:creator>
      <dc:date>2025-02-03T14:37:27Z</dc:date>
    </item>
  </channel>
</rss>

