Mark Needham reported a frontend node crash when running a specific query in Postgres. The query involved a CROSS JOIN UNNEST operation on the 'orders' table. Tianxiao Shen mentioned that this query is not valid in Postgres but is supported in systems like Flink and Presto. Mark Needham later shared a corrected query that worked without crashing the frontend node.
Mark Needham
Asked on May 04, 2023
Example of the corrected query:
WITH orderItems AS (
SELECT unnest(items) AS orderItem,
id AS orderId, createdAt
FROM orders
)
SELECT orderId, createdAt,
((orderItem).productid, (orderItem).quantity, (orderItem).price)::
STRUCT<productId varchar, quantity varchar, price varchar> AS orderItem,
(products.id, products.name, products.description, products.category, products.image, products.price)::
STRUCT<id varchar, name varchar, description varchar, category varchar, image varchar, price varchar> AS product
FROM orderItems
JOIN products ON products.id = (orderItem).productId
LIMIT 10```