<?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 ERROR: key not found in SQL when trying to pass the result of a CTE as a function parameter in Warehousing &amp; Analytics</title>
    <link>https://community.databricks.com/t5/warehousing-analytics/error-key-not-found-in-sql-when-trying-to-pass-the-result-of-a/m-p/91398#M1565</link>
    <description>&lt;P&gt;Hi Community,&lt;BR /&gt;I try to&amp;nbsp;pass the result of a CTE as a function parameter as code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;WITH t1 AS (
    SELECT array_join(collect_list(output), ',') AS x
    FROM my_catalog.my_db.get_x(:startTime, :endTime)
)
SELECT 'AM_offline' as Type, CASE WHEN offline_ratio &amp;gt; 1.5 THEN 'no-Go' ELSE 'Go' END as Status
FROM my_catalog.my_db.get_ratio (
    _startTime =&amp;gt; :startTime, 
    _endTime =&amp;gt; :endTime, 
    _x =&amp;gt; (SELECT x FROM t1 LIMIT 1)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I encounter the&amp;nbsp;key not found error.&amp;nbsp;&lt;SPAN&gt;Can someone tell me, what is the reason of such error?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;key not found: 863&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Sep 2024 09:19:24 GMT</pubDate>
    <dc:creator>JS_L</dc:creator>
    <dc:date>2024-09-23T09:19:24Z</dc:date>
    <item>
      <title>ERROR: key not found in SQL when trying to pass the result of a CTE as a function parameter</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/error-key-not-found-in-sql-when-trying-to-pass-the-result-of-a/m-p/91398#M1565</link>
      <description>&lt;P&gt;Hi Community,&lt;BR /&gt;I try to&amp;nbsp;pass the result of a CTE as a function parameter as code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;WITH t1 AS (
    SELECT array_join(collect_list(output), ',') AS x
    FROM my_catalog.my_db.get_x(:startTime, :endTime)
)
SELECT 'AM_offline' as Type, CASE WHEN offline_ratio &amp;gt; 1.5 THEN 'no-Go' ELSE 'Go' END as Status
FROM my_catalog.my_db.get_ratio (
    _startTime =&amp;gt; :startTime, 
    _endTime =&amp;gt; :endTime, 
    _x =&amp;gt; (SELECT x FROM t1 LIMIT 1)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I encounter the&amp;nbsp;key not found error.&amp;nbsp;&lt;SPAN&gt;Can someone tell me, what is the reason of such error?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;key not found: 863&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2024 09:19:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/error-key-not-found-in-sql-when-trying-to-pass-the-result-of-a/m-p/91398#M1565</guid>
      <dc:creator>JS_L</dc:creator>
      <dc:date>2024-09-23T09:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: key not found in SQL when trying to pass the result of a CTE as a function parameter</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/error-key-not-found-in-sql-when-trying-to-pass-the-result-of-a/m-p/91551#M1571</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/122407"&gt;@JS_L&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Could you also attach definition of my_db.get_ration function? Most probably _x parameter expects certain datatype and when you're using subquery you're passing dataframe.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2024 09:33:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/error-key-not-found-in-sql-when-trying-to-pass-the-result-of-a/m-p/91551#M1571</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2024-09-24T09:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: key not found in SQL when trying to pass the result of a CTE as a function parameter</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/error-key-not-found-in-sql-when-trying-to-pass-the-result-of-a/m-p/91643#M1574</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/110502"&gt;@szymon_dybczak&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for replying. I don't the issue is related to datatype, since the query works if I pass the subquery to _x parameter without CTE.&lt;/P&gt;&lt;P&gt;Please see as below code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;SELECT 'AM_offline' as Type, CASE WHEN offline_ratio &amp;gt; 1.5 THEN 'no-Go' ELSE 'Go' END as Status
FROM my_catalog.my_db.get_ratio (
    _startTime =&amp;gt; :startTime, 
    _endTime =&amp;gt; :endTime, 
    _x =&amp;gt; (
        SELECT array_join(collect_list(output), ',') 
        FROM my_catalog.my_db.get_x(:startTime, :endTime)
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 03:46:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/error-key-not-found-in-sql-when-trying-to-pass-the-result-of-a/m-p/91643#M1574</guid>
      <dc:creator>JS_L</dc:creator>
      <dc:date>2024-09-25T03:46:12Z</dc:date>
    </item>
  </channel>
</rss>

