3
votes

I want to select all columns in a table except StudentAddress and hence I wrote following query:

select `(StudentAddress)?+.+` from student;

It gives following error in Squirrel Sql client. org.apache.spark.sql.AnalysisException: cannot resolve '(StudentAddress)?+.+' given input columns

1
This syntax does not seem to be supported by Spark - David דודו Markovitz
Any workarounds? - Patel
What is the actual need? - David דודו Markovitz
I am joining multiple very wide tables so after performing one join, I need to drop one of the joined column to remove ambiguity for next join. Currently, I am specifying all the column names I want in select but functionality like except columns would be very flexible. Thanks. - Patel

1 Answers

7
votes

You can use drop() method in the DataFrame API to drop a particular column and then select all the columns.

For example:

val df = hiveContext.read.table("student")
val dfWithoutStudentAddress = df.drop("StudentAddress")