I recently switched from PostgreSQL to trino, and I run into the problem, that I obviously can't write any WITH statement properly to make it run. I tried to research it but only problem I found is here, and it was a typo in the query.
My query is basically the same, but without the typo, and I still have the same problem:
WITH tab1 as (
select
id,
(case when col2 > 0 then 'a' else 'b' end) as cathegory
from work_schema.generic_table
)
select
tab1.id
-- id # just to demonstrate I tried both, none of them works
from tab1
This query triggers very generic error that I just cannot find anything about in documentation (anything helpful), nor here or anywhere else.
SQL Error [57]: Query failed (#20250120_133332_03607_ritng): line 3:6: Schema must be specified when session schema is not set
The query inside WITH statement alone works, I just don't understand why similar definitions work when I copy them into trino.
Can you guys explain any of these?