clickhouse icon indicating copy to clipboard operation
clickhouse copied to clipboard

Access management queries fail because of obligatory FORMAT

Open ZiggerZZ opened this issue 2 years ago • 1 comments

await client.query("CREATE USER hello HOST ANY IDENTIFIED WITH sha256_password BY 'world').toPromise(); fails with ERROR [ExceptionsHandler] Syntax error: failed at position 77 ('FORMAT'): FORMAT JSON;

The library automatically ends a format (json/csv/tsv) and it makes sense for SELECT queries, however it fails for access management queries.

Any idea for a workaround?

ZiggerZZ avatar Oct 27 '22 20:10 ZiggerZZ

For those who need this as well: I ended up copying index.js to my project and replacing lines 523-525 by

        if (query.toUpperCase().startsWith('CREATE USER') ||
            query.toUpperCase().startsWith('GRANT SELECT') ||
            query.toUpperCase().startsWith('CREATE ROW POLICY')) {
        }
        else if ( ! R_FORMAT_PARSER.test(query)) {
          query += ` FORMAT ${ClickHouse.getFullFormatName(me.format)}`;
        }

ZiggerZZ avatar Oct 28 '22 10:10 ZiggerZZ