GET_PATH (Lakehouse v1)
Extrait la valeur d’un VARIANT à partir de path_name.
La valeur est renvoyée sous forme de Variant, ou NULL si l’un des arguments est NULL.
GET_PATH équivaut à une chaîne de fonctions GET ; path_name est constitué d’une concaténation de noms de champ précédés de points (.), de deux-points (:) ou d’opérateurs d’index ([index]). Le premier nom de champ ne nécessite pas d’identifiant initial.
Syntaxe Analyze
Section intitulée « Syntaxe Analyze »func.get_path(<variant>, <path_name>)Exemples Analyze
Section intitulée « Exemples Analyze »func.get_path(func.parse_json('{"k1":[0,1,2], "k2":{"k3":3,"k4":4}}'), 'k2.k4')┌─────────────────────────────────────────────────────────────────────────────────┐│ func.get_path(func.parse_json('{"k1":[0,1,2], "k2":{"k3":3,"k4":4}}'), 'k2.k4') │├─────────────────────────────────────────────────────────────────────────────────┤│ 4 │└─────────────────────────────────────────────────────────────────────────────────┘Syntaxe SQL
Section intitulée « Syntaxe SQL »GET_PATH( <variant>, <path_name> )Arguments
Section intitulée « Arguments »| Arguments | Description |
|---|---|
<variant> |
La valeur VARIANT contenant un ARRAY ou un OBJECT |
<path_name> |
La valeur de type chaîne constituée d’une concaténation de noms de champ |
Type de retour
Section intitulée « Type de retour »VARIANT
Exemples SQL
Section intitulée « Exemples SQL »SELECT get_path(parse_json('{"k1":[0,1,2], "k2":{"k3":3,"k4":4}}'), 'k1[0]');┌───────────────────────────────────────────────────────────────────────┐│ get_path(parse_json('{"k1":[0,1,2], "k2":{"k3":3,"k4":4}}'), 'k1[0]') │├───────────────────────────────────────────────────────────────────────┤│ 0 │└───────────────────────────────────────────────────────────────────────┘
SELECT get_path(parse_json('{"k1":[0,1,2], "k2":{"k3":3,"k4":4}}'), 'k2:k3');┌───────────────────────────────────────────────────────────────────────┐│ get_path(parse_json('{"k1":[0,1,2], "k2":{"k3":3,"k4":4}}'), 'k2:k3') │├───────────────────────────────────────────────────────────────────────┤│ 3 │└───────────────────────────────────────────────────────────────────────┘
SELECT get_path(parse_json('{"k1":[0,1,2], "k2":{"k3":3,"k4":4}}'), 'k2.k4');┌───────────────────────────────────────────────────────────────────────┐│ get_path(parse_json('{"k1":[0,1,2], "k2":{"k3":3,"k4":4}}'), 'k2.k4') │├───────────────────────────────────────────────────────────────────────┤│ 4 │└───────────────────────────────────────────────────────────────────────┘
SELECT get_path(parse_json('{"k1":[0,1,2], "k2":{"k3":3,"k4":4}}'), 'k2.k5');┌───────────────────────────────────────────────────────────────────────┐│ get_path(parse_json('{"k1":[0,1,2], "k2":{"k3":3,"k4":4}}'), 'k2.k5') │├───────────────────────────────────────────────────────────────────────┤│ NULL │└───────────────────────────────────────────────────────────────────────┘