SQL expr undefined function 'LEN'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 11:32 AM
Getting this error message on our production cluster when I run a notebook that uses the SQL expr function that call the LEN() funciton
example code:
df = df.withColumn("POL", expr("CASE WHEN SRC_SYSTEM = 'X' THEN CONCAT('08' , SUBSTRING(POL, 3, LEN(POL) -2)) ELSE POL END"))
Below is the error message. The notebook runs with out issue on my machine on our dev cluster, issue happend on our prod cluster. Any one has any ideas?
Exception happened for incremental load. Exception-> Undefined function: 'LEN'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 87.
I have the following module import...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 10:05 PM
@PhillT
There's no "LEN" function. You should use "LENGTH" instead.
https://spark.apache.org/docs/2.3.0/api/sql/index.html#length

