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

FORMAT PrettyCompact, Syntax error #103

Closed
debian-testing opened this issue Dec 21, 2021 · 2 comments
Closed

FORMAT PrettyCompact, Syntax error #103

debian-testing opened this issue Dec 21, 2021 · 2 comments

Comments

@debian-testing
Copy link

I am trying to use other formats, for example, FORMAT PrettyCompact to write to a file for reporting, however, the queries fail because FORMAT JSON; is being appended to the query after.

I read the docs, tried the format and raw options, tried removing the format options, setting it to null, etc., but no success.

There is code to process the FORMAT option, but I wasn't able to see any way to deactivate the postfixing of FORMAT JSON; without changing the source of this library.

Is there a way? Any ideas?

Test code (works directly in clickhouse-client)

...
    await clickhouse.query('DROP TABLE IF EXISTS t1').toPromise()
    await clickhouse.query('CREATE TABLE t1 (c1 Int8) ENGINE = MergeTree() ORDER BY (c1)').toPromise()
    await clickhouse.query('INSERT INTO t1 (c1) VALUES (1)').toPromise()
    const r = await clickhouse.query('SELECT * FROM t1 FORMAT PrettyCompact').toPromise()
...

Error: Syntax error: failed at position 25: PrettyCompact FORMAT JSON;

Version: [email protected]

@UnamedRus
Copy link

Because of #102

You can just append WITH 1 as a to your select query.

@debian-testing
Copy link
Author

Thank you, works perfectly! (until #102 fixed...)

For reference: ClickHouse.opts.raw=true is required to properly receive the formatted results.

@TimonKK TimonKK closed this as completed Jan 25, 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

3 participants