Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCAPI-7431: Formatted queries docs #6490

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/en/interfaces/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@ You can cancel a long query by pressing Ctrl+C. However, you will still need to

The command-line client allows passing external data (external temporary tables) for querying. For more information, see the section "External data for query processing".

### Queries with Parameters {#cli-queries-with-parameters}

You can create a query with parameters, and pass values for these parameters with the parameters of the client app. For example:

```bash
clickhouse-client --param_parName="[1, 2]" -q "SELECT * FROM table WHERE a = {parName:Array(UInt16)}"
```

#### Syntax of a Query {#cli-queries-with-parameters-syntax}

Format a query by the standard method. Values that you want to put into the query from the app parameters place in braces and format as follows:

```
{<name>:<data type>}
```

- `name` — Identifier of a placeholder that should be used in app parameter as `--param_name = value`.
- `data type` — A data type of app parameter value. For example, data structure like `(integer, ('string', integer))` can have a data type `Tuple(UInt8, Tuple(String, UInt8))` (also you can use another [integer](../data_types/int_uint.md) types).

#### Example

```bash
clickhouse-client --param_tuple_in_tuple="(10, ('dt', 10))" -q "SELECT * FROM table WHERE val = {tuple_in_tuple:Tuple(UInt8, Tuple(String, UInt8))}"
```

## Configuring {#interfaces_cli_configuration}

You can pass parameters to `clickhouse-client` (all parameters have a default value) using:
Expand Down
9 changes: 9 additions & 0 deletions docs/en/interfaces/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,14 @@ curl -sS 'http://localhost:8123/?max_result_bytes=4000000&buffer_size=3000000&wa

Use buffering to avoid situations where a query processing error occurred after the response code and HTTP headers were sent to the client. In this situation, an error message is written at the end of the response body, and on the client side, the error can only be detected at the parsing stage.

### Queries with Parameters {#cli-queries-with-parameters}

You can create a query with parameters, and pass values for these parameters with the parameters of the HTTP request. For more information, see [CLI Formatted Queries](cli.md#cli-queries-with-parameters).

### Example

```bash
curl -sS "<address>?param_id=2&param_phrase=test" -d "SELECT * FROM table WHERE int_column = {id:UInt8} and string_column = {phrase:String}"
```

[Original article](https://clickhouse.yandex/docs/en/interfaces/http_interface/) <!--hide-->