[ 
https://issues.apache.org/jira/browse/CALCITE-5711?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated CALCITE-5711:
------------------------------------
    Labels: pull-request-available  (was: )

> Implement the SINGLE_VALUE aggregation in PostgreSQL Dialect
> ------------------------------------------------------------
>
>                 Key: CALCITE-5711
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5711
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.34.0
>            Reporter: xiong duan
>            Assignee: xiong duan
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.35.0
>
>
> When we use the SQL including the scalar query, converting this SQL Rel to 
> PostgreSQL will include the SINGLE_VALUE aggregation function(PostgreSQL 
> can't handle it) in the dialect SQL.
> Input SQL:
> {code:java}
> select "product_class_id" as c
> from "product" where  "brand_name" = (select "product_name" from "product") 
> {code}
> PostgreSQL Dialect now generates SQL:
> {code:java}
> SELECT \"product\".\"product_class_id\" AS \"C\"
> FROM \"foodmart\".\"product\"
> LEFT JOIN (SELECT SINGLE_VALUE(\"product_name\") AS \"$f0\"
> FROM \"foodmart\".\"product\") AS \"t0\" ON TRUE
> WHERE \"product\".\"brand_name\" = \"t0\".\"$f0\" {code}
> PostgreSQL Dialect will generate SQL:
> {code:java}
> SELECT "product"."product_class_id" AS "C"
> FROM "foodmart"."product"
> LEFT JOIN (SELECT CASE COUNT(*) WHEN 0 THEN NULL WHEN 1 THEN 
> MIN("product_name") ELSE (SELECT CAST(NULL AS VARCHAR(60))
> UNION ALL
> SELECT CAST(NULL AS VARCHAR(60))) END AS "$f0"
> FROM "foodmart"."product") AS "t0" ON TRUE
> WHERE "product"."brand_name" = "t0"."$f0" {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to