vertica-sqlglot-dialect 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Luis de la Torre
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,324 @@
1
+ Metadata-Version: 2.4
2
+ Name: vertica-sqlglot-dialect
3
+ Version: 0.1.0
4
+ Summary: Vertica SQL dialect implementation for sqlglot
5
+ Author-email: Luis de la Torre <luisdelatorre012@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/luisdelatorre/vertica-sqlglot-dialect
8
+ Project-URL: Repository, https://github.com/luisdelatorre/vertica-sqlglot-dialect
9
+ Project-URL: Issues, https://github.com/luisdelatorre/vertica-sqlglot-dialect/issues
10
+ Project-URL: Documentation, https://github.com/luisdelatorre/vertica-sqlglot-dialect#readme
11
+ Keywords: sql,vertica,sqlglot,dialect,parser,sql-parser
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Database
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: sqlglot>=26.0.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
26
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
27
+ Requires-Dist: black>=22.0.0; extra == "dev"
28
+ Requires-Dist: isort>=5.0.0; extra == "dev"
29
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # SQLGlot Vertica Dialect
33
+
34
+ A comprehensive Vertica dialect implementation for [SQLGlot](https://github.com/tobymao/sqlglot), a Python SQL parser and transpiler.
35
+
36
+ ## Features
37
+
38
+ This Vertica dialect provides full-featured support for Vertica SQL syntax, including:
39
+
40
+ ### Core Functionality
41
+ - Complete SQL parsing and generation
42
+ - Vertica-specific data types (TIMESTAMPTZ, BINARY, etc.)
43
+ - Identifier quoting with double quotes
44
+ - Heredoc string support
45
+
46
+ ### Date and Time Functions
47
+ - `DATEADD(unit, interval, timestamp)` - Add intervals to dates/timestamps
48
+ - `DATEDIFF(unit, start_date, end_date)` - Calculate date differences
49
+ - `DATE_TRUNC(unit, timestamp)` - Truncate timestamps to specified unit
50
+ - `TO_CHAR(timestamp, format)` - Format timestamps as strings
51
+ - `TO_DATE(string, format)` - Parse strings as dates
52
+ - `TO_TIMESTAMP(string, format)` - Parse strings as timestamps
53
+ - `CURRENT_DATE`, `CURRENT_TIME`, `CURRENT_TIMESTAMP`, `NOW()`
54
+
55
+ ### String Functions
56
+ - `ILIKE` / `NOT ILIKE` - Case-insensitive pattern matching
57
+ - `LIKE` / `NOT LIKE` - Case-sensitive pattern matching
58
+ - `SUBSTRING(string, start, length)` - Extract substrings
59
+ - `TRIM()` - Remove whitespace
60
+ - Standard string functions (`LENGTH`, `UPPER`, `LOWER`, etc.)
61
+
62
+ ### Mathematical Functions
63
+ - `RANDOM()` - Generate random numbers
64
+ - Standard math functions (`ABS`, `CEIL`, `FLOOR`, `ROUND`, `SQRT`, `POWER`)
65
+
66
+ ### Hash Functions
67
+ - `MD5(string)` - MD5 hash
68
+ - `SHA1(string)` - SHA1 hash
69
+
70
+ ### Array Support
71
+ - `ARRAY[...]` syntax for array literals
72
+ - Array operations and functions
73
+
74
+ ### Window Functions
75
+ - Complete support for window functions
76
+ - `ROW_NUMBER()`, `RANK()`, `LAG()`, `LEAD()`, etc.
77
+ - `OVER` clauses with `PARTITION BY` and `ORDER BY`
78
+
79
+ ### Advanced Features
80
+ - Common Table Expressions (CTEs)
81
+ - Subqueries and EXISTS clauses
82
+ - All JOIN types (INNER, LEFT, RIGHT, FULL OUTER, CROSS)
83
+ - Aggregate functions with GROUP BY and HAVING
84
+ - CASE WHEN expressions
85
+ - Complex data types and constraints
86
+
87
+ ## Installation
88
+
89
+ ```bash
90
+ pip install sqlglot-vertica
91
+ ```
92
+
93
+ For development:
94
+ ```bash
95
+ pip install sqlglot-vertica[dev]
96
+ ```
97
+
98
+ ## Usage
99
+
100
+ ### Basic Usage
101
+
102
+ ```python
103
+ from sqlglot import transpile
104
+ from sqlglot_vertica.vertica import Vertica
105
+
106
+ # Parse and generate Vertica SQL
107
+ sql = "SELECT DATEADD(DAY, 1, CURRENT_DATE)"
108
+ parsed = Vertica.parse(sql)[0]
109
+ generated = Vertica().generate(parsed)
110
+ print(generated) # SELECT DATEADD(DAY, 1, CURRENT_DATE)
111
+
112
+ # Transpile from other dialects to Vertica
113
+ postgres_sql = "SELECT NOW()"
114
+ vertica_sql = transpile(postgres_sql, read='postgres', write='vertica')[0]
115
+ print(vertica_sql) # SELECT CURRENT_TIMESTAMP
116
+ ```
117
+
118
+ ### Advanced Examples
119
+
120
+ ```python
121
+ # Complex query with CTEs and window functions
122
+ complex_query = """
123
+ WITH sales_data AS (
124
+ SELECT
125
+ region,
126
+ DATE_TRUNC(MONTH, sale_date) AS month,
127
+ SUM(amount) AS total_sales,
128
+ ROW_NUMBER() OVER (PARTITION BY region ORDER BY SUM(amount) DESC) AS rank
129
+ FROM sales
130
+ WHERE sale_date >= CURRENT_DATE - INTERVAL '1' YEAR
131
+ GROUP BY region, DATE_TRUNC(MONTH, sale_date)
132
+ )
133
+ SELECT
134
+ region,
135
+ month,
136
+ total_sales,
137
+ CASE
138
+ WHEN rank = 1 THEN 'Top Month'
139
+ ELSE 'Other'
140
+ END AS category
141
+ FROM sales_data
142
+ WHERE rank <= 5
143
+ ORDER BY region, total_sales DESC
144
+ """
145
+
146
+ parsed = Vertica.parse(complex_query)[0]
147
+ print(parsed)
148
+ ```
149
+
150
+ ### Vertica-Specific Features
151
+
152
+ ```python
153
+ # Date functions
154
+ sql = "SELECT DATEDIFF(DAY, '2023-01-01', '2023-12-31')"
155
+ result = Vertica().generate(Vertica.parse(sql)[0])
156
+
157
+ # Array operations
158
+ sql = "SELECT ARRAY[1, 2, 3, 4, 5]"
159
+ result = Vertica().generate(Vertica.parse(sql)[0])
160
+
161
+ # Case-insensitive matching
162
+ sql = "SELECT * FROM users WHERE name ILIKE '%john%'"
163
+ result = Vertica().generate(Vertica.parse(sql)[0])
164
+
165
+ # Timestamp with timezone
166
+ sql = "CREATE TABLE events (id INTEGER, created_at TIMESTAMPTZ)"
167
+ result = Vertica().generate(Vertica.parse(sql)[0])
168
+ ```
169
+
170
+ ## Development
171
+
172
+ ### Setup Development Environment
173
+
174
+ ```bash
175
+ git clone https://github.com/luisdelatorre/sqlglot-vertica.git
176
+ cd sqlglot-vertica
177
+ python -m venv venv
178
+ source venv/bin/activate # On Windows: venv\Scripts\activate
179
+ pip install -e .[dev]
180
+ ```
181
+
182
+ ### Running Tests
183
+
184
+ ```bash
185
+ # Run all tests
186
+ pytest
187
+
188
+ # Run with coverage
189
+ pytest --cov=sqlglot_vertica
190
+
191
+ # Run specific test file
192
+ pytest tests/test_vertica.py
193
+
194
+ # Run specific test method
195
+ pytest tests/test_vertica.py::TestVertica::test_vertica_date_functions
196
+ ```
197
+
198
+ ### Code Quality
199
+
200
+ ```bash
201
+ # Format code
202
+ black sqlglot_vertica tests
203
+
204
+ # Sort imports
205
+ isort sqlglot_vertica tests
206
+
207
+ # Type checking
208
+ mypy sqlglot_vertica
209
+ ```
210
+
211
+ ## Testing
212
+
213
+ The dialect includes comprehensive tests covering:
214
+
215
+ - Basic SQL operations (SELECT, INSERT, UPDATE, DELETE)
216
+ - All supported data types
217
+ - Date and time functions
218
+ - String and mathematical functions
219
+ - Window functions and aggregations
220
+ - JOIN operations
221
+ - Subqueries and CTEs
222
+ - Complex query patterns
223
+ - Transpilation from other dialects
224
+ - Edge cases and error conditions
225
+
226
+ The test suite follows the same patterns as other SQLGlot dialect tests, ensuring consistency and reliability.
227
+
228
+ ## Compatibility
229
+
230
+ - **Python**: 3.8+
231
+ - **SQLGlot**: 26.0.0+
232
+ - **Vertica**: Compatible with Vertica SQL syntax
233
+
234
+ ## Contributing
235
+
236
+ Contributions are welcome! Please:
237
+
238
+ 1. Fork the repository
239
+ 2. Create a feature branch
240
+ 3. Add tests for new functionality
241
+ 4. Ensure all tests pass
242
+ 5. Submit a pull request
243
+
244
+ ## License
245
+
246
+ MIT License - see LICENSE file for details.
247
+
248
+ ## 📁 Examples
249
+
250
+ This package includes comprehensive examples demonstrating various use cases. See the `examples/` directory for detailed demonstrations.
251
+
252
+ ### 🚀 Quick Start Examples
253
+ ```bash
254
+ # Run basic usage examples
255
+ python examples/basic_usage.py
256
+
257
+ # Run advanced transformation examples
258
+ python examples/advanced_transformations.py
259
+
260
+ # Run data migration examples
261
+ python examples/data_migration.py
262
+
263
+ # Run performance analysis examples
264
+ python examples/performance_analysis.py
265
+
266
+ # Run comprehensive demonstration
267
+ python examples/run_all_examples.py
268
+ ```
269
+
270
+ ### 📋 Example Categories
271
+
272
+ 1. **`examples/basic_usage.py`** - Fundamental operations
273
+ - Basic SQL parsing with Vertica syntax
274
+ - Cross-dialect transpilation
275
+ - AST inspection and manipulation
276
+ - Error handling for unsupported features
277
+
278
+ 2. **`examples/advanced_transformations.py`** - AST manipulation
279
+ - Custom query transformations
280
+ - Query optimization using SQLGlot
281
+ - Schema analysis and lineage tracking
282
+ - Advanced AST rewriting patterns
283
+
284
+ 3. **`examples/data_migration.py`** - Database migration
285
+ - DDL conversion between databases
286
+ - Function migration (date/time, string, hash)
287
+ - Data type mapping
288
+ - Batch script processing and validation
289
+
290
+ 4. **`examples/performance_analysis.py`** - Query optimization
291
+ - Query complexity analysis
292
+ - Anti-pattern detection
293
+ - Index recommendation
294
+ - Performance benchmarking
295
+
296
+ ### Common Use Cases
297
+
298
+ ```python
299
+ # Database Migration
300
+ from sqlglot import transpile
301
+ from sqlglot_vertica.vertica import Vertica
302
+
303
+ vertica_sql = "SELECT DATEDIFF('day', hire_date, CURRENT_DATE) FROM employees"
304
+ postgres_sql = transpile(vertica_sql, read=Vertica, write="postgres")[0]
305
+
306
+ # Query Analysis
307
+ from sqlglot import parse_one
308
+ ast = parse_one("SELECT MD5(email) FROM users WHERE active = true", read=Vertica)
309
+ tables = [table.name for table in ast.find_all(exp.Table)]
310
+ functions = [func.sql() for func in ast.find_all(exp.Func)]
311
+
312
+ # Error Handling
313
+ from sqlglot.errors import ParseError, UnsupportedError
314
+ try:
315
+ parse_one("SELECT $$invalid syntax$$", read=Vertica)
316
+ except ParseError as e:
317
+ print(f"Parse error: {e}")
318
+ ```
319
+
320
+ ## Acknowledgments
321
+
322
+ - Built on top of the excellent [SQLGlot](https://github.com/tobymao/sqlglot) library
323
+ - Inspired by existing SQLGlot dialect implementations, particularly Postgres
324
+ - Designed to be compatible with Vertica SQL syntax and semantics
@@ -0,0 +1,293 @@
1
+ # SQLGlot Vertica Dialect
2
+
3
+ A comprehensive Vertica dialect implementation for [SQLGlot](https://github.com/tobymao/sqlglot), a Python SQL parser and transpiler.
4
+
5
+ ## Features
6
+
7
+ This Vertica dialect provides full-featured support for Vertica SQL syntax, including:
8
+
9
+ ### Core Functionality
10
+ - Complete SQL parsing and generation
11
+ - Vertica-specific data types (TIMESTAMPTZ, BINARY, etc.)
12
+ - Identifier quoting with double quotes
13
+ - Heredoc string support
14
+
15
+ ### Date and Time Functions
16
+ - `DATEADD(unit, interval, timestamp)` - Add intervals to dates/timestamps
17
+ - `DATEDIFF(unit, start_date, end_date)` - Calculate date differences
18
+ - `DATE_TRUNC(unit, timestamp)` - Truncate timestamps to specified unit
19
+ - `TO_CHAR(timestamp, format)` - Format timestamps as strings
20
+ - `TO_DATE(string, format)` - Parse strings as dates
21
+ - `TO_TIMESTAMP(string, format)` - Parse strings as timestamps
22
+ - `CURRENT_DATE`, `CURRENT_TIME`, `CURRENT_TIMESTAMP`, `NOW()`
23
+
24
+ ### String Functions
25
+ - `ILIKE` / `NOT ILIKE` - Case-insensitive pattern matching
26
+ - `LIKE` / `NOT LIKE` - Case-sensitive pattern matching
27
+ - `SUBSTRING(string, start, length)` - Extract substrings
28
+ - `TRIM()` - Remove whitespace
29
+ - Standard string functions (`LENGTH`, `UPPER`, `LOWER`, etc.)
30
+
31
+ ### Mathematical Functions
32
+ - `RANDOM()` - Generate random numbers
33
+ - Standard math functions (`ABS`, `CEIL`, `FLOOR`, `ROUND`, `SQRT`, `POWER`)
34
+
35
+ ### Hash Functions
36
+ - `MD5(string)` - MD5 hash
37
+ - `SHA1(string)` - SHA1 hash
38
+
39
+ ### Array Support
40
+ - `ARRAY[...]` syntax for array literals
41
+ - Array operations and functions
42
+
43
+ ### Window Functions
44
+ - Complete support for window functions
45
+ - `ROW_NUMBER()`, `RANK()`, `LAG()`, `LEAD()`, etc.
46
+ - `OVER` clauses with `PARTITION BY` and `ORDER BY`
47
+
48
+ ### Advanced Features
49
+ - Common Table Expressions (CTEs)
50
+ - Subqueries and EXISTS clauses
51
+ - All JOIN types (INNER, LEFT, RIGHT, FULL OUTER, CROSS)
52
+ - Aggregate functions with GROUP BY and HAVING
53
+ - CASE WHEN expressions
54
+ - Complex data types and constraints
55
+
56
+ ## Installation
57
+
58
+ ```bash
59
+ pip install sqlglot-vertica
60
+ ```
61
+
62
+ For development:
63
+ ```bash
64
+ pip install sqlglot-vertica[dev]
65
+ ```
66
+
67
+ ## Usage
68
+
69
+ ### Basic Usage
70
+
71
+ ```python
72
+ from sqlglot import transpile
73
+ from sqlglot_vertica.vertica import Vertica
74
+
75
+ # Parse and generate Vertica SQL
76
+ sql = "SELECT DATEADD(DAY, 1, CURRENT_DATE)"
77
+ parsed = Vertica.parse(sql)[0]
78
+ generated = Vertica().generate(parsed)
79
+ print(generated) # SELECT DATEADD(DAY, 1, CURRENT_DATE)
80
+
81
+ # Transpile from other dialects to Vertica
82
+ postgres_sql = "SELECT NOW()"
83
+ vertica_sql = transpile(postgres_sql, read='postgres', write='vertica')[0]
84
+ print(vertica_sql) # SELECT CURRENT_TIMESTAMP
85
+ ```
86
+
87
+ ### Advanced Examples
88
+
89
+ ```python
90
+ # Complex query with CTEs and window functions
91
+ complex_query = """
92
+ WITH sales_data AS (
93
+ SELECT
94
+ region,
95
+ DATE_TRUNC(MONTH, sale_date) AS month,
96
+ SUM(amount) AS total_sales,
97
+ ROW_NUMBER() OVER (PARTITION BY region ORDER BY SUM(amount) DESC) AS rank
98
+ FROM sales
99
+ WHERE sale_date >= CURRENT_DATE - INTERVAL '1' YEAR
100
+ GROUP BY region, DATE_TRUNC(MONTH, sale_date)
101
+ )
102
+ SELECT
103
+ region,
104
+ month,
105
+ total_sales,
106
+ CASE
107
+ WHEN rank = 1 THEN 'Top Month'
108
+ ELSE 'Other'
109
+ END AS category
110
+ FROM sales_data
111
+ WHERE rank <= 5
112
+ ORDER BY region, total_sales DESC
113
+ """
114
+
115
+ parsed = Vertica.parse(complex_query)[0]
116
+ print(parsed)
117
+ ```
118
+
119
+ ### Vertica-Specific Features
120
+
121
+ ```python
122
+ # Date functions
123
+ sql = "SELECT DATEDIFF(DAY, '2023-01-01', '2023-12-31')"
124
+ result = Vertica().generate(Vertica.parse(sql)[0])
125
+
126
+ # Array operations
127
+ sql = "SELECT ARRAY[1, 2, 3, 4, 5]"
128
+ result = Vertica().generate(Vertica.parse(sql)[0])
129
+
130
+ # Case-insensitive matching
131
+ sql = "SELECT * FROM users WHERE name ILIKE '%john%'"
132
+ result = Vertica().generate(Vertica.parse(sql)[0])
133
+
134
+ # Timestamp with timezone
135
+ sql = "CREATE TABLE events (id INTEGER, created_at TIMESTAMPTZ)"
136
+ result = Vertica().generate(Vertica.parse(sql)[0])
137
+ ```
138
+
139
+ ## Development
140
+
141
+ ### Setup Development Environment
142
+
143
+ ```bash
144
+ git clone https://github.com/luisdelatorre/sqlglot-vertica.git
145
+ cd sqlglot-vertica
146
+ python -m venv venv
147
+ source venv/bin/activate # On Windows: venv\Scripts\activate
148
+ pip install -e .[dev]
149
+ ```
150
+
151
+ ### Running Tests
152
+
153
+ ```bash
154
+ # Run all tests
155
+ pytest
156
+
157
+ # Run with coverage
158
+ pytest --cov=sqlglot_vertica
159
+
160
+ # Run specific test file
161
+ pytest tests/test_vertica.py
162
+
163
+ # Run specific test method
164
+ pytest tests/test_vertica.py::TestVertica::test_vertica_date_functions
165
+ ```
166
+
167
+ ### Code Quality
168
+
169
+ ```bash
170
+ # Format code
171
+ black sqlglot_vertica tests
172
+
173
+ # Sort imports
174
+ isort sqlglot_vertica tests
175
+
176
+ # Type checking
177
+ mypy sqlglot_vertica
178
+ ```
179
+
180
+ ## Testing
181
+
182
+ The dialect includes comprehensive tests covering:
183
+
184
+ - Basic SQL operations (SELECT, INSERT, UPDATE, DELETE)
185
+ - All supported data types
186
+ - Date and time functions
187
+ - String and mathematical functions
188
+ - Window functions and aggregations
189
+ - JOIN operations
190
+ - Subqueries and CTEs
191
+ - Complex query patterns
192
+ - Transpilation from other dialects
193
+ - Edge cases and error conditions
194
+
195
+ The test suite follows the same patterns as other SQLGlot dialect tests, ensuring consistency and reliability.
196
+
197
+ ## Compatibility
198
+
199
+ - **Python**: 3.8+
200
+ - **SQLGlot**: 26.0.0+
201
+ - **Vertica**: Compatible with Vertica SQL syntax
202
+
203
+ ## Contributing
204
+
205
+ Contributions are welcome! Please:
206
+
207
+ 1. Fork the repository
208
+ 2. Create a feature branch
209
+ 3. Add tests for new functionality
210
+ 4. Ensure all tests pass
211
+ 5. Submit a pull request
212
+
213
+ ## License
214
+
215
+ MIT License - see LICENSE file for details.
216
+
217
+ ## 📁 Examples
218
+
219
+ This package includes comprehensive examples demonstrating various use cases. See the `examples/` directory for detailed demonstrations.
220
+
221
+ ### 🚀 Quick Start Examples
222
+ ```bash
223
+ # Run basic usage examples
224
+ python examples/basic_usage.py
225
+
226
+ # Run advanced transformation examples
227
+ python examples/advanced_transformations.py
228
+
229
+ # Run data migration examples
230
+ python examples/data_migration.py
231
+
232
+ # Run performance analysis examples
233
+ python examples/performance_analysis.py
234
+
235
+ # Run comprehensive demonstration
236
+ python examples/run_all_examples.py
237
+ ```
238
+
239
+ ### 📋 Example Categories
240
+
241
+ 1. **`examples/basic_usage.py`** - Fundamental operations
242
+ - Basic SQL parsing with Vertica syntax
243
+ - Cross-dialect transpilation
244
+ - AST inspection and manipulation
245
+ - Error handling for unsupported features
246
+
247
+ 2. **`examples/advanced_transformations.py`** - AST manipulation
248
+ - Custom query transformations
249
+ - Query optimization using SQLGlot
250
+ - Schema analysis and lineage tracking
251
+ - Advanced AST rewriting patterns
252
+
253
+ 3. **`examples/data_migration.py`** - Database migration
254
+ - DDL conversion between databases
255
+ - Function migration (date/time, string, hash)
256
+ - Data type mapping
257
+ - Batch script processing and validation
258
+
259
+ 4. **`examples/performance_analysis.py`** - Query optimization
260
+ - Query complexity analysis
261
+ - Anti-pattern detection
262
+ - Index recommendation
263
+ - Performance benchmarking
264
+
265
+ ### Common Use Cases
266
+
267
+ ```python
268
+ # Database Migration
269
+ from sqlglot import transpile
270
+ from sqlglot_vertica.vertica import Vertica
271
+
272
+ vertica_sql = "SELECT DATEDIFF('day', hire_date, CURRENT_DATE) FROM employees"
273
+ postgres_sql = transpile(vertica_sql, read=Vertica, write="postgres")[0]
274
+
275
+ # Query Analysis
276
+ from sqlglot import parse_one
277
+ ast = parse_one("SELECT MD5(email) FROM users WHERE active = true", read=Vertica)
278
+ tables = [table.name for table in ast.find_all(exp.Table)]
279
+ functions = [func.sql() for func in ast.find_all(exp.Func)]
280
+
281
+ # Error Handling
282
+ from sqlglot.errors import ParseError, UnsupportedError
283
+ try:
284
+ parse_one("SELECT $$invalid syntax$$", read=Vertica)
285
+ except ParseError as e:
286
+ print(f"Parse error: {e}")
287
+ ```
288
+
289
+ ## Acknowledgments
290
+
291
+ - Built on top of the excellent [SQLGlot](https://github.com/tobymao/sqlglot) library
292
+ - Inspired by existing SQLGlot dialect implementations, particularly Postgres
293
+ - Designed to be compatible with Vertica SQL syntax and semantics
@@ -0,0 +1,70 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "vertica-sqlglot-dialect"
7
+ version = "0.1.0"
8
+ description = "Vertica SQL dialect implementation for sqlglot"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ authors = [
12
+ {name = "Luis de la Torre", email = "luisdelatorre012@gmail.com"}
13
+ ]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Topic :: Database",
22
+ "Topic :: Software Development :: Libraries :: Python Modules",
23
+ ]
24
+ requires-python = ">=3.11"
25
+ dependencies = [
26
+ "sqlglot>=26.0.0",
27
+ ]
28
+ keywords = ["sql", "vertica", "sqlglot", "dialect", "parser", "sql-parser"]
29
+
30
+ [project.optional-dependencies]
31
+ dev = [
32
+ "pytest>=7.0.0",
33
+ "pytest-cov>=4.0.0",
34
+ "black>=22.0.0",
35
+ "isort>=5.0.0",
36
+ "mypy>=1.0.0",
37
+ ]
38
+
39
+ [project.urls]
40
+ Homepage = "https://github.com/luisdelatorre/vertica-sqlglot-dialect"
41
+ Repository = "https://github.com/luisdelatorre/vertica-sqlglot-dialect"
42
+ Issues = "https://github.com/luisdelatorre/vertica-sqlglot-dialect/issues"
43
+ Documentation = "https://github.com/luisdelatorre/vertica-sqlglot-dialect#readme"
44
+
45
+ [tool.setuptools.packages.find]
46
+ where = ["."]
47
+ include = ["sqlglot_vertica*"]
48
+
49
+ [tool.pytest.ini_options]
50
+ testpaths = ["tests"]
51
+ python_files = ["test_*.py"]
52
+ python_classes = ["Test*"]
53
+ python_functions = ["test_*"]
54
+
55
+ [tool.black]
56
+ line-length = 100
57
+ target-version = ['py311']
58
+
59
+ [tool.isort]
60
+ profile = "black"
61
+ line_length = 100
62
+
63
+ [tool.ruff]
64
+ target-version = "py311"
65
+
66
+ [tool.mypy]
67
+ python_version = "3.11"
68
+ warn_return_any = true
69
+ warn_unused_configs = true
70
+ disallow_untyped_defs = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+