Select 除 spark 中的特定列外的所有列 sql

Select all except particular column in spark sql

我想 select table 中除 StudentAddress 之外的所有列,因此我写了以下查询:

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

它在 Squirrel Sql 客户端中给出以下错误。 org.apache.spark.sql.AnalysisException: 无法解析“(StudentAddress)?+.+”给定的输入列

您可以在 DataFrame API 中使用 drop() 方法删除特定列,然后 select 所有列。

例如:

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