Skip to content

Commit

Permalink
Merge branch 'main' into modify_display
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li authored Jun 15, 2023
2 parents 813a607 + b9c38da commit c0399bb
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 9 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,59 @@ We can use `.CMD_NAME VAL` to update the `Settings` above in runtime, example:
:) .max_display_rows 10
```

## DSN

Format:
```
databend[+flight]://user:[password]@host[:port]/[database][?sslmode=disabled][&arg1=value1]
```

Examples:

- `databend://root:@localhost:8000/?sslmode=disable`

- `databend://user1:password1@tnxxxx--default.gw.aws-us-east-2.default.databend.com:443/benchmark?enable_dphyp=1`

- `databend+flight://root:@localhost:8900/database1?connect_timeout=10`


Available Args:

Common:

| Arg | Description |
|---|---|
| `tenant` | Tenant ID, Databend Cloud only. |
| `warehouse` | Warehouse name, Databend Cloud only. |
| `sslmode` | Set to `disable` if not using tls |


RestAPI client:

| Arg | Description |
|---|---|
| `presigned_url_disabled` | Set to `1` to disable presigned upload to object storage, *should only be used with local testing environment* |
| `wait_time_secs` | Request wait time for page, default to `1` |
| `max_rows_in_buffer` | Max rows for page buffer |
| `max_rows_per_page` | Max response rows for a single page |


FlightSQL client:

| Arg | Description |
|---|---|
| `connect_timeout` | Grpc connect timeout seconds |
| `query_timeout` | Query timeout seconds |
| `tcp_nodelay` | Default to `true` |
| `tcp_keepalive` | Tcp keepalive seconds, default to `3600`, set to `0` to disable keepalive |
| `http2_keep_alive_interval` | Keep alive interval in seconds, default to `300` |
| `keep_alive_timeout` | Keep alive timeout in seconds, default to `20` |
| `keep_alive_while_idle` | Default to `true` |

Query Settings:

see: [Databend Query Settings](https://databend.rs/doc/sql-commands/show/show-settings)


## Development

Expand Down
3 changes: 1 addition & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bendsql"
version = "0.3.10"
version = "0.3.11"
edition = "2021"
license = "Apache-2.0"
description = "Databend Native Command Line Tool"
Expand All @@ -11,7 +11,6 @@ repository = "https://github.com/datafuselabs/databend-client"
[dependencies]
anyhow = "1.0.70"
async-trait = "0.1.68"
atty = "0.2.14"
chrono = { version = "0.4.24", default-features = false, features = ["clock"] }
clap = { version = "4.1.0", features = ["derive", "env"] }
comfy-table = "6.1.4"
Expand Down
2 changes: 0 additions & 2 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ Options:
-V, --version Print version
```

## Examples

### REPL
```sql
❯ bendsql
Expand Down
3 changes: 3 additions & 0 deletions cli/src/ast/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ pub enum TokenKind {
#[regex(r#"[_a-zA-Z][_$a-zA-Z0-9]*"#)]
Ident,

#[regex(r#"\$[0-9]+"#)]
ColumnPosition,

#[regex(r#"`[^`]*`"#)]
#[regex(r#""([^"\\]|\\.|"")*""#)]
#[regex(r#"'([^'\\]|\\.|'')*'"#)]
Expand Down
9 changes: 6 additions & 3 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ mod display;
mod helper;
mod session;

use std::{collections::BTreeMap, io::stdin};
use std::{
collections::BTreeMap,
io::{stdin, IsTerminal},
};

use anyhow::{anyhow, Result};
use clap::{CommandFactory, Parser, ValueEnum};
Expand Down Expand Up @@ -264,8 +267,8 @@ pub async fn main() -> Result<()> {
}
};
let mut settings = Settings::default();

let is_repl = atty::is(atty::Stream::Stdin) && !args.non_interactive && args.query.is_none();
let is_terminal = stdin().is_terminal();
let is_repl = is_terminal && !args.non_interactive && args.query.is_none();
if is_repl {
settings.display_pretty_sql = true;
settings.show_progress = true;
Expand Down
4 changes: 2 additions & 2 deletions driver/tests/driver/select_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ async fn select_decimal() {
Value::Number(NumberValue::Decimal128(
100i128,
DecimalSize {
precision: 15,
precision: 3,
scale: 2
},
)),
Value::Number(NumberValue::Decimal128(
50i128,
DecimalSize {
precision: 3,
precision: 2,
scale: 1
},
)),
Expand Down
1 change: 1 addition & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[toolchain]
channel = "stable"
date = "2023-06-01"
components = ["rustfmt", "clippy"]

0 comments on commit c0399bb

Please sign in to comment.