<?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: null object while running a query against parquet in Warehousing &amp; Analytics</title>
    <link>https://community.databricks.com/t5/warehousing-analytics/null-object-while-running-a-query-against-parquet/m-p/75627#M1406</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Without additional context, my assumption is that since all the values are null, it's impossible to determine the column's type. Do you have a default value? You could consider coalescing with that value. For example, if the default value is false:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT 
  SUM(
    CASE WHEN COALESCE(
      CAST(match_result.ecommerce.has_online_payments AS BOOLEAN),
      FALSE
    ) THEN
      1 
    ELSE 
      0 
    END
  )
FROM
  parquet.`s3://folder_path/*`&lt;/LI-CODE&gt;&lt;P&gt;Otherwise you can handle the null values as&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;&amp;nbsp;suggested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jun 2024 20:08:12 GMT</pubDate>
    <dc:creator>giuseppegrieco</dc:creator>
    <dc:date>2024-06-24T20:08:12Z</dc:date>
    <item>
      <title>null object while running a query against parquet</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/null-object-while-running-a-query-against-parquet/m-p/75604#M1404</link>
      <description>&lt;P&gt;I am running this query against parquet:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT 
SUM(CASE WHEN match_result.ecommerce.has_online_payments THEN 1 ELSE 0 END)
FROM parquet.`s3://folder_path/*`&lt;/LI-CODE&gt;&lt;P&gt;when all the values of the object `match_result.ecommerce` are null, I get the following error:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[INVALID_EXTRACT_BASE_FIELD_TYPE] Can't extract a value from "match_result.ecommerce". Need a complex type [STRUCT, ARRAY, MAP] but got "INT". SQLSTATE: 42000; line 2, pos 14&lt;/LI-CODE&gt;&lt;P&gt;How can I fix this issue?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 17:39:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/null-object-while-running-a-query-against-parquet/m-p/75604#M1404</guid>
      <dc:creator>Shaimaa</dc:creator>
      <dc:date>2024-06-24T17:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: null object while running a query against parquet</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/null-object-while-running-a-query-against-parquet/m-p/75627#M1406</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Without additional context, my assumption is that since all the values are null, it's impossible to determine the column's type. Do you have a default value? You could consider coalescing with that value. For example, if the default value is false:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT 
  SUM(
    CASE WHEN COALESCE(
      CAST(match_result.ecommerce.has_online_payments AS BOOLEAN),
      FALSE
    ) THEN
      1 
    ELSE 
      0 
    END
  )
FROM
  parquet.`s3://folder_path/*`&lt;/LI-CODE&gt;&lt;P&gt;Otherwise you can handle the null values as&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;&amp;nbsp;suggested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 20:08:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/null-object-while-running-a-query-against-parquet/m-p/75627#M1406</guid>
      <dc:creator>giuseppegrieco</dc:creator>
      <dc:date>2024-06-24T20:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: null object while running a query against parquet</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/null-object-while-running-a-query-against-parquet/m-p/75628#M1407</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;Thank you but the issue persists even if I add a null check:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT 
SUM(CASE WHEN match_result IS NOT NULL AND match_result.ecommerce IS NOT NULL AND match_result.ecommerce.has_online_payments THEN 1 ELSE 0 END) 
FROM parquet.`s3://folder_path/*`&lt;/LI-CODE&gt;&lt;P&gt;the values in this particular file for&amp;nbsp;&lt;SPAN&gt;"match_result.ecommerce" are null but they are not always null for all files that I run the query against. How can I tell specify that the condition should evaluate to 0 if the value of&amp;nbsp;"match_result.ecommerce" is null instead of erroring out?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 20:09:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/null-object-while-running-a-query-against-parquet/m-p/75628#M1407</guid>
      <dc:creator>Shaimaa</dc:creator>
      <dc:date>2024-06-24T20:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: null object while running a query against parquet</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/null-object-while-running-a-query-against-parquet/m-p/75700#M1415</link>
      <description>&lt;P&gt;None of these solutions with coalesce work because it's "&lt;SPAN&gt;match_result.ecommerce" that is null not "match_result.ecommerce.has_online_payments". So it's still trying to extract a value from a null. Help me modify the query accordingly please.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 11:44:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/null-object-while-running-a-query-against-parquet/m-p/75700#M1415</guid>
      <dc:creator>Shaimaa</dc:creator>
      <dc:date>2024-06-25T11:44:22Z</dc:date>
    </item>
  </channel>
</rss>

