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];
6 days ago in Apache Spark by Esha
53 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 6 days ago 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
64 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
29 views
+5 votes
11 answers

Concatenate columns in apache spark dataframe

its late but this how you can ...READ MORE

answered Mar 21 in Apache Spark by anonymous
22,962 views
0 votes
1 answer

cache tables in apache spark sql

Caching the tables puts the whole table ...READ MORE

answered May 4, 2018 in Apache Spark by Data_Nerd
• 2,360 points
529 views
0 votes
0 answers
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,110 points
2,047 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,110 points
196 views
0 votes
10 answers

hadoop fs -put command?

copy command can be used to copy files ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Sujay
10,477 views
0 votes
1 answer

Difference between cogroup and full outer join in spark

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

answered 6 days ago in Apache Spark by Kiran
23 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 6 days ago in Apache Spark by Ishan
12 views