Insert data to clickhouse DB using Redash


#1

Issue Summary

is it possible to insert to data into Clickhouse using Redash SQL editor ?

Table:

CREATE TABLE test ( UserID UInt64,
PageViews UInt8,
Duration UInt8,
Sign Int8)
ENGINE = CollapsingMergeTree(Sign)
ORDER BY UserID;

Insert query (direct tested using yandex/clickhouse-client ):

INSERT INTO test
VALUES (14,
5,
3,
1)

Got error :
Error running query: Code: 27, e.displayText() = DB::Exception: Cannot parse input: expected ( before: FORMAT JSON: (at row 2) , e.what() = DB::Exception

Technical details:


#2

For future reference, copying @Vladis’s response from Slack:

No, it’s not possible because there is added FORMAT JSON string to the end of query.


#3

I’ll add some details:

We should use “FORMAT JSON” string in query runner to fast parse it to Redash’s result format.

Modifying (insert/create/alter) data through Redash is not common use case. I can add some options to make it possible through Redash if it’s needed.

@arikfr WDYT?


#4

Not sure about this. How will you detect if it’s a non select query?


#5

@arikfr something like this works in my projects:

query_string.strip().split(' ')[0].lower().strip() == 'select'