<?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 APPLY INTO Highdate instead of NULL for __END_AT in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/apply-into-highdate-instead-of-null-for-end-at/m-p/82881#M36762</link>
    <description>&lt;P&gt;I really like the APPLY INTO function to keep track of changes and historize them in SCD2.&lt;BR /&gt;However, I am a bit confused that current records get an __END_AT of NULL. Typically, __END_AT should be a highgate (i.e. 9999-12-31) or similar, so that a point in time query can simply use:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;SELECT * FROM TABLE where '&amp;lt;my-date&amp;gt;' BETWEEN __START_AT and __END_AT&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Right now I believe I have to use COALESCE on __END_AT to get the correct results. Is there an option to set a&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="arial, helvetica, sans-serif"&gt;highgate instead of NULL for __END_AT?&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Aug 2024 14:42:44 GMT</pubDate>
    <dc:creator>c-thiel</dc:creator>
    <dc:date>2024-08-13T14:42:44Z</dc:date>
    <item>
      <title>APPLY INTO Highdate instead of NULL for __END_AT</title>
      <link>https://community.databricks.com/t5/data-engineering/apply-into-highdate-instead-of-null-for-end-at/m-p/82881#M36762</link>
      <description>&lt;P&gt;I really like the APPLY INTO function to keep track of changes and historize them in SCD2.&lt;BR /&gt;However, I am a bit confused that current records get an __END_AT of NULL. Typically, __END_AT should be a highgate (i.e. 9999-12-31) or similar, so that a point in time query can simply use:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;SELECT * FROM TABLE where '&amp;lt;my-date&amp;gt;' BETWEEN __START_AT and __END_AT&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Right now I believe I have to use COALESCE on __END_AT to get the correct results. Is there an option to set a&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="arial, helvetica, sans-serif"&gt;highgate instead of NULL for __END_AT?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 14:42:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/apply-into-highdate-instead-of-null-for-end-at/m-p/82881#M36762</guid>
      <dc:creator>c-thiel</dc:creator>
      <dc:date>2024-08-13T14:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: APPLY INTO Highdate instead of NULL for __END_AT</title>
      <link>https://community.databricks.com/t5/data-engineering/apply-into-highdate-instead-of-null-for-end-at/m-p/139311#M51147</link>
      <description>&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;The APPLY INTO function for SCD2 historization typically sets the __END_AT field of current records to NULL rather than a "highgate" like 9999-12-31. This is by design and reflects that the record is still current and has no defined end date yet.&lt;/P&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Currently, there is no built-in option in APPLY INTO to set a highgate value such as 9999-12-31 in place of NULL for the __END_AT field. The common and recommended practice in querying such SCD2 tables is to use COALESCE on __END_AT during point-in-time queries, for example:&lt;/P&gt;
&lt;DIV class="w-full md:max-w-[90vw]"&gt;
&lt;DIV class="codeWrapper text-light selection:text-super selection:bg-super/10 my-md relative flex flex-col rounded-lg font-mono text-sm font-normal bg-subtler"&gt;
&lt;DIV class="translate-y-xs -translate-x-xs bottom-xl mb-xl flex h-0 items-start justify-end md:sticky md:top-[calc(var(--header-height)+var(--size-xs))]"&gt;
&lt;DIV class="overflow-hidden rounded-full border-subtlest ring-subtlest divide-subtlest bg-base"&gt;
&lt;DIV class="border-subtlest ring-subtlest divide-subtlest bg-subtler"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="-mt-xl"&gt;
&lt;DIV&gt;
&lt;DIV class="text-quiet bg-subtle py-xs px-sm inline-block rounded-br rounded-tl-lg text-xs font-thin" data-testid="code-language-indicator"&gt;sql&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&lt;CODE&gt;&lt;SPAN class="token token"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token token"&gt;FROM&lt;/SPAN&gt; &lt;SPAN class="token token"&gt;table&lt;/SPAN&gt; &lt;SPAN class="token token"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN class="token token"&gt;'&amp;lt;my-date&amp;gt;'&lt;/SPAN&gt; &lt;SPAN class="token token operator"&gt;BETWEEN&lt;/SPAN&gt; __START_AT &lt;SPAN class="token token operator"&gt;AND&lt;/SPAN&gt; &lt;SPAN class="token token"&gt;COALESCE&lt;/SPAN&gt;&lt;SPAN class="token token punctuation"&gt;(&lt;/SPAN&gt;__END_AT&lt;SPAN class="token token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token token"&gt;'9999-12-31'&lt;/SPAN&gt;&lt;SPAN class="token token punctuation"&gt;)&lt;/SPAN&gt;
&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;This approach avoids assuming a default date on data insertion and clearly specifies that NULL __END_AT means "open-ended" or current record.&lt;/P&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;In summary:&lt;/P&gt;
&lt;UL class="marker:text-quiet list-disc"&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;APPLY INTO currently sets __END_AT to NULL for current records (no explicit "highgate").&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;There is no native setting to replace NULL with a highgate date in APPLY INTO.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Using COALESCE in your queries is the standard way to handle the NULL __END_AT in point-in-time filtering.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;This design aligns with Delta Live Tables and Databricks implementations where NULL __END_AT signifies an active record's open-ended coverage, and your query patterns accommodate that appropriately.​&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2025 11:41:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/apply-into-highdate-instead-of-null-for-end-at/m-p/139311#M51147</guid>
      <dc:creator>mark_ott</dc:creator>
      <dc:date>2025-11-17T11:41:57Z</dc:date>
    </item>
  </channel>
</rss>

