cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Parse_Syntax_Error Help

deltax_07
New Contributor

i'm getting this error: Exception in thread "main" org.apache.spark.sql.catalyst.parser.ParseException: [PARSE_SYNTAX_ERROR] Syntax error at or near ','.(line 1, pos 18) == SQL == sum(mp4) AS Videos, sum(csv+xlsx) AS Sheets, sum(docx+txt+pdf) AS Documents, sum(zip+html+pptx) AS Others, sum(gif+jgp+png) AS Images ------------------^^^
for my code in scala:

// Define field mappings and aggregations
val fieldMappings = Map(
"Documents" -> Seq("docx", "txt", "pdf"),
"Sheets" -> Seq("csv", "xlsx"),
"Images" -> Seq("gif", "jgp", "png"),
"Videos" -> Seq("mp4"),
"Others" -> Seq("zip", "html", "pptx")
)

// // Define aggregation pipeline
val aggregatedDF = inputDF.groupBy("u_id").agg(
expr(
fieldMappings.map { case (category, fields) =>
sum(fields.mkString("+")).alias(category)
}.mkString(", ")
)
)
0 REPLIES 0

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group