Comments (6)
Awesome, thank you for the extra info. That should make this pretty straightforward. We don't have to touch parsing and can still lowercase lots of tokens- we'll just leave identifiers (incl. function names) alone.
CLI flag should be --dialect clickhouse
from sqlfmt.
@Shlomixg I'm cutting the release for 0.10.0 right now -- if you upgrade, you can run that version with sqlfmt . --dialect clickhouse
and we won't lowercase so many things. Would love to get any more feedback from you!
from sqlfmt.
Thanks for the report, @Shlomixg !
I had no idea ClickHouse was case sensitive. (Why would they do that to us?!)
Should be easy enough to not lowercase the output, but...
Are SQL keywords (like select) also case sensitive, or is it just some/all function names?
I designed this with multiple dialects in mind, so it shouldn't be too bad to change the parsing logic to be case-sensitive. I'm just a little sad because we've gotten away with only one "polyglot" dialect so far.
from sqlfmt.
Thanks for your quick response!
I think only the CH unique functions are case-sensitive, meaning that select isn't case-sensitive.
You can find more information in the docs.
Note that aliases are also case-sensitive.
from sqlfmt.
Implementation notes (this is bigger than I thought, to get the Dialect
or Mode
into the Node.capitalize()
method):
- Add Dialect as a property of Analyzer
- Create a
NodeManager
(NodeBuilder
?) class with Dialect as a property - instantiate a
NodeManager
where needed inactions.py
- move
Node.from_token()
toNodeManager.create_node_from_token()
; also moveNode.capitalize()
andNode.whitespace()
- update
NodeManager.capitalize()
to check for the Clickhouse dialect - update
Line.append_newline()
so it doesn't useNode.from_token()
from sqlfmt.
Bravo :)
I'll test it soon and leave feedback.
Thanks!
from sqlfmt.
Related Issues (20)
- One specific BQ-DBT SQL file gets wrongly formatted and becomes unusable
- Support formatting stdin? HOT 2
- Support pg-promise Query Files with Named Parameters HOT 2
- Case-sentitive identifiers within object navigation expressions are lowercased HOT 2
- Request: Support leading commas HOT 1
- sqlfmt incorrect reformatted JSON access path, breaking all accesses. HOT 1
- Don't merge lines if they contain a trailing comma HOT 3
- parsing error for postgress set HOT 3
- sqlfmt adds an extra space to PostgreSQL double tilda operators (`LIKE` alias) HOT 3
- Support Python format/f-string as templater
- PostgreSQL formatting of extensions is broken HOT 2
- Request: Implement in compiled language HOT 1
- Support for formatting SQL code blocks in Markdown HOT 2
- Table name containing the restricted keyword "case" triggers an error HOT 4
- Unstable indentation in jinja `set` tag with triple-quoted, multiline strings HOT 2
- exists inside select when select items are on separate lines HOT 1
- Don't break union all by name into two lines HOT 2
- Preserve the space between `interval` and a following parenthesis
- Use `ruff format` for jinjafmt if `black` is not available HOT 1
- Modernize dev tooling and CI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlfmt.