0
我有這個特殊的JSON文件,它是由PostgreSQL生成的日誌。我將這個JSON文件從多行格式轉換爲單行格式。在我分析的Dataframe中的一個字段中有一個字符串列。此字符串列本身就是JSON格式的這個例子:查詢使用Spark DataFrames的JSON數據列,但不知道它的Schema
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "671.64"
},
"ordering_operation": {
"using_filesort": true,
"cost_info": {
"sort_cost": "100.00"
},
"table": {
"table_name": "test1",
"access_type": "range",
"possible_keys": [
"PRIMARY"
],
"key": "PRIMARY",
"used_key_parts": [
"id"
],
"key_length": "4",
"rows_examined_per_scan": 100,
"rows_produced_per_join": 100,
"filtered": "100.00",
"cost_info": {
"read_cost": "21.64",
"eval_cost": "20.00",
"prefix_cost": "41.64",
"data_read_per_join": "18K"
},
"used_columns": [
"id",
"c"
],
"attached_condition": "(`proxydemo`.`test1`.`id` between 501747 and <cache>((504767 + 99)))"
}
}
}
}
我知道,在星火2.0+我可以使用
from_json(E:柱,模式:StructType):列
函數來自SparkSQL函數。但我不確定該字符串的模式應該是什麼。我已經完成了很多模式和StructType定義,但是這個有點層次!我不明白這個模式應該如何定義! `
我只是想補充一點,我不要求某人爲我完成模式,只知道解釋這個分層數據模式的技術是什麼? –