Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTE's don't respond with JSON format #106

Closed
mike-luabase opened this issue Jan 16, 2022 · 3 comments
Closed

CTE's don't respond with JSON format #106

mike-luabase opened this issue Jan 16, 2022 · 3 comments

Comments

@mike-luabase
Copy link

mike-luabase commented Jan 16, 2022

Queries with a CTE respond with the data as text without the normal JSON structure

let sql = `
with a1 as (select 1)
select * from a1
`
const d = await clickhouse.query(sql).toPromise();
console.log('clickhouse result: ', d)

result

clickhouse result:  1  2

Using clickhouse-client

lua-2 :) with a1 as (select 1 as a)
         select a, 2 as b from a1

WITH a1 AS
    (
        SELECT 1 AS a
    )
SELECT
    a,
    2 AS b
FROM a1

Query id: e5d31289-c52c-425a-90f1-d87786ac8298

┌─a─┬─b─┐
│ 1 │ 2 │
└───┴───┘

1 rows in set. Elapsed: 0.133 sec. 
@mike-luabase
Copy link
Author

mike-luabase commented Jan 16, 2022

ClickHouse client version 21.12.3.32 (official build).
Connected to ClickHouse server version 21.12.3 revision 54452.

@mike-luabase
Copy link
Author

As mentioned here, adding with to this regex appears to fix the issue

if (query.match(/^(select|with|show|exists)/i)) {

@mike-luabase mike-luabase changed the title CTE's don't work CTE's don't respond with JSON format Jan 16, 2022
@TimonKK
Copy link
Owner

TimonKK commented Jul 11, 2022

The fix has been released

@TimonKK TimonKK closed this as completed Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants