10-20-2023
	
		
		09:52 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		10-20-2023
	
		
		10:22 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		
		
			JoeM
		
		
		
		
		
		
		
		
	
			
		
Hi,
I am trying to get regex to work in a materialized view but keep running into "undefined function" errors
Is there something wrong with my format?
10-20-2023 10:25 AM
@mkrieger  - This will depend on whether you are using SparkSQL or Postgres. Here are samples of how you might regex match in each example:
Postgres
SELECT CategoryName, (CategoryName ~ 'c') AS regex_column
FROM OnlineStore.ProductCategory
Spark SQL
SELECT
    `OnlineStore.productcategory`.`CategoryName` AS `CategoryName`, regexp(`OnlineStore.productcategory`.`CategoryName`, 'c') AS regex_column
FROM
    `OnlineStore.productcategory` `OnlineStore.productcategory`
10-20-2023 01:52 PM
Thanks for the quick response!
I've confirmed that I am using SparkSQL, although I am still running into the following error message: 
org.apache.spark.sql.AnalysisException: Undefined function: 'regexp'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'
Generated from this query:
10-23-2023 07:02 AM
@mkrieger - I am surprised you are running into that. It might be worth also trying either regex_like or rlike.