<?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 expr undefined function 'LEN' in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/sql-expr-undefined-function-len/m-p/38735#M26738</link>
    <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/33986"&gt;@PhillT&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;There's no "LEN" function. You should use "LENGTH" instead.&lt;/P&gt;&lt;P&gt;&lt;A href="https://spark.apache.org/docs/2.3.0/api/sql/index.html#length" target="_blank"&gt;https://spark.apache.org/docs/2.3.0/api/sql/index.html#length&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jul 2023 05:05:49 GMT</pubDate>
    <dc:creator>daniel_sahal</dc:creator>
    <dc:date>2023-07-31T05:05:49Z</dc:date>
    <item>
      <title>SQL expr undefined function 'LEN'</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-expr-undefined-function-len/m-p/38697#M26722</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Getting this error message on our production cluster when I run a notebook that uses the SQL expr function that call the LEN() funciton&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;example code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;df &lt;SPAN class=""&gt;=&lt;/SPAN&gt; df&lt;SPAN class=""&gt;.&lt;/SPAN&gt;withColumn&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;"POL"&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; expr&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;"CASE WHEN SRC_SYSTEM = 'X' THEN CONCAT('08' , SUBSTRING(POL, 3, LEN(POL) -2)) ELSE POL END"&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Below is the error message.&amp;nbsp; The notebook runs with out issue on my machine on our dev cluster, issue happend on our prod cluster.&amp;nbsp; Any one has any ideas?&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Exception happened for incremental load. Exception-&amp;gt; Undefined function: 'LEN'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 87.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have the following module import...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; pyspark.sql.functions &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; *&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; pyspark.sql.types &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; *&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; pyspark.sql &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; functions &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; F, Window&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; pyspark.sql.functions &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; col, create_map, lit, expr&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; itertools &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; chain&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; pyspark &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; StorageLevel&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; pyspark.sql.functions &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; coalesce&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 28 Jul 2023 18:32:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-expr-undefined-function-len/m-p/38697#M26722</guid>
      <dc:creator>PhillT</dc:creator>
      <dc:date>2023-07-28T18:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: SQL expr undefined function 'LEN'</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-expr-undefined-function-len/m-p/38735#M26738</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/33986"&gt;@PhillT&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;There's no "LEN" function. You should use "LENGTH" instead.&lt;/P&gt;&lt;P&gt;&lt;A href="https://spark.apache.org/docs/2.3.0/api/sql/index.html#length" target="_blank"&gt;https://spark.apache.org/docs/2.3.0/api/sql/index.html#length&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2023 05:05:49 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-expr-undefined-function-len/m-p/38735#M26738</guid>
      <dc:creator>daniel_sahal</dc:creator>
      <dc:date>2023-07-31T05:05:49Z</dc:date>
    </item>
  </channel>
</rss>

