<?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: How to Use the CharIndex with Databricks SQL in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27510#M19376</link>
    <description>&lt;P&gt;You're correct Werners. Thank you very much.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Oct 2022 10:12:33 GMT</pubDate>
    <dc:creator>Carlton</dc:creator>
    <dc:date>2022-10-14T10:12:33Z</dc:date>
    <item>
      <title>How to Use the CharIndex with Databricks SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27502#M19368</link>
      <description>&lt;P&gt;When applying the following T-SQL I don't get any errors on MS SQL Server&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT DISTINCT
  *
&amp;nbsp;
FROM dbo.account
LEFT OUTER JOIN dbo.crm2cburl_lookup
  ON account.Id = CRM2CBURL_Lookup.[Key]
LEFT OUTER JOIN dbo.organizations 
ON CRM2CBURL_Lookup.CB_URL_KEY = organizations.cb_url
cross apply (values (charindex('://', homepage_url))) a(a)
cross apply (values (iif(a = 0, 1, a + 3))) b(b)
cross apply (values (charindex('/', homepage_url, b))) c(c)
cross apply (values (iif(c = 0, len(homepage_url) + 1, c))) d(d)
cross apply (values (substring(homepage_url, b, d - b))) e(e)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, when I apply the similar query (identical except for the database used) I get the error message missing 'JOIN'.&lt;/P&gt;&lt;P&gt;The error relates to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;cross apply (values (charindex('://', homepage_url))) a(a)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The query on Databricks is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT DISTINCT
  *
&amp;nbsp;
FROM basecrmcbreport.account
LEFT OUTER JOIN basecrmcbreport.crm2cburl_lookup
  ON account.Id = crm2cburl_lookup.Key
LEFT OUTER JOIN basecrmcbreport.organizations 
ON crm2cburl_lookup.CB_URL_KEY = organizations.cb_url
cross apply (values (charindex('://', homepage_url))) a(a)
cross apply (values (iif(a = 0, 1, a + 3))) b(b)
cross apply (values (charindex('/', homepage_url, b))) c(c)
cross apply (values (iif(c = 0, len(homepage_url) + 1, c))) d(d)
cross apply (values (substring(homepage_url, b, d - b))) e(e)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My feeling is the problem is a syntax issue with the way Databricks deals with charindex, but I'm not sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 16:00:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27502#M19368</guid>
      <dc:creator>Carlton</dc:creator>
      <dc:date>2022-10-13T16:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Use the CharIndex with Databricks SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27503#M19369</link>
      <description>&lt;P&gt;cross apply is not a function in databricks sql.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 08:14:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27503#M19369</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-10-14T08:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Use the CharIndex with Databricks SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27504#M19370</link>
      <description>&lt;P&gt;Hi Werners,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for reaching out&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you let me know what I could use instead of cross apply?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 08:26:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27504#M19370</guid>
      <dc:creator>Carlton</dc:creator>
      <dc:date>2022-10-14T08:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Use the CharIndex with Databricks SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27505#M19371</link>
      <description>&lt;P&gt;No idea as I have no idea what cross apply does. &lt;/P&gt;&lt;P&gt;Maybe if you can explain what you want to achieve I can propose an alternative&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 08:32:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27505#M19371</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-10-14T08:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to Use the CharIndex with Databricks SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27506#M19372</link>
      <description>&lt;P&gt;Werners, thanks again from getting in touch.&lt;/P&gt;&lt;P&gt;I managed to fix this by replacing cross apply with cross join.&lt;/P&gt;&lt;P&gt;However, I'm not getting the error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Undefined function: iif. This function is neither a built-in/temporary function, nor a persistent function that is qualified as spark_catalog.default.iif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a equivalent method to &lt;B&gt;iif&lt;/B&gt; in Databricks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 09:17:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27506#M19372</guid>
      <dc:creator>Carlton</dc:creator>
      <dc:date>2022-10-14T09:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Use the CharIndex with Databricks SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27507#M19373</link>
      <description>&lt;P&gt;I think it is iff.&lt;/P&gt;&lt;P&gt;Here is a list with all the functions:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/sql/language-manual/sql-ref-functions-builtin-alpha.html" target="test_blank"&gt;https://docs.databricks.com/sql/language-manual/sql-ref-functions-builtin-alpha.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 09:19:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27507#M19373</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-10-14T09:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to Use the CharIndex with Databricks SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27508#M19374</link>
      <description>&lt;P&gt;In that case, its strange that I'm getting the suggesting iff isn;t supported&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;This function is neither a built-in/temporary function, nor a persistent function that is qualified as spark_catalog.default.iif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 09:28:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27508#M19374</guid>
      <dc:creator>Carlton</dc:creator>
      <dc:date>2022-10-14T09:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to Use the CharIndex with Databricks SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27509#M19375</link>
      <description>&lt;P&gt;it seems you use IIF instead of IFF.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 09:38:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27509#M19375</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-10-14T09:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Use the CharIndex with Databricks SQL</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27510#M19376</link>
      <description>&lt;P&gt;You're correct Werners. Thank you very much.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 10:12:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-use-the-charindex-with-databricks-sql/m-p/27510#M19376</guid>
      <dc:creator>Carlton</dc:creator>
      <dc:date>2022-10-14T10:12:33Z</dc:date>
    </item>
  </channel>
</rss>

