本文介紹函數中欄位提模數式參數的取值以及含義。
相關函數
以下為使用欄位提模數式mode參數的函數列表及其參數預設值。
分類 | 函數 | mode的預設值 |
欄位值賦值函數 | overwrite | |
欄位值提取函數 | fill-auto | |
fill-auto | ||
fill-auto | ||
fill-auto | ||
fill-auto | ||
overwrite | ||
overwrite | ||
映射富化函數 | fill-auto | |
fill-auto |
欄位提取檢查與覆蓋模式
下表介紹欄位提模數式mode參數的不同取值以及說明。
參數值 | 說明 |
fill | 當目標欄位不存在或者值為空白時,設定目標欄位。 |
fill-auto | 當新值非空,且目標欄位不存在或者值為空白時,設定目標欄位。 |
add | 當目標欄位不存在時,設定目標欄位。 |
add-auto | 當新值非空,且目標欄位不存在時,設定目標欄位。 |
overwrite | 總是設定目標欄位。 |
overwrite-auto | 當新值非空,設定目標欄位。 |
以下通過樣本的方式對不同模式進行說明:
原始日誌
a: # 空值 b: 100加工樣本
模式
樣本
加工結果
add
e_set("c", "123", mode='add')a:# 空值 b: 100 c: 123e_set("c", "", mode='add')a:# 空值 b: 100 c:e_set("a", "123", mode='add')a:# 空值 b: 100add-auto
e_set("c", "", mode='add-auto')不添加欄位
c,原始日誌不變。fill
e_set("c", "123", mode='fill')a:# 空值 b: 100 c: 123e_set("c", "", mode='fill')a:# 空值 b: 100 c:e_set("a", "123", mode='fill')a: 123 b: 100e_set("b", "123", mode='fill')目標欄位不變,仍為
b: 100。fill-auto
e_set("c", "", mode='fill-auto')不添加欄位
c,原始日誌不變。overwrite
e_set("c", "123", mode='overwrite')a:# 空值 b: 100 c: 123e_set("c", "", mode='overwrite')a:# 空值 b: 100 c:e_set("b", "200", mode='overwrite')a:# 空值 b: 200e_set("b", "", mode='overwrite')a:# 空值 b:overwrite-auto
e_set("b", "", mode='overwrite-auto')目標欄位不變,仍為
b: 100。
欄位名提取約束
適用於e_json、e_kv,e_kv_delimit、e_regex等函數。
提取的欄位名必須滿足字元條件,否則會被丟棄。不支援Regexu'_*[\u4e00-\u9fa5\u0800-\u4e00a-zA-Z][\u4e00-\u9fa5\u0800-\u4e00\\w\\.\\-]*'。例如123=abc、__1__:100、1k=200、{"123": "456"}等欄位名會被丟棄。
樣本:使用預設的欄位約束名。
原始日誌
data: {"k1": 100, "k2": {"k3": 200, "k4": {"k5": 300} } }加工規則
e_json( "data", fmt="parent", sep="@", prefix="__", suffix="__", include_node=r"[\u4e00-\u9fa5\u0800-\u4e00a-zA-Z][\w\-\.]*", mode="fill-auto", )加工結果
data: {"k1": 100, "k2": {"k3": 200, "k4": {"k5": 300} } } data@__k1__:100 k2@__k3__:200 k4@__k5__:300