<?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: Materialized views - Query ends with _X in Data &amp; Schema Discussions</title>
    <link>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5431#M445</link>
    <description>&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; This is working now.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jan 2024 10:53:37 GMT</pubDate>
    <dc:creator>nikhil_cr</dc:creator>
    <dc:date>2024-01-22T10:53:37Z</dc:date>
    <item>
      <title>Materialized views - Query ends with _X</title>
      <link>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5412#M440</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to write a query in MV (Spark SQL) which excludes the items ending with "_X"&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand underscore ("_") is&amp;nbsp;single character wildcard in SQL and should be addressed as '%[_]x' or&amp;nbsp;'%\_x' which will include the Underscore (_).&amp;nbsp; But it seems in Incorta - this is not working properly. After using the below query I can still see items ending with '_x'&lt;/P&gt;&lt;P&gt;select *&amp;nbsp; from table1&lt;BR /&gt;where CATALOG_NUMBER &lt;STRONG&gt;not like&lt;/STRONG&gt; &lt;STRONG&gt;'%\_x'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;or CATALOG_NUMBER &lt;STRONG&gt;not like&lt;/STRONG&gt; &lt;STRONG&gt;'%\_X'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Please suggest any other method or if i'm missing anything above?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nikhil&lt;/P&gt;&lt;P&gt;-nikhil.cr@lkqeurope.com&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 06:31:19 GMT</pubDate>
      <guid>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5412#M440</guid>
      <dc:creator>nikhil_cr</dc:creator>
      <dc:date>2024-01-17T06:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized views - Query ends with _X</title>
      <link>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5415#M441</link>
      <description>&lt;P&gt;I found this ( below ) w/ a Google search.&lt;/P&gt;&lt;P&gt;Alternatively I'd bring the data into an insight and fiddle w/ a formula filter&amp;nbsp; ( or start with "ends with" ) and then copy the SQL from the insight into the MV and see if replicates the results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;=============== snip ================== source:&amp;nbsp;&lt;A href="https://www.mssqltips.com/sqlservertip/5670/examples-and-function-for-using-sql-server-like-operator-and-wildcard-characters/" target="_blank" rel="noopener"&gt;https://www.mssqltips.com/sqlservertip/5670/examples-and-function-for-using-sql-server-like-operator-and-wildcard-characters/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get around this, we can use the ESCAPE clause with the SQL LIKE operator to tell the query engine to use the wildcard character as a literal.&lt;/P&gt;&lt;P&gt;The ESCAPE clause has the following format:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;ESCAPE&lt;/SPAN&gt; &lt;SPAN class=""&gt;'escape_character'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;For instance, in the following query the escape character is '!', and it is also included in the pattern. It means the symbol following the escape character should be considered as a regular symbol:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;USE&lt;/SPAN&gt;&lt;SPAN class=""&gt; TestDB&lt;/SPAN&gt;&lt;SPAN class=""&gt;GO&lt;/SPAN&gt;

&lt;SPAN class=""&gt;SELECT&lt;/SPAN&gt;&lt;SPAN class=""&gt; *&lt;/SPAN&gt;&lt;SPAN class=""&gt;FROM&lt;/SPAN&gt;&lt;SPAN class=""&gt; myUser&lt;/SPAN&gt;&lt;SPAN class=""&gt;WHERE&lt;/SPAN&gt;&lt;SPAN class=""&gt; LoginName &lt;/SPAN&gt;&lt;SPAN class=""&gt;LIKE&lt;/SPAN&gt; &lt;SPAN class=""&gt;'%!_my%'&lt;/SPAN&gt; &lt;SPAN class=""&gt;ESCAPE&lt;/SPAN&gt; &lt;SPAN class=""&gt;'!'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Therefore, '_' symbol, which is after '!' in the pattern, is not considered a wildcard character and we have this result:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;So, after applying the ESCAPE clause to the example with a variable we have the correct result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;=========== end snip ================&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 20:17:54 GMT</pubDate>
      <guid>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5415#M441</guid>
      <dc:creator>RADSr</dc:creator>
      <dc:date>2024-01-17T20:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized views - Query ends with _X</title>
      <link>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5417#M442</link>
      <description>&lt;P&gt;Update - I uploaded a quick test file, did the query in an insight and then copied the SQL from the insight into the MV using SPARK SQL and it appears to accept the underscore as a literal character and not a wildcard:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RADSr_0-1705522721258.png" style="width: 1205px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2522i7C534AFCD3E3EC19/image-dimensions/1205x712?v=v2" width="1205" height="712" role="button" title="RADSr_0-1705522721258.png" alt="RADSr_0-1705522721258.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 20:19:36 GMT</pubDate>
      <guid>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5417#M442</guid>
      <dc:creator>RADSr</dc:creator>
      <dc:date>2024-01-17T20:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized views - Query ends with _X</title>
      <link>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5420#M443</link>
      <description>&lt;P&gt;Thank&amp;nbsp; you&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 12:53:18 GMT</pubDate>
      <guid>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5420#M443</guid>
      <dc:creator>nikhil_cr</dc:creator>
      <dc:date>2024-01-18T12:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized views - Query ends with _X</title>
      <link>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5430#M444</link>
      <description>&lt;P&gt;There is a simpler solution to this issue. You can use negative lookbehind regex notation.&lt;/P&gt;&lt;P&gt;SELECT&lt;BR /&gt;t1.col1&lt;BR /&gt;FROM&lt;BR /&gt;table1 t1&lt;BR /&gt;WHERE&lt;BR /&gt;t1.CATALOG_NUMBER regexp '.+(?&amp;lt;!(_[xX]))$'&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Screenshot 2024-01-22 at 4.14.02 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2524iD3CE0C8E3AF7C62E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2024-01-22 at 4.14.02 PM.png" alt="Screenshot 2024-01-22 at 4.14.02 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This will look for "_" followed by any letters present inside the square bracket, in this case [xX]. So it will reject all the strings which fulfil this condition.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 10:48:23 GMT</pubDate>
      <guid>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5430#M444</guid>
      <dc:creator>kartikgaur24</dc:creator>
      <dc:date>2024-01-22T10:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Materialized views - Query ends with _X</title>
      <link>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5431#M445</link>
      <description>&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; This is working now.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 10:53:37 GMT</pubDate>
      <guid>https://community.incorta.com/t5/data-schema-discussions/materialized-views-query-ends-with-x/m-p/5431#M445</guid>
      <dc:creator>nikhil_cr</dc:creator>
      <dc:date>2024-01-22T10:53:37Z</dc:date>
    </item>
  </channel>
</rss>

