-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(query,insert): add query-level settings override (#123)
- Loading branch information
Showing
13 changed files
with
490 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use clickhouse::{error::Result, Client}; | ||
|
||
/// Besides [`Client::query`], it works similarly with [`Client::insert`] and [`Client::inserter`]. | ||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let client = Client::default() | ||
.with_url("http://localhost:8123") | ||
// This setting is global and will be applied to all queries. | ||
.with_option("limit", "100"); | ||
|
||
let numbers = client | ||
.query("SELECT number FROM system.numbers") | ||
// This setting will be applied to this particular query only; | ||
// it will override the global client setting. | ||
.with_option("limit", "3") | ||
.fetch_all::<u64>() | ||
.await?; | ||
|
||
// note that it prints the first 3 numbers only (because of the setting override) | ||
println!("{numbers:?}"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.