文档首页 > > 开发指南> 优化查询性能> SQL执行troubleshooting>

执行SELECT查询时,提示failed to find conversion function from unknown to text

执行SELECT查询时,提示failed to find conversion function from unknown to text

分享
更新时间:2020/12/30 GMT+08:00

问题描述

执行select语句时,报错

failed to find conversion function from unknown to text

ERROR:  failed to find conversion function from unknown to text

原因分析

在select的语句的子查询中包含常量,但是没有指定常量类型。

处理方法

将子查询中的常量类型强转为一个固定的类型。

例:

create table t1(col1 int, col2 int);

SELECT distinct Q.*
    FROM (SELECT col1,
          '2015-03-01' AS start_time,
          '2015-03-01' AS last_time
         FROM t1)Q;

可以修改为:

SELECT distinct Q.*
    FROM (SELECT col1,
          cast('2015-03-01' as text) AS start_time,
          cast('2015-03-01' as text) AS last_time
         FROM t1)Q;
分享:

    相关文档

    相关产品