|
1 |
| -## ZetaSQL - Analyzer Framework for SQL |
2 |
| - |
3 |
| -ZetaSQL defines a language (grammar, types, data model, and semantics) as well |
4 |
| -as a parser and analyzer. It is not itself a database or query engine. Instead |
5 |
| -it is intended to be used by multiple engines wanting to provide consistent |
6 |
| -behavior for all semantic analysis, name resolution, type checking, implicit |
7 |
| -casting, etc. Specific query engines may not implement all features in the |
8 |
| -ZetaSQL language and may give errors if specific features are not supported. For |
9 |
| -example, engine A may not support any updates and engine B may not support |
10 |
| -analytic functions. |
11 |
| - |
12 |
| -[ZetaSQL Language Guide](docs/README.md) |
13 |
| - |
14 |
| -[ZetaSQL ResolvedAST API](docs/resolved_ast.md) |
15 |
| - |
16 |
| -## Status of Project and Roadmap |
17 |
| - |
18 |
| -This codebase is being open sourced in multiple phases: |
19 |
| - |
20 |
| -1. Parser and Analyzer **Complete** |
21 |
| - - Initial release includes only a subset of tests |
22 |
| -2. Reference Implementation **In Progress** |
23 |
| - - Base capability **Complete** |
24 |
| - - Function library **In Progress** |
25 |
| -3. Compliance Tests **Complete** |
26 |
| - - includes framework for validating compliance of arbitrary engines |
27 |
| -4. Misc tooling |
28 |
| - - Improved Formatter **In Progress** |
29 |
| - |
30 |
| -Multiplatform support is planned for the following platforms: |
31 |
| - |
32 |
| - - Linux (Ubuntu 1804 _with gcc8_ is our reference platform, but others may work). |
33 |
| - - MacOS (Experimental) |
34 |
| - - Windows (version TDB) |
35 |
| - |
36 |
| -Until all this code is released, we cannot provide any guarantees of API |
37 |
| -stability and cannot accept contributions. We will also be releasing more |
38 |
| -documentation over time, particular related to developing engines with this |
39 |
| -framework. Documentation on the [language](docs/) itself is fairly |
40 |
| -complete. |
41 |
| - |
42 |
| - |
43 |
| -## Flags |
44 |
| -ZetaSQL uses the Abseil [Flags](https://abseil.io/blog/20190509-flags) library |
45 |
| -to handle commandline flags. Unless otherwise documented, all flags are for |
46 |
| -debugging purposes only and may change, stop working or be removed at any time. |
47 |
| - |
48 |
| - |
49 |
| -## How to Build |
50 |
| - |
51 |
| -ZetaSQL uses [bazel](https://bazel.build) for building and dependency |
52 |
| -resolution. After installing bazel (we maintain support for 1.0, |
53 |
| -but other versions may work), simply run: |
54 |
| - |
55 |
| -```bazel build ...``` |
56 |
| - |
57 |
| -## How to add as a Dependency in bazel |
58 |
| -See the (WORKSPACE) file, as it is a little unusual. |
59 |
| - |
60 |
| -### With docker |
61 |
| - TODO: Add docker build script. |
62 |
| - |
63 |
| -## Example Usage |
64 |
| -A very basic command line tool is available to run simple queries with the |
65 |
| -reference implementation: |
66 |
| -```bazel run //zetasql/tools/execute_query:execute_query -- "select 1 + 1;"``` |
67 |
| - |
68 |
| -The reference implementation is not yet completely released and currently |
69 |
| -supports only a subset of functions and types. |
70 |
| - |
71 |
| -## Differential Privacy |
72 |
| -For questions, documentation and examples of ZetaSQLs implementation of |
73 |
| -Differential Privacy, please check out |
74 |
| -(https://github.com/google/differential-privacy). |
75 |
| - |
76 |
| -## Versions |
77 |
| - |
78 |
| -ZetaSQL makes no guarantees regarding compatibility between releases. |
79 |
| -Breaking changes may be made at any time. Our releases are numbered based |
80 |
| -on the date of the commit the release is cut from. The number format is |
81 |
| -YYYY.MM.n, where YYYY is the year, MM is the two digit month, and n is a |
82 |
| -sequence number within the time period. |
| 1 | +## ZetaSQL Formatter |
| 2 | + |
| 3 | +[](https://github.com/Matts966/zetasql-formatter/actions?query=branch%main+workflow%3ABuild+) |
| 4 | + |
| 5 | +<p align="center"> |
| 6 | + <img src="./docs/changes.png"> |
| 7 | +</p> |
| 8 | + |
| 9 | +This repository is forked from [google/zetasql](https://github.com/google/zetasql) and provides SQL formatter with preserved comments. This formatter can be applied to mainly BigQuery and SpanSQL. |
| 10 | + |
| 11 | +## Quick Start |
| 12 | + |
| 13 | +```bash |
| 14 | +# To install for MacOSX |
| 15 | +wget https://github.com/Matts966/zetasql-formatter/releases/latest/download/zetasql-formatter_darwin_amd64.zip \ |
| 16 | + && sudo unzip zetasql-formatter_darwin_amd64.zip -d /usr/local/bin |
| 17 | +``` |
| 18 | + |
| 19 | +```bash |
| 20 | +# To install for Linux |
| 21 | +wget https://github.com/Matts966/zetasql-formatter/releases/latest/download/zetasql-formatter_linux_x86_64.zip \ |
| 22 | + && sudo unzip zetasql-formatter_linux_x86_64.zip -d /usr/local/bin |
| 23 | +``` |
| 24 | + |
| 25 | +```bash |
| 26 | +# To apply formatter for files |
| 27 | +$ zetasql-formatter [files and directories] |
| 28 | + |
| 29 | +# Format stdin |
| 30 | +$ echo "select * from test" | zetasql-formatter |
| 31 | +SELECT |
| 32 | + * |
| 33 | +FROM |
| 34 | + test; |
| 35 | + |
| 36 | +$ zetasql-formatter |
| 37 | +select * from ok; |
| 38 | +-- CTRL-D |
| 39 | +SELECT |
| 40 | + * |
| 41 | +FROM |
| 42 | + ok; |
| 43 | +-- CTRL-D |
| 44 | +``` |
| 45 | +
|
| 46 | +## Integration with [efm-langserver](https://github.com/mattn/efm-langserver) |
| 47 | +
|
| 48 | +- Install efm-langserver |
| 49 | +- Locate [`config.yaml`](https://github.com/mattn/efm-langserver#example-for-configyaml) like below |
| 50 | +
|
| 51 | +```yaml |
| 52 | +version: 2 |
| 53 | +tools: |
| 54 | + zetasql-formatter: &zetasql-formatter |
| 55 | + format-command: zetasql-formatter |
| 56 | + format-stdin: true |
| 57 | +languages: |
| 58 | + sql: |
| 59 | + - <<: *zetasql-formatter |
| 60 | + sql-bigquery: |
| 61 | + - <<: *zetasql-formatter |
| 62 | +``` |
83 | 63 |
|
84 | 64 | ## License
|
85 | 65 |
|
86 | 66 | [Apache License 2.0](LICENSE)
|
87 | 67 |
|
88 |
| -## Support Disclaimer |
89 |
| -This is not an officially supported Google product. |
| 68 | +## Sponsors |
| 69 | +
|
| 70 | +The development of this formatter is sponsored by the Japan Data Science Consortium. |
0 commit comments