Skip to content

Commit f320b66

Browse files
authored
Merge pull request #16 from aipescience/adql-2.1
update to the final ADQL 2.1
2 parents 18094a0 + 1eede62 commit f320b66

36 files changed

+568
-2488
lines changed

.github/workflows/pytest.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,32 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v3
1212

13-
- name: Set up Python 3.9
13+
- name: Set up Python 3.11
1414
uses: actions/setup-python@v2
1515
with:
16-
python-version: 3.9
16+
python-version: 3.11
1717

1818
- name: Install prerequisites
1919
run: |
2020
sudo apt update
2121
sudo apt install -y default-jre
2222
python -m pip install --upgrade pip
23-
23+
2424
- name: Build queryparser
2525
run: |
26-
wget http://www.antlr.org/download/antlr-4.11.1-complete.jar
26+
wget http://www.antlr.org/download/antlr-4.13.1-complete.jar
2727
make
28-
pip install -r requirements.txt -I -e .
28+
pip install -I -e .[test]
2929
pip install pytest-cov
3030
pip install coveralls
31-
31+
3232
- name: Run Tests
3333
run: |
3434
pytest lib/ --cov=queryparser
3535
coveralls --service=github
3636
env:
3737
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
39-
38+
4039
coveralls:
4140
name: Indicate completion to coveralls
4241
needs: build

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## 0.7.0 (2024-05-21)
2+
3+
major overhaul for ADQL 2.1 recommendation 2023-12-15
4+
- COOSYS is not required for the geometry constructors anymore, since it's deprecated
5+
- the geometry constructors return the correct datatype (double precision[])
6+
and correct units (degrees)
7+
- droped the maintenance/support for the translation from ADQL to MySQL.
8+
- bumped the version of `antlr4-python3-runtime` to 4.13.1
9+
- fixed `BOX` constructor, although it's deprecated in ADQL 2.1
10+
- fixed `CONTAINS` for the case `0=CONTAINS()`
11+
- fixed `INTERSECTS` for the case `0=INTERSECTS()`
12+
- new requirements for the `pg_sphere` extension
13+
([link](https://github.com/kimakan/pgsphere/tree/aiprdbms16))
14+
- removed not supported optional ADQL functions, such as `CENTROID`, `REGION`, etc.
15+
- replaced `setup.py` by `pyproject.toml` since `python setup.py install` is deprecated
16+
117
## 0.6.1 (2022-11-17)
218

319
- 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

+42-26
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 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)
@@ -22,9 +24,7 @@ Installation
2224
The easiest way to install the package is by using the pip tool:
2325

2426
```bash
25-
26-
pip install queryparser-python3
27-
27+
python -m pip install queryparser-python3
2828
```
2929

3030
Alternatively, you can clone the repository and install it from there.
@@ -37,45 +37,62 @@ Generating the parser from the git repository
3737

3838
To generate the parsers you need `python3` , `java` above version
3939
7, and `antlr4` (`antlr-4.*-complete.jar` has to be installed inside the
40-
`/usr/local/lib/` or `/usr/local/bin/` directories).
40+
`/usr/local/lib/`, `/usr/local/bin/` or root directory of the project).
41+
42+
The current version of `antlr-4.*-complete.jar` can be downloaded via
43+
44+
```bash
45+
wget http://www.antlr.org/download/antlr-4.13.1-complete.jar
46+
```
4147

4248
After cloning the project run
4349

4450
```bash
45-
make
51+
make
4652
```
4753

4854
and a `lib` directory will be created. After that, run
4955

5056
```bash
51-
python setup.py install
57+
python -m pip install .
5258
```
5359

5460
to install the generated parser in your virtual environment.
5561

5662

63+
Additional requirements
64+
-----------------------
65+
The queryparser assumes that the PostgreSQL database has the extension
66+
[pg_sphere](https://github.com/kimakan/pgsphere/tree/aiprdbms16) installed.
67+
Although the `pg_sphere` is not required for the python module, the PostgreSQL
68+
**queries will not run** without this extension installed on the database.
69+
70+
5771
Parsing MySQL and PostgreSQL
5872
----------------------------
5973

74+
**Since version 0.7, MySQL part of the parser is not maintained anymore.
75+
Thus, the MySQL related functionality cannot be guaranteed!**
76+
6077
Parsing and processing of MySQL queries can be done by creating an instance
6178
of the `MySQLQueryProcessor` class
6279

6380
```python
64-
from queryparser.mysql import MySQLQueryProcessor
65-
qp = MySQLQueryProcessor()
81+
from queryparser.mysql import MySQLQueryProcessor
82+
qp = MySQLQueryProcessor()
6683
```
6784

6885
feeding it a MySQL query
6986

7087
```python
71-
sql = "SELECT a FROM db.tab;"
72-
qp.set_query(sql)
88+
sql = "SELECT a FROM db.tab;"
89+
qp.set_query(sql)
7390
```
7491

7592
and running it with
7693

7794
```python
78-
qp.process_query()
95+
qp.process_query()
7996
```
8097

8198
After the processing is completed, the processor object `qp` will include
@@ -88,8 +105,8 @@ PostgreSQL parsing is very similar to MySQL, except it requires importing
88105
the `PostgreSQLProcessor` class:
89106

90107
```python
91-
from queryparser.postgresql import PostgreSQLQueryProcessor
92-
qp = PostgreSQLQueryProcessor()
108+
from queryparser.postgresql import PostgreSQLQueryProcessor
109+
qp = PostgreSQLQueryProcessor()
93110
```
94111

95112
The rest of the functionality remains the same.
@@ -102,35 +119,34 @@ Translation of ADQL queries is done similarly by first creating an instance of
102119
the `ADQLQueryTranslator` class
103120

104121
```python
105-
from queryparser.adql import ADQLQueryTranslator
106-
adql = "SELECT TOP 100 POINT('ICRS', ra, de) FROM db.tab;"
107-
adt = ADQLQueryTranslator(adql)
122+
from queryparser.adql import ADQLQueryTranslator
123+
adql = "SELECT TOP 100 POINT('ICRS', ra, de) FROM db.tab;"
124+
adt = ADQLQueryTranslator(adql)
108125
```
109126

110127
and calling
111128

112129
```python
113-
adt.to_mysql()
130+
adt.to_postgresql()
114131
```
115132

116133
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-
134+
the ADQL query had no errors. The PostgreSQL query can then be parsed with the
135+
`PostgreSQLQueryProcessor` in the same way as shown above.
120136

121137
Testing
122138
-------
123139

124-
First, install `pytest`
140+
First in the root directory of the project, install optional dependencies
141+
(`PyYAML` and `pytest`) by running
125142

126143
```bash
127-
pip install pytest
144+
python -m pip install .[test]
128145
```
129146

130-
then run the test suite for a version of python you would like to test with
147+
then run the test suite with
131148

132149
```bash
133-
pytest lib/
150+
python -m pytest lib/
134151
```
135152

136-
More elaborate testing procedures can be found in the development notes.

docs/dev-notes.md

-69
This file was deleted.

0 commit comments

Comments
 (0)