Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.34.0
Description
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:
select "product_class_id" as c from "product" where "brand_name" = (select "product_name" from "product")
PostgreSQL Dialect now generates SQL:
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\"
PostgreSQL Dialect will generate SQL:
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"
Attachments
Issue Links
- links to