apache / shardingsphere

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.
Apache License 2.0
19.76k stars 6.69k forks source link

pgsql aliases cannot be resolved #24917

Open 794086163 opened 1 year ago

794086163 commented 1 year ago

Bug Report

Which version of ShardingSphere did you use?

5.2.1

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Expected behavior

can get the function alias field

Actual behavior

Error attempting to get column 'statisticsDate' from result set. Cause: java.sql.SQLFeatureNotSupportedException: Can not get index from column label statisticsDate.\n; Can not get index from column label statisticsDate.; nested exception is java.sql.SQLFeatureNotSupportedException: Can not get index from column label statisticsDate."

Reason analyze (If you can)

SQL parsing exception image

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

SELECT * FROM ( SELECT '2023-03' AS "statisticsDate" ) A LEFT JOIN ( SELECT id AS "data_net_type" , to_char( date_trunc( 'month', '2023-03-03' :: DATE ), 'YYYY-MM' ) AS "date"

FROM
    test

ORDER BY
"date" 
) b ON A."statisticsDate" = b."date"
strongduanmu commented 1 year ago

Hi @794086163, does this sql contains sharding table?

794086163 commented 1 year ago

Hi @794086163, does this sql contains sharding table? Does not contain

strongduanmu commented 1 year ago

You can try the latest 5.3.2 version, we have fix this exception.

794086163 commented 1 year ago

You can try the latest 5.3.2 version, we have fix this exception.

ok,i try it

794086163 commented 1 year ago

5.3.2 Can be fixed

794086163 commented 1 year ago

You can try the latest 5.3.2 version, we have fix this exception.

image

select cast( id as text) ,cast(id as text) from test