Skip to content

Conversation

@findinpath
Copy link
Contributor

What changes are proposed in this pull request, and why are they necessary?

The translation of a nested subquery causes inexistent table references in the output query.

Table

CREATE TABLE test.table_id_value (id int, value varchar(255))

Hive View

CREATE VIEW IF NOT EXISTS test.view_max_values AS
SELECT value FROM test.table_id_value  WHERE id IN (SELECT MAX(id) FROM test.table_id_value)

Coral to Trino Translation outcome

SELECT "table_id_value"."value" AS "value"
FROM "test"."table_id_value" AS "table_id_value"
INNER JOIN (
        SELECT MAX("table_id_value0"."id")
        FROM (
                SELECT MAX("table_id_value0"."id")
                FROM "test"."table_id_value" AS "table_id_value0") AS "t0"
                GROUP BY MAX("table_id_value0"."id")
        ) AS "t1"
  ON "table_id_value"."id" = MAX("table_id_value0"."id")

The JOIN expression ON "table_id_value"."id" = MAX("table_id_value0"."id") is referencing an inexistent table - table_id_value0.

How was this patch tested?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant