Duplicate field names found, only the first will be accessible

I’m writing a datasource plugin for an in-house datastore.
The plugin is front-end based.
According to the Data frames document, it seems that it is recommended to build a wide-format data frame with duplicate field names (See the sample result data frame pictures in the document).
But when my datasource plugin build a wide-format data frame with duplicate field names with MutableDataFrame constructor, a warning is logged on the developer console:

Duplicate field names found: sample_field, only the first will be accessible

According to the MutableDataFrame source code, it seems that it does not support the fields that have duplicate names. So I changed the name of the fields by appending ‘_1’, ‘_2’ etc.
Is this a correct fix?

Thanks in advance.

Are you able to show some of the Data Frame structure when you get this warning? (Query Inspector :: JSON :: DataFrame structure).

With duplicate field names, I would expect that in general, there would be Field.labels that distinguish the field uniquely. So I am wondering if you have labels in this case and still get that warning?

Here it is. (a bit long - and the field name is changed to ‘sample_type’ to hide our internal details)
Field names are the same - ‘sample_type’ (except for a time field named ‘end_time’), and the labels are all different.
And I get the following warning message: Duplicate field names found: sample_type, only the first will be accessible.
The “values” section in the json contains only one “sample_type” values array. Maybe the warning message indicates this.

[
  {
    "fields": [
      {
        "name": "end_time",
        "type": "time",
        "config": {},
        "state": {
          "displayName": "end_time",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "end_time",
                "formattedLabels": ""
              }
            }
          }
        }
      },
      {
        "name": "sample_type",
        "type": "number",
        "config": {
          "displayName": "sample_type (type='1')"
        },
        "labels": {
          "type": "1"
        },
        "state": {
          "displayName": "sample_type (type='1')",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "sample_type (type='1')",
                "formattedLabels": "{type=\"1\"}",
                "labels": {
                  "type": "1"
                }
              }
            }
          },
          "calcs": {
            "sum": 2663,
            "max": 414,
            "min": 8,
            "logmin": 8,
            "mean": 242.0909090909091,
            "last": null,
            "first": 414,
            "lastNotNull": 10,
            "firstNotNull": 414,
            "count": 44,
            "nonNullCount": 11,
            "allIsNull": false,
            "allIsZero": false,
            "range": 406,
            "diff": -404,
            "delta": 1520,
            "step": -401,
            "previousDeltaUp": false
          }
        }
      },
      {
        "name": "sample_type",
        "type": "number",
        "config": {
          "displayName": "sample_type (type='13')"
        },
        "labels": {
          "type": "13"
        },
        "state": {
          "calcs": {
            "sum": 8523,
            "max": 1325,
            "min": 24,
            "logmin": 24,
            "mean": 774.8181818181819,
            "last": null,
            "first": null,
            "lastNotNull": 38,
            "firstNotNull": 1253,
            "count": 44,
            "nonNullCount": 11,
            "allIsNull": false,
            "allIsZero": false,
            "range": 1301,
            "diff": -1215,
            "delta": 5040,
            "step": -1286,
            "previousDeltaUp": false
          },
          "displayName": "sample_type (type='13')",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "sample_type (type='13')",
                "formattedLabels": "{type=\"13\"}",
                "labels": {
                  "type": "13"
                }
              }
            }
          }
        }
      },
      {
        "name": "sample_type",
        "type": "number",
        "config": {
          "displayName": "sample_type (type='14')"
        },
        "labels": {
          "type": "14"
        },
        "state": {
          "calcs": {
            "sum": 4547,
            "max": 708,
            "min": 13,
            "logmin": 13,
            "mean": 413.3636363636364,
            "last": null,
            "first": null,
            "lastNotNull": 20,
            "firstNotNull": 700,
            "count": 44,
            "nonNullCount": 11,
            "allIsNull": false,
            "allIsZero": false,
            "range": 695,
            "diff": -680,
            "delta": 2624,
            "step": -643,
            "previousDeltaUp": false
          },
          "displayName": "sample_type (type='14')",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "sample_type (type='14')",
                "formattedLabels": "{type=\"14\"}",
                "labels": {
                  "type": "14"
                }
              }
            }
          }
        }
      },
      {
        "name": "sample_type",
        "type": "number",
        "config": {
          "displayName": "sample_type (type='15')"
        },
        "labels": {
          "type": "15"
        },
        "state": {
          "calcs": {
            "sum": 13086,
            "max": 2063,
            "min": 41,
            "logmin": 41,
            "mean": 1189.6363636363637,
            "last": null,
            "first": null,
            "lastNotNull": 67,
            "firstNotNull": 2063,
            "count": 44,
            "nonNullCount": 11,
            "allIsNull": false,
            "allIsZero": false,
            "range": 2022,
            "diff": -1996,
            "delta": 7494,
            "step": -1987,
            "previousDeltaUp": false
          },
          "displayName": "sample_type (type='15')",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "sample_type (type='15')",
                "formattedLabels": "{type=\"15\"}",
                "labels": {
                  "type": "15"
                }
              }
            }
          }
        }
      },
      {
        "name": "sample_type",
        "type": "number",
        "config": {
          "displayName": "sample_type (type='2')"
        },
        "labels": {
          "type": "2"
        },
        "state": {
          "calcs": {
            "sum": 1013245,
            "max": 155858,
            "min": 3403,
            "logmin": 3403,
            "mean": 92113.18181818182,
            "last": null,
            "first": null,
            "lastNotNull": 4218,
            "firstNotNull": 151948,
            "count": 44,
            "nonNullCount": 11,
            "allIsNull": false,
            "allIsZero": false,
            "range": 152455,
            "diff": -147730,
            "delta": 590908,
            "step": -151597,
            "previousDeltaUp": false
          },
          "displayName": "sample_type (type='2')",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "sample_type (type='2')",
                "formattedLabels": "{type=\"2\"}",
                "labels": {
                  "type": "2"
                }
              }
            }
          }
        }
      },
      {
        "name": "sample_type",
        "type": "number",
        "config": {
          "displayName": "sample_type (type='3')"
        },
        "labels": {
          "type": "3"
        },
        "state": {
          "calcs": {
            "sum": 843082,
            "max": 129920,
            "min": 2799,
            "logmin": 2799,
            "mean": 76643.81818181818,
            "last": null,
            "first": null,
            "lastNotNull": 3563,
            "firstNotNull": 128363,
            "count": 44,
            "nonNullCount": 11,
            "allIsNull": false,
            "allIsZero": false,
            "range": 127121,
            "diff": -124800,
            "delta": 489495,
            "step": -126255,
            "previousDeltaUp": false
          },
          "displayName": "sample_type (type='3')",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "sample_type (type='3')",
                "formattedLabels": "{type=\"3\"}",
                "labels": {
                  "type": "3"
                }
              }
            }
          }
        }
      },
      {
        "name": "sample_type",
        "type": "number",
        "config": {
          "displayName": "sample_type (type='4')"
        },
        "labels": {
          "type": "4"
        },
        "state": {
          "calcs": {
            "sum": 46559,
            "max": 7074,
            "min": 168,
            "logmin": 168,
            "mean": 4232.636363636364,
            "last": null,
            "first": null,
            "lastNotNull": 178,
            "firstNotNull": 7006,
            "count": 44,
            "nonNullCount": 11,
            "allIsNull": false,
            "allIsZero": false,
            "range": 6906,
            "diff": -6828,
            "delta": 26938,
            "step": -6904,
            "previousDeltaUp": false
          },
          "displayName": "sample_type (type='4')",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "sample_type (type='4')",
                "formattedLabels": "{type=\"4\"}",
                "labels": {
                  "type": "4"
                }
              }
            }
          }
        }
      },
      {
        "name": "sample_type",
        "type": "number",
        "config": {
          "displayName": "sample_type (type='5')"
        },
        "labels": {
          "type": "5"
        },
        "state": {
          "calcs": {
            "sum": 1716,
            "max": 283,
            "min": 4,
            "logmin": 4,
            "mean": 156,
            "last": null,
            "first": null,
            "lastNotNull": 5,
            "firstNotNull": 260,
            "count": 44,
            "nonNullCount": 11,
            "allIsNull": false,
            "allIsZero": false,
            "range": 279,
            "diff": -255,
            "delta": 1038,
            "step": -264,
            "previousDeltaUp": false
          },
          "displayName": "sample_type (type='5')",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "sample_type (type='5')",
                "formattedLabels": "{type=\"5\"}",
                "labels": {
                  "type": "5"
                }
              }
            }
          }
        }
      },
      {
        "name": "sample_type",
        "type": "number",
        "config": {
          "displayName": "sample_type (type='6')"
        },
        "labels": {
          "type": "6"
        },
        "state": {
          "calcs": {
            "sum": 444,
            "max": 70,
            "min": 2,
            "logmin": 2,
            "mean": 49.333333333333336,
            "last": null,
            "first": null,
            "lastNotNull": 3,
            "firstNotNull": 70,
            "count": 44,
            "nonNullCount": 9,
            "allIsNull": false,
            "allIsZero": false,
            "range": 68,
            "diff": -67,
            "delta": 193,
            "step": -65,
            "previousDeltaUp": false
          },
          "displayName": "sample_type (type='6')",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "sample_type (type='6')",
                "formattedLabels": "{type=\"6\"}",
                "labels": {
                  "type": "6"
                }
              }
            }
          }
        }
      },
      {
        "name": "sample_type",
        "type": "number",
        "config": {
          "displayName": "sample_type (type='8')"
        },
        "labels": {
          "type": "8"
        },
        "state": {
          "calcs": {
            "sum": 7,
            "max": 3,
            "min": 1,
            "logmin": 1,
            "mean": 1.4,
            "last": null,
            "first": null,
            "lastNotNull": 1,
            "firstNotNull": 1,
            "count": 44,
            "nonNullCount": 5,
            "allIsNull": false,
            "allIsZero": false,
            "range": 2,
            "diff": 0,
            "delta": 2,
            "step": -2,
            "previousDeltaUp": false
          },
          "displayName": "sample_type (type='8')",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "sample_type (type='8')",
                "formattedLabels": "{type=\"8\"}",
                "labels": {
                  "type": "8"
                }
              }
            }
          }
        }
      },
      {
        "name": "sample_type",
        "type": "number",
        "config": {
          "displayName": "sample_type (type='7')"
        },
        "labels": {
          "type": "7"
        },
        "state": {
          "calcs": {
            "sum": 4,
            "max": 2,
            "min": 1,
            "logmin": 1,
            "mean": 1.3333333333333333,
            "last": 1,
            "first": null,
            "lastNotNull": 1,
            "firstNotNull": 1,
            "count": 44,
            "nonNullCount": 3,
            "allIsNull": false,
            "allIsZero": false,
            "range": 1,
            "diff": 0,
            "delta": 2,
            "step": -1,
            "previousDeltaUp": false
          },
          "displayName": "sample_type (type='7')",
          "scopedVars": {
            "__series": {
              "text": "Series",
              "value": {
                "name": "Series (A)"
              }
            },
            "__field": {
              "text": "Field",
              "value": {
                "name": "sample_type (type='7')",
                "formattedLabels": "{type=\"7\"}",
                "labels": {
                  "type": "7"
                }
              }
            }
          }
        }
      }
    ],
    "values": {
      "end_time": [
        "2020-06-07T05:13:00.000Z",
        "2020-06-07T05:14:00.000Z",
        "2020-06-07T05:15:00.000Z",
        "2020-06-07T05:16:00.000Z",
        "2020-06-07T05:17:00.000Z",
        "2020-06-07T05:18:00.000Z",
        "2020-06-07T05:19:00.000Z",
        "2020-06-07T05:21:00.000Z",
        "2020-06-07T05:22:00.000Z",
        "2020-06-07T05:25:00.000Z",
        "2020-06-07T05:26:00.000Z",
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null
      ],
      "sample_type": [
        414,
        386,
        11,
        399,
        305,
        409,
        8,
        343,
        9,
        369,
        10,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null
      ]
    },
    "first": [
      "2020-06-07T05:13:00.000Z",
      "2020-06-07T05:14:00.000Z",
      "2020-06-07T05:15:00.000Z",
      "2020-06-07T05:16:00.000Z",
      "2020-06-07T05:17:00.000Z",
      "2020-06-07T05:18:00.000Z",
      "2020-06-07T05:19:00.000Z",
      "2020-06-07T05:21:00.000Z",
      "2020-06-07T05:22:00.000Z",
      "2020-06-07T05:25:00.000Z",
      "2020-06-07T05:26:00.000Z",
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null,
      null
    ],
    "refId": "A",
    "length": 44
  }
]