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 14, 2019 in Apache Spark by Esha
17,411 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 14, 2019 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, 2019 in Apache Spark by Tina
41,985 views
0 votes
1 answer
0 votes
2 answers

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

var d=rdd2col.rdd.map(x=>x.split(",")) or val names=rd ...READ MORE

answered Aug 5, 2020 in Apache Spark by Ramkumar Ramasamy.
11,060 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, 2019 in Apache Spark by Firoz
2,788 views
+1 vote
2 answers
+1 vote
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
• 11,380 points
10,560 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
• 11,380 points
2,185 views
+2 votes
11 answers

hadoop fs -put command?

Hi, You can create one directory in HDFS ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
104,222 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 14, 2019 in Apache Spark by Kiran
9,374 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, 2019 in Apache Spark by Ishan
4,110 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP