clickhouse-datasource icon indicating copy to clipboard operation
clickhouse-datasource copied to clipboard

Scan error on Nullable( Enum(..) ): converting NULL to string is unsupported

Open sergey-v9 opened this issue 10 months ago • 0 comments

For the nullable enum column (in this case, 'status') Query Builder fails to select the column as is and displays the error message: sql: Scan error on column index 2, name "status": converting NULL to string is unsupported: Could not process SQL results

As a workaround, this can be fixed by manually wrapping the enum column with toString() function in SQL Editor.

Sample table to reproduce:

CREATE TABLE test_nullable_enum
(
    timestamp DateTime64, 
    id String(64),
    status Nullable(
        Enum(
            'Success' = 1,
            'Fail' = 2
        )
    )
) ENGINE = MergeTree
ORDER BY id;

INSERT INTO test_nullable_enum (timestamp, id, status) VALUES ('2024-04-18 00:00:00.000', 'i0', NULL);
INSERT INTO test_nullable_enum (timestamp, id, status) VALUES ('2024-04-18 11:11:11.000', 'i1', 'Success');
INSERT INTO test_nullable_enum (timestamp, id, status) VALUES ('2024-04-18 22:22:22.000', 'i2', 'Fail');

SELECT * FROM test_nullable_enum;

Screenshots

image

image

image

Environment:

  • Grafana version: v10.4.2 (701c851be7) Docker image grafana/grafana-oss:10.4.2
  • Plugin version: 4.0.6
  • OS Grafana is installed on: linux/amd64 (Docker for Windows)
  • User OS & Browser: Windows 11, Google Chrome 124

sergey-v9 avatar Apr 19 '24 13:04 sergey-v9