```sales_in_latest CREATE VIEW sales_of_products A...
# troubleshooting
b
Copy code
sales_in_latest
CREATE VIEW sales_of_products AS  
        SELECT product_id, 
            COUNT(*) totalCnt, 
            SUM(case when SUBSTR(orders.order_date,1,7) = '2023-01' then 1 END) sMM01,
            SUM(case when SUBSTR(orders.order_date,1,7) = '2022-12' then 1 END) sMM12,
            SUM(case when SUBSTR(orders.order_date,1,7) = '2022-11' then 1 END) sMM11,
            SUM(case when SUBSTR(orders.order_date,1,7) = '2022-10' then 1 END) sMM10,
            SUM(case when SUBSTR(orders.order_date,1,7) = '2022-09' then 1 END) sMM09,
            SUM(case when SUBSTR(orders.order_date,1,7) = '2022-08' then 1 END) sMM08,
            SUM(case when SUBSTR(orders.order_date,1,7) = '2022-07' then 1 END) sMM07,
            SUM(case when SUBSTR(orders.order_date,1,7) = '2022-03' then 1 END) sMM03,
            SUM(case when SUBSTR(orders.order_date,1,7) = '2022-04' then 1 END) sMM04,
            SUM(case when SUBSTR(orders.order_date,1,7) = '2022-05' then 1 END) sMM05,
            SUM(case when SUBSTR(orders.order_date,1,7) = '2022-06' then 1 END) sMM06
        FROM order_skus
            JOIN orders ON orders.id = order_skus.order_id 
        WHERE orders.status NOT IN ('prepared_wx_prepay', 'failed', 'wait_pay', 'user_cancel', 'system_cancel')
        GROUP BY order_skus.product_id
when query this view in md file, error like this:
my-evidence-project@0.0.1 dev
evidence dev -o
SvelteKit v1.0.0-next.202 network: not exposed network: not exposed local: http://localhost:3000 Use --host to expose server to other devices on this network ✓ orders_by_month from database ✓ orders_of_last_month from database ✓ orders_of_this_month from database sales_in_latest running... D:\Users\james\evidence>
Running environment is • OS: windows 10 pro 22h2 19045.2546 • evidence@latest (2023.1.31 utc+9) • data access to duckdb
g
Does the dev server stop working completely when you try to run that query?
b
start 'npm run dev' and stop. just like written above console message. no other error information.
g
ok got it, thanks! Has this query worked for you in Evidence in previous versions?
b
today I try first this query. I seem to encounter this phenomenon mainly when using JOIN
g
If you remove this line, will the query run?
CREATE VIEW sales_of_products AS
b
CREATE VIEW sales_of_products AS
in duckdb, in Evidence
SELECT * FROM sales_of_product ORDER BY totalCnt desc LIMIT 20
g
ah sorry, I understand now. I'll look into this a bit more
So far I haven't been able to reproduce the issue. Just to confirm, are you able to see the results of the view in your IDE (or wherever you created the view from)?
I got as close as I could with our demo database:
b
I can see the results of view in command window like this: but in Evidence I meet stop without error message.
In Evidence
CREATE VIEW sales_of_products AS
gives execution error
CREATE TABLE sales_of_products AS
succeeds DuckDB How did you do it?(DuckDB 너 어떻게 한거야?)
💦 1
g
hmm strange - I used the
CREATE VIEW
syntax and it worked. I was using DBeaver to set up the view before testing in Evidence. Two other things that might be impacting this - I'm on a Mac (I'll test on Windows next) + I wonder if the duckdb version has anything to do with it
ok i've reproduced it on windows! Will play around with it some more and see if I find the issue
I tried running the view query inside of evidence rather than creating the view inside duckdb and I still got the error (only on Windows)
Then I reduced the query down to the most minimal I could and ended up with this:
Copy code
select item from orders 
join deliveries on orders.id=deliveries.order_id
This query breaks on Windows, but works on Mac. Interestingly, changing the join to a "left join" gets the query to run on Windows, but if you then add a where clause to it, it breaks again
Unfortunately this is a duckdb issue, so there's not much that we can do, but I've added a comment into this issue they're tracking on github: https://github.com/duckdb/duckdb/issues/5370#issuecomment-1412265839
💋 1
🤩 1