@@ -120,11 +120,15 @@ static DefaultMacro chsql_macros[] = {
120
120
{DEFAULT_SCHEMA, " IPv4NumToString" , {" num" , nullptr }, {{nullptr , nullptr }}, R"( CONCAT(CAST((num >> 24) & 255 AS VARCHAR), '.', CAST((num >> 16) & 255 AS VARCHAR), '.', CAST((num >> 8) & 255 AS VARCHAR), '.', CAST(num & 255 AS VARCHAR)))" },
121
121
{DEFAULT_SCHEMA, " IPv4StringToNum" , {" ip" , nullptr }, {{nullptr , nullptr }}, R"( CAST(SPLIT_PART(ip, '.', 1) AS INTEGER) * 256 * 256 * 256 + CAST(SPLIT_PART(ip, '.', 2) AS INTEGER) * 256 * 256 + CAST(SPLIT_PART(ip, '.', 3) AS INTEGER) * 256 + CAST(SPLIT_PART(ip, '.', 4) AS INTEGER))" },
122
122
// -- JSON Macros
123
- {DEFAULT_SCHEMA, " JSONExtract" , {" json" , " key" , " type" , nullptr }, {{nullptr , nullptr }}, R"( CAST(json_extract(json, key) AS type))" },
123
+ {DEFAULT_SCHEMA, " JSONExtract" , {" json" , " key" , nullptr }, {{nullptr , nullptr }}, R"( json_extract(json, key))" },
124
+ {DEFAULT_SCHEMA, " JSONExtractString" , {" json" , " key" , nullptr }, {{nullptr , nullptr }}, R"( CAST(json_extract(json, key) AS VARCHAR))" },
125
+ {DEFAULT_SCHEMA, " JSONExtractUInt" , {" json" , " key" , nullptr }, {{nullptr , nullptr }}, R"( CAST(json_extract(json, key) AS UINTEGER))" },
126
+ {DEFAULT_SCHEMA, " JSONExtractInt" , {" json" , " key" , nullptr }, {{nullptr , nullptr }}, R"( CAST(json_extract(json, key) AS INT32))" },
127
+ {DEFAULT_SCHEMA, " JSONExtractFloat" , {" json" , " key" , nullptr }, {{nullptr , nullptr }}, R"( CAST(json_extract(json, key) AS DOUBLE))" },
124
128
{DEFAULT_SCHEMA, " JSONExtractRaw" , {" json" , " key" , nullptr }, {{nullptr , nullptr }}, R"( json_extract(json, key))" },
125
129
{DEFAULT_SCHEMA, " JSONHas" , {" json" , " key" , nullptr }, {{nullptr , nullptr }}, R"( json_extract(json, key) IS NOT NULL)" },
126
130
{DEFAULT_SCHEMA, " JSONLength" , {" json" , nullptr }, {{nullptr , nullptr }}, R"( json_array_length(json))" },
127
- {DEFAULT_SCHEMA, " JSONType" , {" json" , nullptr }, {{nullptr , nullptr }}, R"( json_each(json))" },
131
+ {DEFAULT_SCHEMA, " JSONType" , {" json" , " path " , nullptr }, {{nullptr , nullptr }}, R"( CASE WHEN path IS NULL THEN json_each(json) ELSE json_each(json,path) END )" },
128
132
{DEFAULT_SCHEMA, " JSONExtractKeys" , {" json" , nullptr }, {{nullptr , nullptr }}, R"( json_object_keys(json))" },
129
133
{DEFAULT_SCHEMA, " JSONExtractValues" , {" json" , nullptr }, {{nullptr , nullptr }}, R"( json_each_text(json))" },
130
134
// -- Compare Macros
0 commit comments