Help Center> Data Warehouse Service> Developer Guide> Query Performance Optimization> Troubleshooting Errors Using SQL Statements> "failed to find conversion function from unknown to text" Is Displayed When a User Executes the SELECT Statement

"failed to find conversion function from unknown to text" Is Displayed When a User Executes the SELECT Statement

Description

An error message is displayed when the SELECT statement is executed.

failed to find conversion function from unknown to text

ERROR:  failed to find conversion function from unknown to text

Possible Causes

The type of a constant in a subquery of the SELECT statement is not specified.

Troubleshooting Method

Convert the constant type of the subquery to a fixed type.

Example:

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;

Change it as follows:

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;