goccy / go-zetasqlite

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

Cannot `UNNEST` null array fields #179

Closed ohaibbq closed 8 months ago

ohaibbq commented 9 months ago
WITH file AS (
  SELECT 1 AS file_id, ARRAY<STRING>["r", "w"] AS modes
  UNION ALL SELECT 2, ARRAY<STRING>["w"]
)
SELECT id,
(SELECT mode FROM UNNEST(modes) AS mode WHERE mode = 'w') IS NOT NULL AS write_mode,
(SELECT mode FROM UNNEST(modes) AS mode WHERE mode = 'r') IS NOT NULL AS read_mode
FROM UNNEST([1, 2, 3]) id
LEFT JOIN file on file.file_id = id

Expected

id write_mode read_mode
1 true true
2 true false
3 false false

Actual

id write_mode read_mode
1 true true
2 true false
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x100ee1d94]