【发布时间】:2017-10-10 20:22:19
【问题描述】:
我从 XML 文件创建了一个 DataFrame。创建的 DataFrame 具有以下方案。
val df = hiveContext.read.format("com.databricks.spark.xml").option("rowTag", row_tag_name).load(data_dir_path_xml)
df.printSchema()
root
|-- samples: struct (nullable = true)
| |-- sample: array (nullable = true)
| | |-- element: struct (containsNull = true)
| | | |-- abc: string (nullable = true)
| | | |-- def: long (nullable = true)
| | | |-- type: string (nullable = true)
|-- abc: string (nullable = true)
我想屏蔽数据框中的 abc/def。
我能够到达我想使用的领域:
val abc = df.select($"samples.sample".getField("abc"))
但我想屏蔽数据帧 df 中的字段 abc/def(用 XXXX 替换 abc 字段)。请帮我解决这个问题
【问题讨论】:
-
掩码 abc/def 是什么意思?是你想用 def 值屏蔽 abc 吗?
-
我想将字段 'abc' 和 'def' 替换为值 'xxxxx'。这些字段是敏感数据。
-
你想替换列值对吗?
-
没错,我想替换整列的值,@RameshMaharjan
标签: xml scala apache-spark dataframe masking