sqlparse
sqlparse copied to clipboard
Add ClickHouse support
ClickHouse is an OLAP database with some additional syntax
Were is an example of a query that uses most of the additional syntax
CREATE TABLE arrays_test
(
s String,
arr Array(UInt8)
)
ENGINE = MergeTree()
ORDER BY s
PARTITION BY tuple();
INSERT INTO arrays_test VALUES ('Hello', [1,2]), ('World', [3,4,5]), ('Goodbye', []);
SELECT s, arr
FROM arrays_test
ARRAY JOIN arr
PREWHERE s='Hello'
WHERE arr>1
LIMIT 1 BY s
LIMIT 10
FORMAT Pretty;
Result
s |arr|
-----|---|
Hello| 2|
query="SELECT s, arr FROM arrays_test ARRAY JOIN arr PREWHERE s='Hello' WHERE arr>1 LIMIT 1 BY s LIMIT 10 FORMAT Pretty;"
print(sqlparse.format(query, reindent=True, keyword_case='upper'))
SELECT s,
arr
FROM arrays_test
ARRAY JOIN arr
PREWHERE s='Hello'
WHERE arr>1
LIMIT 1 BY s
LIMIT 10
FORMAT Pretty;
Please refuse the pull request if you think it is a very specific database
Codecov Report
Merging #619 (8bb07ce) into master (23d2993) will decrease coverage by
0.80%
. The diff coverage is40.90%
.
@@ Coverage Diff @@
## master #619 +/- ##
==========================================
- Coverage 96.82% 96.02% -0.81%
==========================================
Files 20 20
Lines 1514 1536 +22
==========================================
+ Hits 1466 1475 +9
- Misses 48 61 +13
Impacted Files | Coverage Δ | |
---|---|---|
sqlparse/filters/aligned_indent.py | 100.00% <ø> (ø) |
|
sqlparse/filters/reindent.py | 95.00% <14.28%> (-3.27%) |
:arrow_down: |
sqlparse/engine/grouping.py | 97.45% <36.36%> (-2.55%) |
:arrow_down: |
sqlparse/keywords.py | 100.00% <100.00%> (ø) |
|
sqlparse/sql.py | 97.62% <100.00%> (+0.02%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 23d2993...8bb07ce. Read the comment docs.
Good initiative @filipecaixeta. Please, consider adding other specific types of join, i.e. ALL, ANY, ASOF, SEMI.