Skip to content
Advertisement

Col names not detected – AnalysisException: Cannot resolve ‘Name’ given input columns ‘col10’

I’m trying to run a transformation function in a pyspark script:

JavaScript

My dataset looks like this:

JavaScript

My desired output is something like this:

JavaScript

However, the last code line gives me an error similar to this:

JavaScript

When I check:

JavaScript

I see ‘col1’, ‘col2’ etc in the first row instead of the actual labels ( [“Name”,”Type”] ). Should I separately remove and then add the original column titles?

Advertisement

Answer

It seems like that your meta data table was configured using the built-in CSV classifier. If this classifier isn’t able to detect a header, it will call the columns col1, col2 etc.

Your problem lies one stage before your ETL job, so in my opinion you shouldn’t remove and re-add the original column titles, but fix your data import / schema detection, by using a custom classifier.

Advertisement