org.apache.spark.sql.AnalysisException: cannot resolve "`id`" given input columns

0 votes

Hi Team,

We have one csv file with no header and we want to include header how to do it. Could you please guide it for this.

i tried but it is throwing below error.

scala> case class Person(id:Int,name:String,age:Int,numfriends :Int)
defined class Person
scala> val ff = spark.read.format("csv").option("header","false").option("inferschema","true").load("spark/fakefriends.csv"). as [Person]
org.apache.spark.sql.AnalysisException: cannot resolve "`id`" given input columns: [_c0, _c1, _c2, _c3];
Jul 13 in Apache Spark by Esha
1,117 views

1 answer to this question.

0 votes

I have used a header-less csv file i.e., person.csv for illustration on adding headers to a dataframe. Please refer to the below screenshots for the commands:

imageThe above is the small person.csv file that I have used.image

answered Jul 13 by Puneet

Related Questions In Apache Spark

0 votes
1 answer

org.apache.spark.sql.AnalysisException: cannot resolve given input columns

The string Productivity has to be enclosed between single ...READ MORE

answered Jul 10 in Apache Spark by Tina
625 views
0 votes
1 answer

Error : split value is not a member of org.apache.spark.sql.Row

spark.read.csv is used when loading into a ...READ MORE

answered Jul 10 in Apache Spark by Rishi
175 views
0 votes
1 answer

Error : split value is not a member of org.apache.spark.sql.Row

spark.read.csv is used when loading into a ...READ MORE

answered Jul 22 in Apache Spark by Firoz
202 views
0 votes
1 answer
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,670 points
2,736 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,670 points
289 views
0 votes
10 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
13,556 views
0 votes
1 answer

Difference between cogroup and full outer join in spark

Please go through the below explanation : Full ...READ MORE

answered Jul 13 in Apache Spark by Kiran
224 views
0 votes
1 answer

Spark: How can i create temp views in user defined database instead of default database?

You can try the below code: df.registerTempTable(“airports”) sqlContext.sql(" create ...READ MORE

answered Jul 14 in Apache Spark by Ishan
44 views