Skip to content

Commit

Permalink
fix: put settings_clause before FORMAT RowBinary
Browse files Browse the repository at this point in the history
  • Loading branch information
magurotuna committed May 29, 2023
1 parent b3cf2b7 commit 465b1cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<T> Insert<T> {

// TODO: what about escaping a table name?
// https://clickhouse.yandex/docs/en/query_language/syntax/#syntax-identifiers
let query = format!("INSERT INTO {table} ({fields}) FORMAT RowBinary {settings_clause}");
let query = format!("INSERT INTO {table} ({fields}) {settings_clause} FORMAT RowBinary");
pairs.append_pair("query", &query);

if client.compression.is_lz4() {
Expand Down
16 changes: 14 additions & 2 deletions tests/test_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ async fn async_insert() {
struct MyRow<'a> {
no: u32,
name: &'a str,
ts: u32,
}

// Create a table.
client
.query(
"
CREATE TABLE test(no UInt32, name LowCardinality(String))
CREATE TABLE test(
no UInt32,
name LowCardinality(String),
ts Datetime
)
ENGINE = MergeTree
ORDER BY no
",
Expand All @@ -92,7 +97,14 @@ async fn async_insert() {
.build();
let mut insert = client.async_insert("test", opts).unwrap();
for i in 0..1000 {
insert.write(&MyRow { no: i, name: "foo" }).await.unwrap();
insert
.write(&MyRow {
no: i,
name: "foo",
ts: 42,
})
.await
.unwrap();
}

insert.end().await.unwrap();
Expand Down

0 comments on commit 465b1cf

Please sign in to comment.