1

I have

val colNames = data.schema.fieldNames
.filter(colName => colName.split("-")(0) == "20003" || colName == "eid") 

which I then use to select a subset of a dataframe:

var medData = data.select(colNames.map(c => col(c)): _*).rdd

but I get

cannot resolve '`20003-0.0`' given input columns: 
[20003-0.0, 20003-0.1, 20003-0.2, 20003-0.3];;

What is going on?

1 Answer 1

4

I had to include backticks like this:

var medData = data.select(colNames.map(c => col(s"`$c`")): _*).rdd

spark is for some reason adding the backticks

Sign up to request clarification or add additional context in comments.

2 Comments

Hey cosmos1990, any idea why this is happening? I just came up against the same thing and can't fathom why this might be happening
Looks like its not spark adding the back-ticks, but rather the back-ticks being required to escape the dots and hyphens - issues.apache.org/jira/browse/SPARK-18502 and stackoverflow.com/questions/30889630/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.