<?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: SQL CONTAINS Function is not working on Databricks in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/sql-contains-function-is-not-working-on-databricks/m-p/7997#M3730</link>
    <description>&lt;P&gt;In Spark SQL, the CONTAINS function is not a built-in function. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As an alternative, you can use the below inbuilt functions &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt; LIKE function can be used to check whether a string contains a specific substring. The syntax is as follows:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sample Code&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM table_name
WHERE column_name LIKE '%substring%'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;INSTR function can be used to find the position of a substring within a string. If the substring is not found, the function returns 0. The syntax is as follows:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM table_name WHERE INSTR(column_name, 'substring') &amp;gt; 0&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or the good old Regex &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM table_name
WHERE column_name RLIKE 'regexp_pattern'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please let me know if this helps. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2023 08:53:02 GMT</pubDate>
    <dc:creator>pvignesh92</dc:creator>
    <dc:date>2023-03-10T08:53:02Z</dc:date>
    <item>
      <title>SQL CONTAINS Function is not working on Databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-contains-function-is-not-working-on-databricks/m-p/7996#M3729</link>
      <description>&lt;P&gt;I am trying to use sql CONTAINS function in my sql query but it is throwing the below error :&lt;/P&gt;&lt;P&gt;AnalysisException: Undefined function: 'CONTAINS'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 14 pos&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 06:40:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-contains-function-is-not-working-on-databricks/m-p/7996#M3729</guid>
      <dc:creator>Prasann_gupta</dc:creator>
      <dc:date>2023-03-10T06:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: SQL CONTAINS Function is not working on Databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-contains-function-is-not-working-on-databricks/m-p/7997#M3730</link>
      <description>&lt;P&gt;In Spark SQL, the CONTAINS function is not a built-in function. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As an alternative, you can use the below inbuilt functions &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt; LIKE function can be used to check whether a string contains a specific substring. The syntax is as follows:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sample Code&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM table_name
WHERE column_name LIKE '%substring%'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;INSTR function can be used to find the position of a substring within a string. If the substring is not found, the function returns 0. The syntax is as follows:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM table_name WHERE INSTR(column_name, 'substring') &amp;gt; 0&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or the good old Regex &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM table_name
WHERE column_name RLIKE 'regexp_pattern'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please let me know if this helps. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 08:53:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-contains-function-is-not-working-on-databricks/m-p/7997#M3730</guid>
      <dc:creator>pvignesh92</dc:creator>
      <dc:date>2023-03-10T08:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: SQL CONTAINS Function is not working on Databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-contains-function-is-not-working-on-databricks/m-p/7998#M3731</link>
      <description>&lt;P&gt;Hi @Prasann Gupta​&amp;nbsp;, Spark sql does not have CONTAINS as a built in function. The best option here would be to use LIKE function.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 12:38:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-contains-function-is-not-working-on-databricks/m-p/7998#M3731</guid>
      <dc:creator>Lakshay</dc:creator>
      <dc:date>2023-03-10T12:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: SQL CONTAINS Function is not working on Databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-contains-function-is-not-working-on-databricks/m-p/7999#M3732</link>
      <description>&lt;P&gt;Hi @Prasann Gupta​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Apr 2023 00:47:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-contains-function-is-not-working-on-databricks/m-p/7999#M3732</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-01T00:47:41Z</dc:date>
    </item>
  </channel>
</rss>

