goccy / go-zetasqlite

A database driver library that interprets ZetaSQL queries and runs them using SQLite3
MIT License
56 stars 29 forks source link

`ArrayScanNode` formatting does not support all join types #176

Closed ohaibbq closed 8 months ago

ohaibbq commented 9 months ago

Currently only a cross join is used, so clauses that use INNER JOIN or LEFT OUTER JOIN produce incorrect results.

WITH produce AS (select 'lettuce' AS item UNION ALL SELECT 'banana')
SELECT item, in_stock_items is not null AS item_in_stock FROM produce
LEFT OUTER JOIN unnest(['lettuce']) in_stock_items ON in_stock_items = item;
item item_in_stock
lettuce true
banana false
WITH produce AS (select 'lettuce' AS item UNION ALL SELECT 'banana')
SELECT item, in_stock_items is not null AS item_in_stock FROM produce
INNER JOIN unnest(['lettuce']) in_stock_items ON in_stock_items = item;
item item_in_stock
lettuce true