Skip to content

Commit

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

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

* README

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

* jsoncompacteachrowwithnamesandtypes

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

* reorder

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

---------

Signed-off-by: Julio Jimenez <[email protected]>
  • Loading branch information
juliojimenez committed Feb 19, 2023
1 parent f2e0c48 commit b322ec3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ clickhouse-cl supports automatic input and output format processing for the form
| [JSONStringsEachRowWithProgress](https://clickhouse.com/docs/en/interfaces/formats/#jsonstringseachrowwithprogress) || :heavy_check_mark: | BOOST-JSON:JSON-OBJECT | jget *obj* *key* |
| [JSONCompactEachRow](https://clickhouse.com/docs/en/interfaces/formats/#jsoncompacteachrow) | :heavy_check_mark: | :heavy_check_mark: | BOOST-JSON:JSON-OBJECT | jget *obj* *key* |
| [JSONCompactEachRowWithNames](https://clickhouse.com/docs/en/interfaces/formats/#jsoncompacteachrowwithnames) | :heavy_check_mark: | :heavy_check_mark: | BOOST-JSON:JSON-OBJECT | jget *obj* *key* |
| [JSONCompactEachRowWithNamesAndTypes](https://clickhouse.com/docs/en/interfaces/formats/#jsoncompacteachrowwithnamesandtypes) | :heavy_check_mark: | :heavy_check_mark: | BOOST-JSON:JSON-OBJECT | jget *obj* *key* |
| [Pretty](https://clickhouse.com/docs/en/interfaces/formats/#pretty) || :heavy_check_mark: || Best viewed with `:console t` |

### Functions
Expand Down
3 changes: 1 addition & 2 deletions 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.17.0"
:version "0.18.0"
:depends-on (#:boost-json
#:dexador
#:lexer
Expand All @@ -15,7 +15,6 @@
(:file "clickhouse" :depends-on ("http" "ch-sql-parser")))))
:in-order-to ((test-op (test-op "clickhouse-test"))))


(asdf:defsystem #:clickhouse/ci
:description "CI for Common Lisp ClickHouse Client Library"
:author "[email protected]"
Expand Down
17 changes: 9 additions & 8 deletions src/ch-sql-parser.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,14 @@
(progn
(setf chosen-format (token-value (nth (+ 1 i) lexer)))
;(print chosen-format)
(cond ((equal chosen-format "JSON") (setf *format* 'json))
(cond ((equal chosen-format "TabSeparated") (setf *format* 'tabseparated))
((equal chosen-format "TabSeparatedRaw") (setf *format* 'tabseparatedraw))
((equal chosen-format "TabSeparatedWithNames") (setf *format* 'tabseparatedwithnames))
((equal chosen-format "TabSeparatedWithNamesAndTypes") (setf *format* 'tabseparatedwithnamesandtypes))
((equal chosen-format "CSV") (setf *format* 'csv))
((equal chosen-format "CSVWithNames") (setf *format* 'csvwithnames))
((equal chosen-format "CSVWithNamesAndTypes") (setf *format* 'csvwithnamesandtypes))
((equal chosen-format "JSON") (setf *format* 'json))
((equal chosen-format "JSONStrings") (setf *format* 'jsonstrings))
((equal chosen-format "JSONColumns") (setf *format* 'jsoncolumns))
((equal chosen-format "JSONColumnsWithMetadata") (setf *format* 'jsoncolumnswithmetadata))
Expand All @@ -283,14 +290,8 @@
((equal chosen-format "JSONStringsEachRowWithProgress") (setf *format* 'jsonstringseachrowwithprogress))
((equal chosen-format "JSONCompactEachRow") (setf *format* 'jsoncompacteachrow))
((equal chosen-format "JSONCompactEachRowWithNames") (setf *format* 'jsoncompacteachrowwithnames))
((equal chosen-format "JSONCompactEachRowWithNamesAndTypes") (setf *format* 'jsoncompacteachrowwithnamesandtypes))
((equal chosen-format "Pretty") (setf *format* 'pretty))
((equal chosen-format "TabSeparated") (setf *format* 'tabseparated))
((equal chosen-format "TabSeparatedRaw") (setf *format* 'tabseparatedraw))
((equal chosen-format "TabSeparatedWithNames") (setf *format* 'tabseparatedwithnames))
((equal chosen-format "TabSeparatedWithNamesAndTypes") (setf *format* 'tabseparatedwithnamesandtypes))
((equal chosen-format "CSV") (setf *format* 'csv))
((equal chosen-format "CSVWithNames") (setf *format* 'csvwithnames))
((equal chosen-format "CSVWithNamesAndTypes") (setf *format* 'csvwithnamesandtypes))
(t (setf *format* nil))))))))

(defun to-vector (val)
Expand Down
3 changes: 2 additions & 1 deletion src/utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
(equalp formatting clickhouse.ch-sql-parser::'jsonstringseachrow)
(equalp formatting clickhouse.ch-sql-parser::'jsonstringseachrowwithprogress)
(equalp formatting clickhouse.ch-sql-parser::'jsoncompacteachrow)
(equalp formatting clickhouse.ch-sql-parser::'jsoncompacteachrowwithnames))
(equalp formatting clickhouse.ch-sql-parser::'jsoncompacteachrowwithnames)
(equalp formatting clickhouse.ch-sql-parser::'jsoncompacteachrowwithnamesandtypes))
(jsoneachrow-formats b))
((equalp formatting clickhouse.ch-sql-parser::'pretty)
(pretty-formatter b))
Expand Down

0 comments on commit b322ec3

Please sign in to comment.