Skip to content

[bug] Inconsistent data type (int/float) within single field/column in results #8707

@bbczeuz

Description

@bbczeuz

Bug report

System info:

  • RHEL7, Influxdb 1.2.4

Steps to reproduce:

  1. Push some data with the 'cpu'-plugin of telegraf to the DB
  2. Query this data
  3. Resulting field data types vary in a single column from row to row

Expected behavior:
One field shall always have the same data type

Actual behavior:
If a float-field value is zero, it's returned as '0' instead of '0.0'. Re-Importing this data to InfluxDB leads to a field type conflict: e.g. 400: {"error":"partial write: field type conflict: input field \"usage_user\" on measurement \"cpu\" is type integer, already exists as type float dropped=1"}

  • Test SELECT usage_user::integer FROM telegraf.raw.cpu: all results arrive as integers
  • Test SELECT usage_user::float FROM telegraf.raw.cpu: some results arrive as ints, some as floats
  • Test SELECT usage_user + 0.0 FROM telegraf.raw.cpu: some results arrive as ints, some as floats
  • Test SELECT usage_user + 0.5 FROM telegraf.raw.cpu: all results arrive as floats
  • Test SELECT usage_user + 1.0 FROM telegraf.raw.cpu: some results arrive as ints, some as floats
  • At least Python's JSON package can differ between int and float zero: aa=json.loads('{"bla":0.0, "ble":0}')

Additional info:

curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=telegraf" --data-urlencode "q=SHOW FIELD KEYS FROM cpu"                             
{
    "results": [
        {
            "statement_id": 0,
            "series": [
                {
                    "name": "cpu",
                    "columns": [
                        "fieldKey",
                        "fieldType"
                    ],
                    "values": [
                        [
                            "usage_guest",
                            "float"
                        ],
                        [
                            "usage_guest_nice",
                            "float"
                        ],
                        [
                            "usage_idle",
                            "float"
                        ],
                        [
                            "usage_iowait",
                            "float"
                        ],
                        [
                            "usage_irq",
                            "float"
                        ],
                        [
                            "usage_nice",
                            "float"
                        ],
                        [
                            "usage_softirq",
                            "float"
                        ],
                        [
                            "usage_steal",
                            "float"
                        ],
                        [
                            "usage_system",
                            "float"
                        ],
                        [
                            "usage_user",
                            "float"
                        ]
                    ]
                }
            ]
        }
    ]
}

curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=telegraf" --data-urlencode "q=SELECT usage_user + 0.0 FROM telegraf.raw.cpu WHERE \"cpu\"='cpu3' GROUP BY * ORDER BY time DESC LIMIT 3" 
{
    "results": [
        {
            "statement_id": 0,
            "series": [
                {
                    "name": "cpu",
                    "tags": {
                        "cpu": "cpu3",
                        "host": "salt-probe"
                    },
                    "columns": [
                        "time",
                        "usage_user"
                    ],
                    "values": [
                        [
                            "2017-08-16T11:38:00Z",
                            0.6018054162312702
                        ],
                        [
                            "2017-08-16T11:37:50Z",
                            0
                        ],
                        [
                            "2017-08-16T11:37:40Z",
                            0.799200799217918
                        ]
                    ]
                }
            ]
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions