mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
formatQuery: improve doc
This commit is contained in:
parent
0bda99e880
commit
21e0c510c8
@ -2797,7 +2797,7 @@ message Root
|
||||
|
||||
## formatQuery
|
||||
|
||||
Returns a formatted version of the given SQL query.
|
||||
Returns a formatted, possibly multi-line, version of the given SQL query.
|
||||
|
||||
**Syntax**
|
||||
|
||||
@ -2815,30 +2815,6 @@ formatQuery(query)
|
||||
|
||||
**Example**
|
||||
|
||||
```sql
|
||||
SELECT formatQuery('select 1;');
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```result
|
||||
┌─formatQuery('select 1;')─┐
|
||||
│ SELECT 1 │
|
||||
└──────────────────────────┘
|
||||
```
|
||||
|
||||
```sql
|
||||
SELECT formatQuery('SeLecT 1');
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```result
|
||||
┌─formatQuery('SeLecT 1')──┐
|
||||
│ SELECT 1 │
|
||||
└──────────────────────────┘
|
||||
```
|
||||
|
||||
```sql
|
||||
SELECT formatQuery('select a, b FRom tab WHERE a > 3 and b < 3');
|
||||
```
|
||||
@ -2857,7 +2833,7 @@ WHERE (a > 3) AND (b < 3) │
|
||||
|
||||
## formatQueryOneLine
|
||||
|
||||
Returns a formatted version of the given SQL query on a single line.
|
||||
Like formatQuery() but the returned formatted string contains no line breaks.
|
||||
|
||||
**Syntax**
|
||||
|
||||
@ -2881,30 +2857,6 @@ SELECT formatQueryOneLine('select 1;');
|
||||
|
||||
Result:
|
||||
|
||||
```result
|
||||
┌─formatQueryOneLine('select 1;')─┐
|
||||
│ SELECT 1 │
|
||||
└─────────────────────────────────┘
|
||||
```
|
||||
|
||||
```sql
|
||||
SELECT formatQueryOneLine('SeLecT 1');
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```result
|
||||
┌─formatQueryOneLine('SeLecT 1')──┐
|
||||
│ SELECT 1 │
|
||||
└─────────────────────────────────┘
|
||||
```
|
||||
|
||||
```sql
|
||||
SELECT formatQueryOneLine('select a, b FRom tab WHERE a > 3 and b < 3');
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```result
|
||||
┌─formatQueryOneLine('select a, b FRom tab WHERE a > 3 and b < 3')─┐
|
||||
│ SELECT a, b FROM tab WHERE (a > 3) AND (b < 3) │
|
||||
|
@ -106,13 +106,11 @@ struct NameFormatQueryOneLine
|
||||
REGISTER_FUNCTION(formatQuery)
|
||||
{
|
||||
factory.registerFunction<FunctionFormatQuery<false, NameFormatQuery>>(FunctionDocumentation{
|
||||
.description = "Returns a formatted version of the given SQL query.\n[example:simple]\n[example:camelcase]",
|
||||
.description = "Returns a formatted, possibly multi-line, version of the given SQL query.\n[example:multiline]",
|
||||
.syntax = "formatQuery(query)",
|
||||
.arguments = {{"query", "The SQL query to be formatted. [String](../../sql-reference/data-types/string.md)"}},
|
||||
.returned_value = "The formatted query. [String](../../sql-reference/data-types/string.md).",
|
||||
.examples{
|
||||
{"simple", "SELECT formatQuery('select 1;')", "SELECT 1"},
|
||||
{"camelcase", "SELECT formatQuery('SeLecT 1')", "SELECT 1"},
|
||||
{"multiline",
|
||||
"SELECT formatQuery('select a, b FRom tab WHERE a > 3 and b < 3');",
|
||||
"SELECT\n"
|
||||
@ -126,13 +124,11 @@ REGISTER_FUNCTION(formatQuery)
|
||||
REGISTER_FUNCTION(formatQueryOneLine)
|
||||
{
|
||||
factory.registerFunction<FunctionFormatQuery<true, NameFormatQueryOneLine>>(FunctionDocumentation{
|
||||
.description = "Returns a formatted version of the given SQL query on a single line.\n[example:simple]\n[example:camelcase]",
|
||||
.description = "Like formatQuery() but the returned formatted string contains no line breaks.\n[example:multiline]",
|
||||
.syntax = "formatQueryOneLine(query)",
|
||||
.arguments = {{"query", "The SQL query to be formatted. [String](../../sql-reference/data-types/string.md)"}},
|
||||
.returned_value = "The formatted query. [String](../../sql-reference/data-types/string.md).",
|
||||
.examples{
|
||||
{"simple", "SELECT formatQueryOneLine('select 1;')", "SELECT 1"},
|
||||
{"camelcase", "SELECT formatQueryOneLine('SeLecT 1')", "SELECT 1"},
|
||||
{"multiline",
|
||||
"SELECT formatQuery('select a, b FRom tab WHERE a > 3 and b < 3');",
|
||||
"SELECT a, b FROM tab WHERE (a > 3) AND (b < 3)"}},
|
||||
|
Loading…
Reference in New Issue
Block a user