Skip to content

Commit

Permalink
📝 JSONCompactStrings Formatter (#127)
Browse files Browse the repository at this point in the history
* 📝 JSONCompactStrings Formatter

Signed-off-by: Julio Jimenez <[email protected]>

* README

Signed-off-by: Julio Jimenez <[email protected]>

* jsoncompactstrings

Signed-off-by: Julio Jimenez <[email protected]>

* tests

Signed-off-by: Julio Jimenez <[email protected]>

* another readme

Signed-off-by: Julio Jimenez <[email protected]>

---------

Signed-off-by: Julio Jimenez <[email protected]>
  • Loading branch information
juliojimenez authored Feb 15, 2023
1 parent 96eb5c3 commit 59cdeb6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Common Lisp ClickHouse Client Library
- [Formats](#formats)
- [Functions](#functions)
- [jget](#jget)
- [Common Forms](#common-forms)
- [Examples](#examples)
- [Connection to a local database](#connection-to-a-local-database)
- [Query](#query)
- [Bugs, Features, and Vulnerabilities Reporting](#bugs-features-and-vulnerabilities-reporting)
Expand Down Expand Up @@ -201,8 +201,8 @@ clickhouse-cl supports automatic input and output format processing for the form

| Format | Input | Output | Result | Functions |
| ------ | ----- | ------ | ------ | --------- |
| TabSeparated | :heavy_check_mark: | :heavy_check_mark: | '('(string*)*) ||
| TabSeparatedRaw | :heavy_check_mark: | :heavy_check_mark: | '('(string*)*) ||
| [TabSeparated](https://clickhouse.com/docs/en/interfaces/formats/#tabseparated) | :heavy_check_mark: | :heavy_check_mark: | '('(string*)*) ||
| [TabSeparatedRaw](https://clickhouse.com/docs/en/interfaces/formats/#tabseparatedraw) | :heavy_check_mark: | :heavy_check_mark: | '('(string*)*) ||
| TabSeparatedWithNames | :heavy_check_mark: | :heavy_check_mark: | '('(string*)*) ||
| TabSeparatedWithNamesAndTypes | :heavy_check_mark: | :heavy_check_mark: | '('(string*)*) ||
| CSV | :heavy_check_mark: | :heavy_check_mark: | '('(string*)*) ||
Expand All @@ -214,6 +214,7 @@ clickhouse-cl supports automatic input and output format processing for the form
| JSONColumns | :heavy_check_mark: | :heavy_check_mark: | BOOST-JSON:JSON-OBJECT | jget *obj* *key* |
| JSONColumnsWithMetadata | :heavy_check_mark: | :heavy_check_mark: | BOOST-JSON:JSON-OBJECT | jget *obj* *key* |
| JSONCompact | :heavy_check_mark: | :heavy_check_mark: | BOOST-JSON:JSON-OBJECT | jget *obj* *key* |
| JSONCompactStrings || :heavy_check_mark: | BOOST-JSON:JSON-OBJECT | jget *obj* *key* |
| Pretty || :heavy_check_mark: || Best viewed with `:console t` |

### Functions
Expand All @@ -236,7 +237,7 @@ CL-USER> (ch:jget *result* "rows")
T
```

## Common Forms
## Examples

### Connection to a local database

Expand Down
2 changes: 1 addition & 1 deletion clickhouse-test.asd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

:author "[email protected]"
:license "Apache-2.0"
:version "0.0.15"
:version "0.0.16"
:depends-on (#:clickhouse
#:fiveam)
:components ((:module "t"
Expand Down
2 changes: 1 addition & 1 deletion clickhouse.asd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:description "Common Lisp ClickHouse Client Library"
:author "[email protected]"
:license "Apache-2.0"
:version "0.9.0"
:version "0.10.0"
:depends-on (#:boost-json
#:dexador
#:lexer
Expand Down
1 change: 1 addition & 0 deletions src/ch-sql-parser.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
((equal chosen-format "JSONColumns") (setf *format* 'jsoncolumns))
((equal chosen-format "JSONColumnsWithMetadata") (setf *format* 'jsoncolumnswithmetadata))
((equal chosen-format "JSONCompact") (setf *format* 'jsoncompact))
((equal chosen-format "JSONCompactStrings") (setf *format* 'jsoncompactstrings))
((equal chosen-format "Pretty") (setf *format* 'pretty))
((equal chosen-format "TabSeparated") (setf *format* 'tabseparated))
((equal chosen-format "TabSeparatedRaw") (setf *format* 'tabseparatedraw))
Expand Down
3 changes: 2 additions & 1 deletion src/utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
(equalp formatting clickhouse.ch-sql-parser::'jsonstrings)
(equalp formatting clickhouse.ch-sql-parser::'jsoncolumns)
(equalp formatting clickhouse.ch-sql-parser::'jsoncolumnswithmetadata)
(equalp formatting clickhouse.ch-sql-parser::'jsoncompact))
(equalp formatting clickhouse.ch-sql-parser::'jsoncompact)
(equalp formatting clickhouse.ch-sql-parser::'jsoncompactstrings))
(json-formats b))
((equalp formatting clickhouse.ch-sql-parser::'pretty)
(pretty-formatter b))
Expand Down
18 changes: 18 additions & 0 deletions t/clickhouse.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@
(is (equalp "│ 1 │
" (clickhouse.utils::pretty-formatter-title-row '(0 4) '("1")))))

(test pretty-formatter-border-top
(is (equalp "┌───┐
" (clickhouse.utils::pretty-formatter-border
'(0 4)
#\BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT
#\BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT
#\BOX_DRAWINGS_LIGHT_DOWN_AND_HORIZONTAL
#\BOX_DRAWINGS_LIGHT_HORIZONTAL))))

(test pretty-formatter-border-bottom
(is (equalp "├───┤
" (clickhouse.utils::pretty-formatter-border
'(0 4)
#\BOX_DRAWINGS_LIGHT_VERTICAL_AND_RIGHT
#\BOX_DRAWINGS_LIGHT_VERTICAL_AND_LEFT
#\BOX_DRAWINGS_LIGHT_VERTICAL_AND_HORIZONTAL
#\BOX_DRAWINGS_LIGHT_HORIZONTAL))))

(test tab-separated-formatter
(is (equalp
'("7" "8" "9")
Expand Down

0 comments on commit 59cdeb6

Please sign in to comment.