Hello @dhyaneshnaik,
Welcome!
Can you please tell me a little bit more about your schema?
How many tags do you have? How many fields do you have?
Will this once-field, now-tag span multiple fields?
How much data are you querying for from the past 10 years?
What do you intend to do after this conversion?
Do you need to both convert the field to the tag and delete the old field? Because if you convert a field to a tag and then delete the field you’ll be deleting that series with your converted tag.
Thanks!
import "csv"
csvData = "#group,false,false,true,true,false,false,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string
#default,mean,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,sensor_id
,,0,2021-04-01T15:15:27Z,2021-08-30T15:15:27.093Z,2021-08-20T01:28:00Z,34.854178689956115,humidity,airSensors,TLM0101
,,1,2021-04-01T15:15:27Z,2021-08-30T15:15:27.093Z,2021-08-20T01:28:00Z,34.81859620710558,humidity,airSensors,TLM0100
,,2,2021-04-01T15:15:27Z,2021-08-30T15:15:27.093Z,2021-08-20T01:28:00Z,0.4464200933827537,co,airSensors,TLM0100
,,3,2021-04-01T15:15:27Z,2021-08-30T15:15:27.093Z,2021-08-20T01:28:00Z,0.6347294407296836,co,airSensors,TLM0101
"
csv.from(csv: csvData)
|> map(fn: (r) => ({
r with
newtag: "humidity"
})
)
map will create a new tag across the two fields. You can copy and paste that code to see how it affect the schema.
Then you can filter out your old field and copy everything but your old field to a new bucket with a new measurement.