This message was deleted.
# general
s
This message was deleted.
j
I know it is possible by using JavaScript function but I do not have it enabled in my cluster for security reasons.
I found this but for some reason it does nothing
Copy code
{
  "type": "cascade",
  "dimension": "network",
  "outputName": "network",
  "extractionFns": [
    {
      "type": "regex",
      "expr": "([g,G][a,A][s,S]).*"
    },
    {
      "type": "stringFormat",
      "format": "[%s API]"
    }
  ]
}
l
You can use the CASE..WHEN..THEN to achieve conditional transformation. It will use
case_searched
under the hood.
Copy code
SELECT 
CASE WHEN network = 'gas.5' THEN 'Gas API' ….. ELSE network AS transformedColumn 
FROM table
j
I need to use native json queries as they are generated by code
l
You can use “case_searched” then
Copy code
case_searched(expr1, result1, [[expr2, result2, ...], else-result]) is similar to CASE WHEN expr1 THEN result1 [ELSE else_result] END in SQL
j
how are they applied to native json queries?
Also,
gas.5
is an example, there are plenty of them and ideally new ones could come in so need to add them for every single combination if it is the same as CASE .. WHEH .. THEN .. END
thats why the regex
l
if there’s a general pattern, then you can use a regex matching filter then instead of equality.
j
it is always
gas.X
where X is a number
l
it should have, I guess. though the cascade would append ” API” to all the dimension values.
j
hmm looks like so although I though it will need to pass first regex func
l
case_searched should allow that. You can add the transformation in the transformSpec and refer to that in the dimension section of the query.
To make it easier, you can test out the stuff locally using SQL, and then checkout the explain plan for the query, and use that as a template.
j
but I would need to touch the ingestion spec, if I just want the native query, is it possible?
j
I think I got it:
Copy code
"virtualColumns": [
    {
      "type": "expression",
      "name": "virtual_network",
      "expression": "case_searched(like(\"network\",'gas.%'),'Gas API',\"network\")",
      "outputType": "STRING"
    }
  ]
  "dimensions": [
    {
      "type": "default",
      "dimension": "method",
      "outputName": "method"
    },
    {
      "type": "default",
      "dimension": "virtual_network",
      "outputName": "network"
    },
  ],