Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select all except particular column in spark sql

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

like image 395
Patel Avatar asked Jun 05 '26 07:06

Patel


1 Answers

Using spark sql try with

select * except(<columns to be excluded>) from tablename

Example:

select * from tmp
#+----+----+----+----+
#|col1|col2|col3|col4|
#+----+----+----+----+
#|a   |b   |c   |d   |
#+----+----+----+----+


#exclude col1,col2
select * except(col1,col2) from table_name
#+----+----+
#|col3|col4|
#+----+----+
#|c   |d   |
#+----+----+
like image 73
notNull Avatar answered Jun 08 '26 00:06

notNull