Skip to content
Advertisement

Apache spark and scala, error while executing queries

I am working with a dataset whose sample is as follows:

JavaScript

I have executed the following commands successfully:

JavaScript

I am getting following error:

JavaScript

java.lang.RuntimeException: Error while encoding: java.lang.RuntimeException: java.lang.Character is not a valid external type for schema of string

I am getting the same error when executing any query against the data. Can you please have a look and provide me with a solution?

Advertisement

Answer

If you looking to skip the RDD extra code you can use the below code

Input file csv (; delimited and every record separated by next line)

JavaScript
  • Define the struct schema
  • Read ; delimited file
  • Read the csv with header=true and pre defined schema as Dataframe directly
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement