Java-嵌套架构中的Spark drop列
我在JAVA中有一个带嵌套列的spark数据框架 下面是Java-嵌套架构中的Spark drop列,java,apache-spark,apache-spark-sql,Java,Apache Spark,Apache Spark Sql,我在JAVA中有一个带嵌套列的spark数据框架 下面是.prinschema()结果 root |-- BeginDateTime: struct (nullable = true) | |-- _XmlNodeValue: string (nullable = true) |-- BusinessDayDate: string (nullable = true) |-- BusinessUnit: struct (nullable = true) | |-- UnitI
.prinschema()
结果
root
|-- BeginDateTime: struct (nullable = true)
| |-- _XmlNodeValue: string (nullable = true)
|-- BusinessDayDate: string (nullable = true)
|-- BusinessUnit: struct (nullable = true)
| |-- UnitID: struct (nullable = true)
我可以使用dataframe.drop(“BeginDateTime”)
删除BeginDateTime列(以及根节点下的所有其他列)
但是如果我做了dataframe.drop(“BusinessUnit.UnitID”)
,它就不会删除它
我在其他列中尝试了这个方法,它们的行为都是一样的:不能删除嵌套列。
这个问题有很多答案,但都是scala/python的。我必须在Java环境中工作
有一个线程(),最后一个答案是Java。但是我不能用他的代码,因为第8行和第27行出错了
错误是没有方法列,没有方法结构
有人能用JAVA为我提供一个有效的解决方案吗
谢谢您可以使用以下方法导入col和struct方法:
导入static org.apache.spark.sql.functions.col
,导入static org.apache.spark.sql.functions.struct
@vinsce col确实有效。我现在得到的错误在结构中。Intellij给了我两个选项:1,让getCOlumn重新运行'scala.collection.Seq'选项2:在xxStruct(scala.collection.Seq,org.apache.spark.sql.Column>)中创建方法'struct',函数中不能应用于(org.apache.spark.sql.Column[])您可以使用:导入静态org.apache spark.sql.functions.coll
,导入static org.apache.spark.sql.functions.struct
@vinsce col确实有效。我现在得到的错误在结构中。Intellij给了我两个选项:1,使getCOlumn重新运行'scala.collection.Seq'选项2:函数中xxxxstruct(scala.collection.Seq,org.apache.spark.sql.Column>)中的创建方法'struct'不能应用于(org.apache.spark.sql.Column[])