Not able to rename the dimension during ingestion time

I am not able to rename a dimension during ingestion time … Sample dimensionsSpec is as below

“dimensionsSpec” : {

“dimensions” : [

“dim1”,“dim2”,

{ “type” : “default”, “dimension” : “dim3”, “outputName”: “dim3_renamed”, “name”: “dim3”},

{ “type” : “default”, “dimension” : “dim4”, “outputName”: “dim4_renamed”, “name”: “dim3”}

]

}

If I don’t give “name” then it gives error. With “name” ingestion goes fine but dimension is not renamed.

Any help on this?

Thanks in advance

  • Mohan

Anyone has any idea what mistake I am doing here? I am kind of stuck here. Thanks in advance

I am still stuck at the same issue. Any help is appreciated … Thanks

This always confuses me as well but Druid has 2 different dimensions specs.
You have the one used when running a query, this one supports renaming: https://github.com/druid-io/druid/blob/ca2b04f0fd00e9c3fac5a3c9184b627c886cbc83/processing/src/main/java/io/druid/query/dimension/DefaultDimensionSpec.java
And you have the one used for indexing, which only supports a name and type: https://github.com/druid-io/druid/blob/master/api/src/main/java/io/druid/data/input/impl/StringDimensionSchema.java

If you are ingesting CSV or TSV you can just rename the dimensions in the columns list already.
If you are ingesting JSON you can use the flatten spec to rename dimensions: http://druid.io/docs/latest/ingestion/flatten-json.html
So you would use:

{
    "type": "path",
    "name": "dim3_renamed",
    "expr": "$.dim3"
}

Thanks Erik. It worked. I am using CSV so changed in the columns list itself and it worked.

Thanks once again