queryparser-python3 0.7.2__tar.gz → 0.7.4__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.
- {queryparser_python3-0.7.2/lib/queryparser_python3.egg-info → queryparser_python3-0.7.4}/PKG-INFO +6 -2
- queryparser_python3-0.7.4/lib/queryparser/__init__.py +1 -0
- queryparser_python3-0.7.4/lib/queryparser/adql/adqlprocessor.py +23 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/adql/adqltranslator.py +8 -11
- queryparser_python3-0.7.4/lib/queryparser/postgresql/PostgreSQLLexer.py +1247 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/postgresql/PostgreSQLParser.py +1684 -1522
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/postgresql/PostgreSQLParserListener.py +18 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4/lib/queryparser_python3.egg-info}/PKG-INFO +6 -2
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser_python3.egg-info/SOURCES.txt +1 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser_python3.egg-info/requires.txt +5 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/pyproject.toml +21 -20
- queryparser_python3-0.7.2/lib/queryparser/__init__.py +0 -1
- queryparser_python3-0.7.2/lib/queryparser/postgresql/PostgreSQLLexer.py +0 -1237
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/LICENSE +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/README.md +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/adql/ADQLLexer.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/adql/ADQLParser.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/adql/ADQLParserListener.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/adql/ADQLParserVisitor.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/adql/__init__.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/common/__init__.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/common/common.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/exceptions/__init__.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/mysql/MySQLLexer.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/mysql/MySQLParser.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/mysql/MySQLParserListener.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/mysql/__init__.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/mysql/mysqllisteners.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/mysql/mysqlprocessor.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/postgresql/__init__.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/postgresql/postgresqllisteners.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/postgresql/postgresqlprocessor.py +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser_python3.egg-info/dependency_links.txt +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser_python3.egg-info/top_level.txt +0 -0
- {queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/setup.cfg +0 -0
{queryparser_python3-0.7.2/lib/queryparser_python3.egg-info → queryparser_python3-0.7.4}/PKG-INFO
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: queryparser-python3
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.4
|
|
4
4
|
Summary: Package for parsing PostgreSQL/MySQL and translating ADQL to PostgreSQL/MySQL.
|
|
5
5
|
Author-email: Gal Matijevic <gmatijevic@aip.de>
|
|
6
|
-
Maintainer-email: Kirill Makan <kmakan@aip.de>
|
|
6
|
+
Maintainer-email: Kirill Makan <kmakan@aip.de>, Simeon Reusch <sreusch@aip.de>
|
|
7
7
|
License: Apache-2.0
|
|
8
8
|
Project-URL: Repository, https://github.com/aipescience/queryparser.git
|
|
9
9
|
Project-URL: Issues, https://github.com/aipescience/queryparser/issues
|
|
@@ -24,6 +24,10 @@ Requires-Dist: antlr4-python3-runtime==4.13.1
|
|
|
24
24
|
Provides-Extra: test
|
|
25
25
|
Requires-Dist: pytest~=8.2.0; extra == "test"
|
|
26
26
|
Requires-Dist: PyYAML~=6.0; extra == "test"
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: build; extra == "dev"
|
|
29
|
+
Requires-Dist: ruff; extra == "dev"
|
|
30
|
+
Requires-Dist: twine; extra == "dev"
|
|
27
31
|
Dynamic: license-file
|
|
28
32
|
|
|
29
33
|
queryparser
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.7.4'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
ADQL processor. Its task is to check if a query has any syntax errors and
|
|
4
|
+
to extract all accessed columns as well as keywords and functions being
|
|
5
|
+
used in a query.
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import absolute_import, print_function
|
|
10
|
+
|
|
11
|
+
__all__ = ["ADQLQueryProcessor"]
|
|
12
|
+
|
|
13
|
+
from ..common import SQLQueryProcessor
|
|
14
|
+
from .ADQLLexer import ADQLLexer
|
|
15
|
+
from .ADQLParser import ADQLParser
|
|
16
|
+
from .ADQLParserListener import ADQLParserListener
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ADQLQueryProcessor(SQLQueryProcessor):
|
|
20
|
+
def __init__(self, query=None):
|
|
21
|
+
super().__init__(
|
|
22
|
+
ADQLLexer, ADQLParser, ADQLParserListener, '"', query
|
|
23
|
+
)
|
{queryparser_python3-0.7.2 → queryparser_python3-0.7.4}/lib/queryparser/adql/adqltranslator.py
RENAMED
|
@@ -4,6 +4,7 @@ from __future__ import absolute_import
|
|
|
4
4
|
|
|
5
5
|
import antlr4
|
|
6
6
|
from antlr4.error.ErrorListener import ErrorListener
|
|
7
|
+
import re
|
|
7
8
|
|
|
8
9
|
from .ADQLLexer import ADQLLexer
|
|
9
10
|
from .ADQLParser import ADQLParser
|
|
@@ -205,7 +206,7 @@ class ADQLGeometryTranslationVisitor(ADQLParserVisitor):
|
|
|
205
206
|
if derived_column is not None:
|
|
206
207
|
ctx_text = f"spoint_to_array_deg({ctx_text})"
|
|
207
208
|
if not (any([isinstance(child, ADQLParser.As_clauseContext) for child in derived_column.children])):
|
|
208
|
-
ctx_text = f"{ctx_text} AS
|
|
209
|
+
ctx_text = f"{ctx_text} AS adql_point"
|
|
209
210
|
else:
|
|
210
211
|
ctx_text = ''
|
|
211
212
|
|
|
@@ -297,7 +298,7 @@ class ADQLGeometryTranslationVisitor(ADQLParserVisitor):
|
|
|
297
298
|
if derived_column is not None:
|
|
298
299
|
ctx_text = f"spoly_to_array_deg({ctx_text})"
|
|
299
300
|
if not (any([isinstance(child, ADQLParser.As_clauseContext) for child in derived_column.children])):
|
|
300
|
-
ctx_text = f"{ctx_text} AS
|
|
301
|
+
ctx_text = f"{ctx_text} AS adql_polygon"
|
|
301
302
|
else:
|
|
302
303
|
ctx_text = ''
|
|
303
304
|
|
|
@@ -470,15 +471,6 @@ class ADQLFunctionsTranslationVisitor(ADQLParserVisitor):
|
|
|
470
471
|
_remove_children(ctx)
|
|
471
472
|
self.contexts[ctx] = ctx_text
|
|
472
473
|
|
|
473
|
-
def visitMath_function(self, ctx):
|
|
474
|
-
ctx_text = ctx.getText()
|
|
475
|
-
if self.output_sql == 'postgresql' and ctx_text[:5].lower() == 'log10':
|
|
476
|
-
_remove_children(ctx)
|
|
477
|
-
self.contexts[ctx] = 'LOG' + ctx_text[5:]
|
|
478
|
-
elif self.output_sql == 'postgresql' and ctx_text[:3].lower() == 'log':
|
|
479
|
-
_remove_children(ctx)
|
|
480
|
-
self.contexts[ctx] = 'LN' + ctx_text[3:]
|
|
481
|
-
|
|
482
474
|
|
|
483
475
|
class SelectQueryListener(ADQLParserListener):
|
|
484
476
|
def __init__(self):
|
|
@@ -691,4 +683,9 @@ class ADQLQueryTranslator(object):
|
|
|
691
683
|
translator_visitor.visit(self.tree)
|
|
692
684
|
|
|
693
685
|
translated_query = self.translate(translator_visitor)
|
|
686
|
+
|
|
687
|
+
# Translate LOG10 to LOG and LOG to LN. It's not the most elegant solution but it works.
|
|
688
|
+
translated_query = re.sub(r'(?<=[\+\-\*/\(\s,])log\(', 'LN(', translated_query, flags=re.IGNORECASE)
|
|
689
|
+
translated_query = re.sub(r'(?<=[\+\-\*/\(\s,])log10\(', 'LOG(', translated_query, flags=re.IGNORECASE)
|
|
690
|
+
|
|
694
691
|
return translated_query
|