Skip to content

Commit f771013

Browse files
committed
major overhaul for ADQL 2.1 from 2023-12-15
1 parent 3dba881 commit f771013

18 files changed

+342
-237
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 0.7.0 (XXXX-XX-XX)
2+
3+
major overhaul for ADQL 2.1 recommendation 2023-12-15
4+
- COOSYS is not required for the geometry constructors
5+
- the geometry constructors return the correct datatype (doube precission[])
6+
and correct units (degrees)
7+
- drop the maintenance/support for the translation from ADQL to MySQL.
8+
- fix `BOX` constructor
9+
- new requirements for the `pg_sphere` and postgreSQL
10+
- ...
11+
112
## 0.6.1 (2022-11-17)
213

314
- fixed the `ORDER BY` clause for the dot-separated column references

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ lib/queryparser/postgresql/%.py: src/queryparser/postgresql/%.py
7070

7171
lib/queryparser/testing: \
7272
lib/queryparser/testing/__init__.py \
73+
lib/queryparser/testing/utils.py \
7374
lib/queryparser/testing/tests.yaml \
7475
lib/queryparser/testing/test_adql.py \
7576
lib/queryparser/testing/test_mysql.py \

README.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
queryparser
22
===========
33

4-
**Tool for parsing and processing of MySQL/PostgreSQL and translation of
4+
**Tool for parsing and processing of (MySQL\*)/PostgreSQL and translation of
55
ADQL SELECT-like queries**
66

77
Designed to be used in conjunction with [django-daiquri](https://github.com/django-daiquiri/daiquiri)
88
as a query processing backend but it can be easily used as a stand-alone tool
99
or integrated into another project.
1010

11+
**\*NOTE: Since version 0.7.0, MySQL is not activelly supported/maintained anymore.**
12+
1113

1214
[![pytest Workflow Status](https://github.com/aipescience/queryparser/actions/workflows/pytest.yml/badge.svg)](https://github.com/aipescience/queryparser/actions/workflows/pytest.yml)
1315
[![Coverage Status](https://coveralls.io/repos/aipescience/queryparser/badge.svg?branch=master&service=github)](https://coveralls.io/github/aipescience/queryparser?branch=master)
@@ -54,9 +56,20 @@ and a `lib` directory will be created. After that, run
5456
to install the generated parser in your virtual environment.
5557

5658

59+
Additional requirements
60+
-----------------------
61+
The queryparser assumes that the PostgreSQL database has the extension
62+
[pg_sphere](https://github.com/kimakan/pgsphere/tree/aiprdbms16) installed. Although the `pg_sphere` is not required for the
63+
python module, the PostgreSQL **queries will not run** without that extension
64+
installed on the database.
65+
66+
5767
Parsing MySQL and PostgreSQL
5868
----------------------------
5969

70+
**Since version 0.7, MySQL part of the parser is not maintained anymore.
71+
Thus, the MySQL related functionality cannot be guaranteed!**
72+
6073
Parsing and processing of MySQL queries can be done by creating an instance
6174
of the `MySQLQueryProcessor` class
6275

@@ -110,13 +123,12 @@ the `ADQLQueryTranslator` class
110123
and calling
111124

112125
```python
113-
adt.to_mysql()
126+
adt.to_postgresql()
114127
```
115128

116129
which returns a translated string representing a valid MySQL query if
117-
the ADQL query had no errors. The MySQL query can then be parsed with the
118-
`MySQLQueryProcessor` in the same way as shown above.
119-
130+
the ADQL query had no errors. The PostgreSQL query can then be parsed with the
131+
`PostgreSQLQueryProcessor` in the same way as shown above.
120132

121133
Testing
122134
-------

docs/dev-notes.md

-69
This file was deleted.

generate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import subprocess
77
import re
88

9-
ANTLR_JAR = 'antlr-4.11.1-complete.jar'
9+
ANTLR_JAR = 'antlr-4.13.1-complete.jar'
1010
ANTLR_DIRS = ('.', '/usr/local/lib/', '/usr/local/bin/')
1111

1212
QUERYPARSER_SRC = 'src/queryparser/'

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
antlr4-python3-runtime==4.11.1
1+
antlr4-python3-runtime==4.13.1
22
pytest~=6.2.5
33
PyYAML~=6.0

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
version=metadata['version'],
2222
author=metadata['author'],
2323
author_email=metadata['email'],
24-
maintainer=metadata['author'],
25-
maintainer_email=metadata['email'],
24+
maintainer=metadata['maintainer'],
25+
maintainer_email=metadata['maintainer_email'],
2626
license=metadata['license'],
2727
url='https://github.com/aipescience/queryparser',
2828
description=u'Parses PostgreSQL/MySQL and translates ADQL to ' +\

src/queryparser/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
__title__ = 'queryparser'
2-
__version__ = '0.6.1'
2+
__version__ = '0.7.0'
33
__author__ = 'Gal Matijevic'
44
__email__ = '[email protected]'
5+
__maintainer__ = 'Kirill Makan'
6+
__maintainer_email__ = '[email protected]'
57
__license__ = 'Apache-2.0'
6-
__copyright__ = 'Copyright 2016-2022 Leibniz Institute for Astrophysics' +\
8+
__copyright__ = 'Copyright 2016-2024 Leibniz Institute for Astrophysics' +\
79
'Potsdam (AIP)'
810

911
VERSION = __version__

src/queryparser/adql/ADQLParser.g4

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ box:
2525
RPAREN ;
2626
catalog_name: ID ;
2727
centroid: CENTROID LPAREN geometry_value_expression RPAREN ;
28-
//character_representation: nonquote_character ;// | SQ SQ ;
28+
// character_representation: nonquote_character ;// | SQ SQ ;
2929
char_function: LOWER LPAREN character_string_literal RPAREN ;
3030
character_string_literal: CSL ; //SQ ( SL )* SQ ; //SQ ( character_representation )* SQ ;
3131
character_value_expression:
3232
character_value_expression concatenation_operator ( value_expression_primary | string_value_function )
3333
| value_expression_primary
3434
| string_value_function ;
35-
circle: CIRCLE LPAREN ( coord_sys COMMA )? coordinates COMMA radius RPAREN ;
35+
circle: CIRCLE LPAREN (( coord_sys COMMA )? circle_center ) COMMA radius RPAREN ;
36+
circle_center: coordinates | coord_value ;
3637
column_name: identifier ;
3738
column_name_list: column_name ( COMMA column_name )* ;
3839
column_reference: ( qualifier DOT )? column_name ;
@@ -41,7 +42,7 @@ comparison_predicate: value_expression comp_op value_expression ;
4142
concatenation_operator: CONCAT ;
4243
contains: CONTAINS LPAREN geometry_value_expression COMMA geometry_value_expression RPAREN ;
4344
coord_sys: string_value_expression ;
44-
coord_value: point | column_reference | centroid ;
45+
coord_value: point_value | column_reference ;
4546
coord1: COORD1 LPAREN coord_value RPAREN ;
4647
coord2: COORD2 LPAREN coord_value RPAREN ;
4748
coordinate1: numeric_value_expression ;
@@ -68,7 +69,7 @@ factor: ( sign )? numeric_primary ;
6869
from_clause: FROM table_reference ( COMMA table_reference )* ;
6970
general_literal: character_string_literal ;
7071
general_set_function: set_function_type LPAREN ( set_quantifier )? value_expression RPAREN ;
71-
geometry_value_expression: box | centroid | circle | point | polygon | region | user_defined_function ;
72+
geometry_value_expression: box | circle | centroid | point | polygon | region | user_defined_function ;
7273
group_by_clause: GROUP BY grouping_column_reference_list ;
7374
grouping_column_reference: column_reference ;
7475
grouping_column_reference_list: grouping_column_reference ( COMMA grouping_column_reference )* ;
@@ -129,6 +130,7 @@ ordering_specification: ASC | DESC ;
129130
outer_join_type: LEFT | RIGHT | FULL ;
130131
pattern: character_value_expression ;
131132
point: POINT LPAREN ( coord_sys COMMA )? coordinates RPAREN ;
133+
point_value: point | centroid | user_defined_function ;
132134
polygon: POLYGON LPAREN
133135
( coord_sys COMMA )?
134136
coordinates COMMA

0 commit comments

Comments
 (0)