我希望能够取消选中单选按钮,想法是这样的:如果我单击某个单选按钮,它将被选中;如果我单击另一个字段,则将选中另一个字段而不是BUT如果我单击已选中的字段,则希望取消选中它,以便所有字段均为空。我试图抓住被选中或未选中的时刻,但似乎与复选框相反,单选按钮没有此字段。有谁知道如何实现这一目标?
scala> spark.conf.set("spark.sql.caseSensitive","true")
scala> val df = sc.parallelize(1 to 1000).toDF()
df: org.apache.spark.sql.DataFrame = [value: int]
scala> df.withColumnRenamed("value","VALUE").write.parquet("test_uc")
scala> df.write.parquet("test_lc")
scala> val df2=spark.read.option("mergeSchema","true").parquet("test_*")
df2: org.apache.spark.sql.DataFrame = [value: int, VALUE: int]
scala> val merged = df2.columns.groupBy(_.toLowerCase)
.map(t => coalesce(t._2.map(col):_*).as(t._1))
.toArray
merged: Array[org.apache.spark.sql.Column] = Array(coalesce(value, VALUE) AS `value`)
scala> df2.select(merged:_*)
res2: org.apache.spark.sql.DataFrame = [value: int]
scala> spark.conf.set("spark.sql.caseSensitive","false")
// process your dataframe