Skip to content

Commit

Permalink
Merge branch 'main' into feat-convert-tuple-size
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li authored May 30, 2024
2 parents f6ef40f + 3082f3d commit 991384e
Show file tree
Hide file tree
Showing 48 changed files with 932 additions and 422 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/bindings.nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,24 @@ jobs:

build:
needs: integration
name: build-${{ matrix.os }}-${{ matrix.arch }}
name: build-${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- { os: linux, arch: arm64, target: aarch64-unknown-linux-gnu, runner: ubuntu-20.04 }
- { os: linux, arch: x64, target: x86_64-unknown-linux-gnu, runner: ubuntu-20.04 }
- { os: windows, arch: x64, target: x86_64-pc-windows-msvc, runner: windows-2019 }
- { os: macos, arch: x64, target: x86_64-apple-darwin, runner: macos-11 }
- { os: macos, arch: arm64, target: aarch64-apple-darwin, runner: macos-11 }
- { target: x86_64-unknown-linux-gnu, runner: ubuntu-20.04 }
- { target: aarch64-unknown-linux-gnu, runner: ubuntu-20.04 }
- { target: aarch64-unknown-linux-musl, runner: ubuntu-latest }
- { target: x86_64-unknown-linux-musl, runner: ubuntu-latest }
- { target: x86_64-pc-windows-msvc, runner: windows-2019 }
- { target: x86_64-apple-darwin, runner: macos-11 }
- { target: aarch64-apple-darwin, runner: macos-11 }
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: ./.github/actions/setup
with:
cache-key: bindings-nodejs-${{ matrix.os }}-${{ matrix.arch }}
cache-key: bindings-nodejs-${{ matrix.target }}
target: ${{ matrix.target }}
- name: Setup node
uses: actions/setup-node@v4
Expand Down Expand Up @@ -99,13 +101,13 @@ jobs:
yarn build
fi
- name: strip for macos
if: matrix.os == 'macos'
if: endsWith(matrix.target, '-apple-darwin')
working-directory: bindings/nodejs
run: |
strip -x *.node
- uses: actions/upload-artifact@v4
with:
name: bindings-nodejs-${{ matrix.os }}-${{ matrix.arch }}
name: bindings-nodejs-${{ matrix.target }}
path: bindings/nodejs/*.node

publish:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/bindings.python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
strategy:
matrix:
include:
- { os: linux, arch: x86_64, target: x86_64-unknown-linux-gnu, runner: ubuntu-20.04 }
# - { os: linux, arch: aarch64, target: aarch64-unknown-linux-gnu, runner: ubuntu-20.04 }
- { os: linux, arch: x86_64, target: x86_64-unknown-linux-gnu, runner: ubuntu-latest }
- { os: linux, arch: aarch64, target: aarch64-unknown-linux-gnu, runner: ubuntu-latest }
- { os: windows, arch: x86_64, target: x86_64-pc-windows-msvc, runner: windows-2019 }
- { os: macos, arch: x86_64, target: x86_64-apple-darwin, runner: macos-11 }
- { os: macos, arch: aarch64, target: aarch64-apple-darwin, runner: macos-11 }
Expand All @@ -69,6 +69,11 @@ jobs:
else
echo "BUILD_ARGS=--release --strip --out dist" >> $GITHUB_OUTPUT
fi
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
echo "MANYLINUX=2_28" >> $GITHUB_OUTPUT
else
echo "MANYLINUX=auto" >> $GITHUB_OUTPUT
fi
- name: Setup Rust toolchain
uses: ./.github/actions/setup
with:
Expand All @@ -79,6 +84,7 @@ jobs:
with:
working-directory: bindings/python
target: ${{ matrix.target }}
manylinux: ${{ steps.opts.outputs.MANYLINUX }}
sccache: 'true'
args: ${{ steps.opts.outputs.BUILD_ARGS }}
- name: Upload artifact
Expand Down
13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.16.3"
version = "0.18.2"
edition = "2021"
license = "Apache-2.0"
authors = ["Databend Authors <[email protected]>"]
Expand All @@ -21,7 +21,10 @@ keywords = ["databend", "database"]
repository = "https://github.com/datafuselabs/bendsql"

[workspace.dependencies]
databend-client = { path = "core", version = "0.16.3" }
databend-driver = { path = "driver", version = "0.16.3" }
databend-driver-macros = { path = "macros", version = "0.16.3" }
databend-sql = { path = "sql", version = "0.16.3" }
databend-client = { path = "core", version = "0.18.2" }
databend-driver = { path = "driver", version = "0.18.2" }
databend-driver-macros = { path = "macros", version = "0.18.2" }
databend-sql = { path = "sql", version = "0.18.2" }

[patch.crates-io]
pyo3-asyncio = { git = "https://github.com/everpcpc/pyo3-asyncio", rev = "42af887" }
175 changes: 86 additions & 89 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ Databend Native Client in Rust

## Components

- [**core**](core): Databend RestAPI rust client
- [**core**](core): Databend RestAPI Rust client

- [**driver**](driver): Databend unified SQL client for RestAPI and FlightSQL
- [**driver**](driver): Databend SQL client for both RestAPI and FlightSQL

- [**cli**](cli): Databend native CLI


## Installation for BendSQL

### Cargo:
Expand All @@ -27,7 +26,6 @@ Or alternatively build from source:
cargo install bendsql
```


### Homebrew:

```bash
Expand All @@ -36,13 +34,13 @@ brew install databendcloud/homebrew-tap/bendsql

### Apt:

* Using DEB822-STYLE format on Ubuntu-22.04/Debian-12 and later:
- Using DEB822-STYLE format on Ubuntu-22.04/Debian-12 and later:

```bash
sudo curl -L -o /etc/apt/sources.list.d/datafuselabs.sources https://repo.databend.rs/deb/datafuselabs.sources
```

* Using old format on Ubuntu-20.04/Debian-11 and earlier:
- Using old format on Ubuntu-20.04/Debian-11 and earlier:

```bash
sudo curl -L -o /usr/share/keyrings/datafuselabs-keyring.gpg https://repo.databend.rs/deb/datafuselabs.gpg
Expand All @@ -61,7 +59,6 @@ sudo apt install bendsql

Check for latest version on [GitHub Release](https://github.com/datafuselabs/bendsql/releases)


## Usage

```
Expand All @@ -71,34 +68,40 @@ Databend Native Command Line Tool
Usage: bendsql [OPTIONS]
Options:
--help Print help information
--flight Using flight sql protocol
--tls Enable TLS
-h, --host <HOST> Databend Server host, Default: 127.0.0.1
-P, --port <PORT> Databend Server port, Default: 8000
-u, --user <USER> Default: root
-p, --password <PASSWORD> [env: BENDSQL_PASSWORD=]
-D, --database <DATABASE> Database name
--set <SET> Settings
--dsn <DSN> Data source name [env: BENDSQL_DSN=]
-n, --non-interactive Force non-interactive mode
--query=<QUERY> Query to execute
-d, --data <DATA> Data to load, @file or @- for stdin
-f, --format <FORMAT> Data format to load [default: csv] [possible values: csv, tsv, ndjson, parquet, xml]
--format-opt <FORMAT_OPT> Data format options
-o, --output <OUTPUT> Output format [possible values: table, csv, tsv, null]
--progress Show progress for query execution in stderr, only works with output format `table` and `null`.
--stats Show stats after query execution in stderr, only works with non-interactive mode.
--time[=<TIME>] Only show execution time without results, will implicitly set output format to `null`. [possible values: local, server]
-V, --version Print version
--help Print help information
--flight Using flight sql protocol, ignored when --dsn is set
--tls Enable TLS, ignored when --dsn is set
-h, --host <HOST> Databend Server host, Default: 127.0.0.1, ignored when --dsn is set
-P, --port <PORT> Databend Server port, Default: 8000, ignored when --dsn is set
-u, --user <USER> Default: root, overrides username in DSN
-p, --password <PASSWORD> Password, overrides password in DSN [env: BENDSQL_PASSWORD]
-r, --role <ROLE> Downgrade role name, overrides role in DSN
-D, --database <DATABASE> Database name, overrides database in DSN
--set <SET> Settings, overrides settings in DSN
--dsn <DSN> Data source name [env: BENDSQL_DSN]
-n, --non-interactive Force non-interactive mode
-A, --no-auto-complete Disable loading tables and fields for auto-completion, which offers a quicker start
--check Check for server status and exit
--query=<QUERY> Query to execute
-d, --data <DATA> Data to load, @file or @- for stdin
-f, --format <FORMAT> Data format to load [default: csv] [possible values: csv, tsv, ndjson, parquet, xml]
--format-opt <FORMAT_OPT> Data format options
-o, --output <OUTPUT> Output format [possible values: table, csv, tsv, null]
--quote-style <QUOTE_STYLE> Output quote style, applies to `csv` and `tsv` output formats [possible values: always, necessary, non-numeric, never]
--progress Show progress for query execution in stderr, only works with output format `table` and `null`.
--stats Show stats after query execution in stderr, only works with non-interactive mode.
--time[=<TIME>] Only show execution time without results, will implicitly set output format to `null`. [possible values: local, server]
-l, --log-level <LOG_LEVEL> [default: info]
-V, --version Print version
```

## Custom configuration

By default bendsql will read configuration from `~/.bendsql/config.toml` and `~/.config/bendsql/config.toml`
sequentially if exists.
sequentially if exists.

- Example file

```
❯ cat ~/.bendsql/config.toml
[connection]
Expand All @@ -108,55 +111,53 @@ connect_timeout = "30s"
[settings]
display_pretty_sql = true
progress_color = "green"
expand = "auto"
no_auto_complete = true
prompt = ":) "
```


- Connection section

| Parameter | Description |
|---|---|
| `host` | Server host to connect. |
| `port` | Server port to connect. |
| `user` | User name. |
| `database` | Which database to connect. |
| `args` | Additional connection args. |

| Parameter | Description |
| ---------- | --------------------------- |
| `host` | Server host to connect. |
| `port` | Server port to connect. |
| `user` | User name. |
| `database` | Which database to connect. |
| `args` | Additional connection args. |

- Settings section

| Parameter | Description |
|---|---|
| `display_pretty_sql` | Whether to display SQL queries in a formatted way. |
| `prompt` | The prompt to display before asking for input. |
| `progress_color` | The color to use for the progress bar. |
| `show_progress` | Whether to show a progress bar when executing queries. |
| `show_stats` | Whether to show statistics after executing queries. |
| `max_display_rows` | The maximum number of rows to display in table output format. |
| `max_width` | Limit display render box max width, 0 means default to the size of the terminal. |
| `max_col_width` | Limit display render each column max width, smaller than 3 means disable the limit. |
| `output_format` | The output format to use. |
| `expand` | Expand table format display, default off, could be on/off/auto. |
| `time` | Whether to show the time elapsed when executing queries. |
| `multi_line` | Whether to allow multi-line input. |
| `replace_newline` | whether replace '\n' with '\\\n'. |

| Parameter | Description |
| -------------------- | ----------------------------------------------------------------------------------- |
| `display_pretty_sql` | Whether to display SQL queries in a formatted way. |
| `prompt` | The prompt to display before asking for input. |
| `progress_color` | The color to use for the progress bar. |
| `show_progress` | Whether to show a progress bar when executing queries. |
| `show_stats` | Whether to show statistics after executing queries. |
| `no_auto_complete` | Whether to disable loading tables and fields for auto-completion on startup. |
| `max_display_rows` | The maximum number of rows to display in table output format. |
| `max_width` | Limit display render box max width, 0 means default to the size of the terminal. |
| `max_col_width` | Limit display render each column max width, smaller than 3 means disable the limit. |
| `output_format` | The output format to use. |
| `expand` | Expand table format display, default auto, could be on/off/auto. |
| `time` | Whether to show the time elapsed when executing queries. |
| `multi_line` | Whether to allow multi-line input. |
| `replace_newline` | whether replace '\n' with '\\\n'. |

## Commands in REPL

| Commands | Description |
|---|---|
| `!exit` | Exit bendsql |
| `!quit` | Exit bendsql |
| `!configs` | Show current settings |
| `!set` | Set settings |
| Commands | Description |
| -------------- | ----------------------- |
| `!exit` | Exit bendsql |
| `!quit` | Exit bendsql |
| `!configs` | Show current settings |
| `!set` | Set settings |
| `!source file` | Source file and execute |

## Setting commands in REPL

We can use `!set CMD_NAME VAL` to update the `Settings` above in runtime, example:

```
❯ bendsql
Expand All @@ -168,6 +169,7 @@ We can use `!set CMD_NAME VAL` to update the `Settings` above in runtime, exampl
## DSN

Format:

```
databend[+flight]://user:[password]@host[:port]/[database][?sslmode=disable][&arg1=value1]
```
Expand All @@ -180,48 +182,43 @@ Examples:

- `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. |
| `tls_ca_file` | Custom root CA certificate path. |
| `connect_timeout` | Connect timeout in seconds |

| Arg | Description |
| ----------------- | ------------------------------------ |
| `tenant` | Tenant ID, Databend Cloud only. |
| `warehouse` | Warehouse name, Databend Cloud only. |
| `sslmode` | Set to `disable` if not using tls. |
| `tls_ca_file` | Custom root CA certificate path. |
| `connect_timeout` | Connect timeout in seconds |

RestAPI client:

| Arg | Description |
|---|---|
| `presigned_url_disabled` | Set to `1` to disable presigned upload to object storage, *deprecated*, use `presign` instead |
| `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 |
| `page_request_timeout_secs` | Timeout for a single page request, default to `30` |
| `presign` | Whether to enable presign for data loading, available arguments are auto/detect/on/off, default to `auto` which only enable presign for `Databend Cloud` |

| Arg | Description |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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 |
| `page_request_timeout_secs` | Timeout for a single page request, default to `30` |
| `presign` | Whether to enable presign for data loading, available arguments are `auto`/`detect`/`on`/`off`. Default to `auto` which only enable presign for `Databend Cloud` |

FlightSQL client:

| Arg | Description |
|---|---|
| `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` |
| Arg | Description |
| --------------------------- | ------------------------------------------------------------------------- |
| `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

### Cargo fmt, clippy, deny
Expand All @@ -238,7 +235,7 @@ make test

### integration tests

*Note: Docker and Docker Compose needed*
_Note: Docker and Docker Compose needed_

```bash
make integration
Expand Down
Loading

0 comments on commit 991384e

Please sign in to comment.