MSSQL metric datatype not detecting

Running version 6.4.1 on Centos 7, I am getting an error trying to use the Microsoft SQL Server datasource in a time-series query with a metric column. It has happened across two separate MSSQL servers running SQL 2012 and SQL 2016. I upgraded from 6.0.1 to 6.4.1 to see if it resolved the problem, but no change. The error appears as soon as you click out of the query field and no sample data is returned.

The error is this, Column metric must be of type VARCHAR, CHAR, NVARCHAR, NCHAR. metric column name: metric type: NVARCHAR but datatype is

The table is defined as follows.

CREATE TABLE [dbo].[BruceTest](
[timedata] [datetime] NULL,
[value_x] [int] NOT NULL,
[metric_x] nvarchar NULL
)

and the query in the panel is created from the default provided by the MSSQL datasource and is as follows. If I remove the metric column, the query returns data and if I run the SQL shown in the Generated SQL field directly on the database, it returns data.

SELECT
__timeEpoch([timedata]), [value_x] as value, [metric_x] as metric FROM BruceTest WHERE __timeFilter([timedata])
ORDER BY
[timedata] ASC

Can anyone shed light on whether I am making a mistake somewhere in the query or if there is a problem with the MSSQL datasource causing this?

Thanks in advance,
Bruce

I solved this by coalesce(metric_x, ‘’) as metric in your select statement