Skip to content

Commit 458311b

Browse files
authored
Merge pull request #14 from aipescience/dev
update to 0.6.0
2 parents 648730b + 0924753 commit 458311b

File tree

14 files changed

+212
-95
lines changed

14 files changed

+212
-95
lines changed

.github/workflows/pytest.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
name: pytest
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Set up Python 3.9
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: 3.9
17+
18+
- name: Install prerequisites
19+
run: |
20+
sudo apt update
21+
sudo apt install -y default-jre
22+
python -m pip install --upgrade pip
23+
24+
- name: Build queryparser
25+
run: |
26+
wget http://www.antlr.org/download/antlr-4.11.1-complete.jar
27+
make
28+
pip install -r requirements.txt -I -e .
29+
pip install pytest-cov
30+
pip install coveralls
31+
32+
- name: Run Tests
33+
run: |
34+
pytest lib/ --cov=queryparser
35+
coveralls --service=github
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
40+
coveralls:
41+
name: Indicate completion to coveralls
42+
needs: build
43+
runs-on: ubuntu-latest
44+
container: python:3-slim
45+
steps:
46+
- name: Run Coveralls finish
47+
run: |
48+
pip install coveralls
49+
coveralls --service=github --finish
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## 0.6.0 (2022-11-04)
2+
3+
- bump the version of `antlr4-python3-runtime` to 4.11.1
4+
- added support for two custom functions - `gaia_healpix_index`, `pdist`
5+
- added support for `DISTINCT ON` , [Issue#11](https://github.com/aipescience/queryparser/issues/11)
6+
- added the `ILIKE` operator
7+
- fix installation of requirements.txt (e.g., the required version of
8+
antlr4-python3-runtime was overwritten by the most current one)
9+

README.rst renamed to README.md

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,26 @@ queryparser
44
**Tool for parsing and processing of MySQL/PostgreSQL and translation of
55
ADQL SELECT-like queries**
66

7-
Designed to be used in conjunction with `django-daiquri <http://github.com/aipescience/django-daiquiri/>`_
7+
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-
.. image:: https://travis-ci.org/aipescience/queryparser.svg?branch=master
12-
:alt: Build Status
13-
:target: https://travis-ci.org/aipescience/queryparser
1411

15-
.. image:: https://coveralls.io/repos/github/aipescience/queryparser/badge.svg?branch=master
16-
:alt: Coverage Status
17-
:target: https://coveralls.io/github/aipescience/queryparser?branch=master
12+
[![pytest Workflow Status](https://github.com/aipescience/queryparser/actions/workflows/pytest.yml/badge.svg)](https://github.com/aipescience/queryparser/actions/workflows/pytest.yml)
13+
[![Coverage Status](https://coveralls.io/repos/aipescience/queryparser/badge.svg?branch=dev&service=github)](https://coveralls.io/github/aipescience/queryparser?branch=dev)
14+
[![License](http://img.shields.io/badge/license-APACHE-blue.svg?style=flat)](https://github.com/aipescience/queryparser/blob/master/LICENSE)
15+
[![Latest Version](https://img.shields.io/pypi/v/queryparser-python3.svg?style=flat)](https://pypi.org/project/queryparser-python3/)
1816

19-
.. image:: https://img.shields.io/pypi/v/queryparser-python3.svg?style=flat
20-
:alt: Latest Version
21-
:target: https://pypi.python.org/pypi/queryparser-python3/
22-
23-
.. image:: http://img.shields.io/badge/license-APACHE-blue.svg?style=flat
24-
:target: https://github.com/adrn/schwimmbad/blob/master/LICENSE
2517

2618

2719
Installation
2820
------------
2921

3022
The easiest way to install the package is by using the pip tool:
3123

32-
.. code-block:: shell
33-
24+
```bash
3425
pip install queryparser-python3
26+
```
3527

3628
Alternatively, you can clone the repository and install it from there.
3729
However, this step also requires generating the parser which is a slightly
@@ -41,21 +33,21 @@ more elaborate process (see below).
4133
Generating the parser from the git repository
4234
---------------------------------------------
4335

44-
To generate the parsers you need `python3` , `java` above version
45-
7, and `antlr4` (`antlr-4.*-complete.jar` has to be installed inside the
36+
To generate the parsers you need `python3` , `java` above version
37+
7, and `antlr4` (`antlr-4.*-complete.jar` has to be installed inside the
4638
`/usr/local/lib/` or `/usr/local/bin/` directories).
4739

4840
After cloning the project run
4941

50-
.. code-block:: bash
51-
42+
```bash
5243
make
44+
```
5345

5446
and a `lib` directory will be created. After that, run
5547

56-
.. code-block:: bash
57-
48+
```bash
5849
python setup.py install
50+
```
5951

6052
to install the generated parser in your virtual environment.
6153

@@ -66,24 +58,23 @@ Parsing MySQL and PostgreSQL
6658
Parsing and processing of MySQL queries can be done by creating an instance
6759
of the ``MySQLQueryProcessor`` class
6860

69-
.. code-block:: python
70-
61+
```python
7162
from queryparser.mysql import MySQLQueryProcessor
72-
7363
qp = MySQLQueryProcessor()
64+
```
7465

7566
feeding it a MySQL query
7667

77-
.. code-block:: python
78-
68+
```python
7969
sql = "SELECT a FROM db.tab;"
8070
qp.set_query(sql)
71+
```
8172

8273
and running it with
8374

84-
.. code-block:: python
85-
75+
```python
8676
qp.process_query()
77+
```
8778

8879
After the processing is completed, the processor object ``qp`` will include
8980
tables, columns, functions, and keywords used in the query or will raise a
@@ -94,11 +85,10 @@ Alternatively, passing the query at initialization automatically processes it.
9485
PostgreSQL parsing is very similar to MySQL, except it requires importing
9586
the `PostgreSQLProcessor` class:
9687

97-
.. code-block:: python
98-
88+
```python
9989
from queryparser.postgresql import PostgreSQLQueryProcessor
100-
10190
qp = PostgreSQLQueryProcessor()
91+
```
10292

10393
The rest of the functionality remains the same.
10494

@@ -109,18 +99,17 @@ Translating ADQL
10999
Translation of ADQL queries is done similarly by first creating an instance of
110100
the ``ADQLQueryTranslator`` class
111101

112-
.. code-block:: python
113-
102+
```python
114103
from queryparser.adql import ADQLQueryTranslator
115-
116104
adql = "SELECT TOP 100 POINT('ICRS', ra, de) FROM db.tab;"
117105
adt = ADQLQueryTranslator(adql)
106+
```
118107

119108
and calling
120109

121-
.. code-block:: python
122-
110+
```python
123111
adt.to_mysql()
112+
```
124113

125114
which returns a translated string representing a valid MySQL query if
126115
the ADQL query had no errors. The MySQL query can then be parsed with the
@@ -132,14 +121,14 @@ Testing
132121

133122
First, install `pytest`
134123

135-
.. code-block:: bash
136-
124+
```bash
137125
pip install pytest
126+
```
138127

139128
then run the test suite for a version of python you would like to test with
140129

141-
.. code-block:: bash
142-
130+
```bash
143131
pytest lib/
132+
```
144133

145-
More elaborate testing procedures can be found in the development notes.
134+
More elaborate testing procedures can be found in the development notes.

docs/dev-notes.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
## ADQL
2+
#### Missing functions
3+
`CAST` function is not supported at all
4+
5+
6+
## PostgreSQL
7+
#### Missing functions
8+
Functions that are supported in pg14 but are not processed py the queryparser
9+
10+
###### Mathematical Functions
11+
- `factorial`
12+
- `gcd`
13+
- `lcm`
14+
- `log10`
15+
- `min_scale`
16+
- `truncate` is not supported in pg14 anymore!
17+
- `trunc`
18+
- `width_bucket`
19+
20+
###### Random Functions
21+
- `setseed` - not sure whether this functions must be implemented...
22+
23+
###### Trigonometric Functions
24+
- `acosd`
25+
- `asind`
26+
- `atand`
27+
- `atan2d`
28+
- `cosd`
29+
- `cotd`
30+
- `sind`
31+
- `tand`
32+
33+
###### Hyperbolic Functions
34+
- `sinh`
35+
- `cosh`
36+
- `tanh`
37+
- `asinh`
38+
- `acosh`
39+
- `atanh`
40+
41+
###### SQL String Functions and Operators
42+
- `||`, concatenates two strings, e.g. 'Post' || "greSQL" -> PostgreSQL, if
43+
one of the inputs is a non-string, then it's converted to string
44+
- `IS [NOT] NORMALIZED`, see https://www.postgresql.org/docs/14/functions-string.html
45+
- `character_length`, same as `char_length`
46+
- `normalize`
47+
- `octet_length`
48+
- `overlay`
49+
- `position`
50+
- `trim`
51+
52+
###### Other String Functions
53+
- `btrim`
54+
- `format`
55+
- `initcap`
56+
- `parse_ident`
57+
- all `quote_*` functions were not implemented, although already present in pg9
58+
- all `regex_*` functions were not implemented, although already present in pg9
59+
- `split_part`
60+
- `strpos`
61+
- `starts_with`
62+
- `string_to_array`
63+
- `string_to_table`
64+
- `to_ascii`
65+
- `unistr`
66+
67+
68+
###### Binary String Functions and Operators
69+

generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import subprocess
77
import re
88

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

1212
QUERYPARSER_SRC = 'src/queryparser/'

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
antlr4-python3-runtime==4.8
2-
pytest==5.4.3
3-
PyYAML==5.3.1
1+
antlr4-python3-runtime==4.11.1
2+
pytest~=6.2.5
3+
PyYAML~=6.0

setup.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
with open('lib/queryparser/__init__.py') as f:
1010
metadata = dict(re.findall(r'__(.*)__ = [\']([^\']*)[\']', f.read()))
1111

12-
requirements = [
13-
'pytest',
14-
'coverage',
15-
'antlr4-python%d-runtime' % python_version
16-
]
12+
with open('requirements.txt') as f:
13+
requirements = f.readlines()
1714

1815
# work around for python 3.4 and antlr4-python3-runtime
1916
if sys.version_info.major == 3 and sys.version_info.minor < 5:
@@ -30,7 +27,7 @@
3027
url='https://github.com/aipescience/queryparser',
3128
description=u'Parses PostgreSQL/MySQL and translates ADQL to ' +\
3229
'PostgreSQL/MySQL.',
33-
long_description=open('README.rst').read(),
30+
long_description=open('README.md').read(),
3431
long_description_content_type='text/x-rst',
3532
install_requires=requirements,
3633
classifiers=[],

src/queryparser/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
__title__ = 'queryparser'
2-
__version__ = '0.5.0'
2+
__version__ = '0.6.0'
33
__author__ = 'Gal Matijevic'
44
__email__ = 'gmatijevic@aip.de'
55
__license__ = 'Apache-2.0'
6-
__copyright__ = 'Copyright 2016-2020 Leibniz Institute for Astrophysics' +\
6+
__copyright__ = 'Copyright 2016-2022 Leibniz Institute for Astrophysics' +\
77
'Potsdam (AIP)'
88

99
VERSION = __version__

src/queryparser/adql/ADQLLexer.g4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ POINT :P_ O_ I_ N_ T_ ;
6565
POLYGON :P_ O_ L_ Y_ G_ O_ N_ ;
6666
POWER :P_ O_ W_ E_ R_ ;
6767
RADIANS :R_ A_ D_ I_ A_ N_ S_ ;
68-
REGION :R_ E_ G_ I_ O_ N_ ;
6968
RAND :R_ A_ N_ D_ ;
69+
REGION :R_ E_ G_ I_ O_ N_ ;
7070
ROUND :R_ O_ U_ N_ D_ ;
7171
SIN :S_ I_ N_ ;
7272
SQRT :S_ Q_ R_ T_ ;
@@ -364,4 +364,4 @@ WS
364364
'\u2029' | '\u202f' | '\u205f' | '\u3000' )+ -> channel(HIDDEN)
365365
;
366366

367-
COMMENT: '--' ~( '\r' | '\n' )* -> skip ;
367+
COMMENT: '--' ~( '\r' | '\n' )* -> skip ;

0 commit comments

Comments
 (0)