Skip to content

Commit

Permalink
remove not supported ADQL functions from grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
kimakan committed May 15, 2024
1 parent 09d7db8 commit ea6900b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
12 changes: 6 additions & 6 deletions src/queryparser/adql/ADQLLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ BIT_OR :B_ I_ T_ '_' O_ R_ ;
BIT_XOR :B_ I_ T_ '_' X_ O_ R_ ;
BOX :B_ O_ X_ ;
CEILING :C_ E_ I_ L_ I_ N_ G_ ;
CENTROID :C_ E_ N_ T_ R_ O_ I_ D_ ;
//CENTROID :C_ E_ N_ T_ R_ O_ I_ D_ ;
CIRCLE :C_ I_ R_ C_ L_ E_ ;
CONTAINS :C_ O_ N_ T_ A_ I_ N_ S_ ;
COORD1 :C_ O_ O_ R_ D_ '1' ;
COORD2 :C_ O_ O_ R_ D_ '2' ;
COORDSYS :C_ O_ O_ R_ D_ S_ Y_ S_ ;
//COORD1 :C_ O_ O_ R_ D_ '1' ;
//COORD2 :C_ O_ O_ R_ D_ '2' ;
//COORDSYS :C_ O_ O_ R_ D_ S_ Y_ S_ ;
COS :C_ O_ S_ ;
COT :C_ O_ T_ ;
DEGREES :D_ E_ G_ R_ E_ E_ S_ ;
Expand All @@ -56,7 +56,7 @@ EXP :E_ X_ P_ ;
FLOOR :F_ L_ O_ O_ R_ ;
ILIKE :I_ L_ I_ K_ E_ ;
INTERSECTS :I_ N_ T_ E_ R_ S_ E_ C_ T_ S_ ;
IN_UNIT :I_ N_ '_' U_ N_ I_ T_ ;
//IN_UNIT :I_ N_ '_' U_ N_ I_ T_ ;
LOG :L_ O_ G_ ;
LOG10 :L_ O_ G_ '10' ;
MOD :M_ O_ D_ ;
Expand All @@ -66,7 +66,7 @@ POLYGON :P_ O_ L_ Y_ G_ O_ N_ ;
POWER :P_ O_ W_ E_ R_ ;
RADIANS :R_ A_ D_ I_ A_ N_ S_ ;
RAND :R_ A_ N_ D_ ;
REGION :R_ E_ G_ I_ O_ N_ ;
//REGION :R_ E_ G_ I_ O_ N_ ;
ROUND :R_ O_ U_ N_ D_ ;
SIN :S_ I_ N_ ;
SQRT :S_ Q_ R_ T_ ;
Expand Down
20 changes: 10 additions & 10 deletions src/queryparser/adql/ADQLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ box:
coordinates COMMA numeric_value_expression COMMA numeric_value_expression
RPAREN ;
catalog_name: ID ;
centroid: CENTROID LPAREN geometry_value_expression RPAREN ;
// centroid: CENTROID LPAREN geometry_value_expression RPAREN ;
// character_representation: nonquote_character ;// | SQ SQ ;
char_function: LOWER LPAREN character_string_literal RPAREN ;
character_string_literal: CSL ; //SQ ( SL )* SQ ; //SQ ( character_representation )* SQ ;
Expand All @@ -44,8 +44,8 @@ contains: CONTAINS LPAREN geometry_value_expression COMMA
contains_predicate: INT EQ contains;
coord_sys: string_value_expression ;
coord_value: point_value | column_reference ;
coord1: COORD1 LPAREN coord_value RPAREN ;
coord2: COORD2 LPAREN coord_value RPAREN ;
//coord1: COORD1 LPAREN coord_value RPAREN ;
//coord2: COORD2 LPAREN coord_value RPAREN ;
coordinate1: numeric_value_expression ;
coordinate2: numeric_value_expression ;
coordinates: coordinate1 COMMA coordinate2 ;
Expand All @@ -65,12 +65,12 @@ distance:
//double_quote_symbol: DQ DQ ;
exact_numeric_literal: unsigned_decimal ( DOT ( unsigned_decimal )? )? | DOT unsigned_decimal;
exists_predicate: EXISTS table_subquery ;
extract_coordsys: COORDSYS LPAREN geometry_value_expression RPAREN ;
// extract_coordsys: COORDSYS LPAREN geometry_value_expression RPAREN ;
factor: ( sign )? numeric_primary ;
from_clause: FROM table_reference ( COMMA table_reference )* ;
general_literal: character_string_literal ;
general_set_function: set_function_type LPAREN ( set_quantifier )? value_expression RPAREN ;
geometry_value_expression: box | circle | centroid | point | polygon | region | user_defined_function ;
geometry_value_expression: box | circle | point | polygon | user_defined_function ; //| centroid | region
group_by_clause: GROUP BY grouping_column_reference_list ;
grouping_column_reference: column_reference ;
grouping_column_reference_list: grouping_column_reference ( COMMA grouping_column_reference )* ;
Expand Down Expand Up @@ -111,7 +111,7 @@ non_join_query_expression: non_join_query_term | query_expression UNION ( A
| query_expression EXCEPT ( ALL )? query_term ;
non_join_query_primary: query_specification | LPAREN non_join_query_expression RPAREN ;
non_join_query_term: non_join_query_primary | query_term INTERSECT ( ALL )? query_expression ;
non_predicate_geometry_function:area | coord1 | coord2 | distance ;
non_predicate_geometry_function:area | distance ; //coord1 | coord2 |
//nondoublequote_character: NDQC ;
//nonquote_character: NQC ;
null_predicate: column_reference IS ( NOT )? NULL ;
Expand All @@ -132,7 +132,7 @@ ordering_specification: ASC | DESC ;
outer_join_type: LEFT | RIGHT | FULL ;
pattern: character_value_expression ;
point: POINT LPAREN ( coord_sys COMMA )? coordinates RPAREN ;
point_value: point | centroid | user_defined_function ;
point_value: point | user_defined_function ;//| centroid
polygon: POLYGON LPAREN
( coord_sys COMMA )?
coordinates COMMA
Expand All @@ -158,7 +158,7 @@ query: query_expression SEMI;
query_specification: ( WITH with_query )? select_query ;
query_term: non_join_query_primary | query_term INTERSECT ( ALL )? query_expression | joined_table ;
radius: numeric_value_expression ;
region: REGION LPAREN string_value_expression RPAREN ;
//region: REGION LPAREN string_value_expression RPAREN ;
regular_identifier: ID ;
schema_name: ID ; //( catalog_name DOT )? unqualified_schema_name ;
search_condition: boolean_term | search_condition OR boolean_term ;
Expand All @@ -174,9 +174,9 @@ signed_integer: ( sign )? unsigned_decimal ;
sort_key: value_expression| column_reference | unsigned_decimal ;
sort_specification: sort_key (ordering_specification )? ;
sort_specification_list: sort_specification ( COMMA sort_specification )* ;
string_geometry_function: extract_coordsys ;
//string_geometry_function: extract_coordsys ;
string_value_expression: character_value_expression ;
string_value_function: string_geometry_function | user_defined_function | char_function;
string_value_function: user_defined_function | char_function; //string_geometry_function |
subquery: LPAREN query_expression RPAREN ;
table_expression:
from_clause
Expand Down
3 changes: 2 additions & 1 deletion src/queryparser/adql/adqltranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def visitArea(self, ctx):
ctx.removeLastChild()
self.contexts[ctx] = ctx_text


'''
def visitCentroid(self, ctx):
"""
Works only for circles.
Expand All @@ -348,6 +348,7 @@ def visitCentroid(self, ctx):
_remove_children(ctx)
self.contexts[ctx] = ctx_text
'''

def visitContains_predicate(self, ctx):
comp_value = ctx.children[0].getText()
Expand Down
8 changes: 0 additions & 8 deletions src/queryparser/testing/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,6 @@ adql_mysql_tests:
- SELECT TOP 10 AREA(CIRCLE('ICRS', "tab".RA, -2.23, 176.98)) FROM db.tab
- SELECT sarea(scircle(spoint(RADIANS(`tab`.`RA`), RADIANS(-2.23)), RADIANS(176.98))) AS adql_area FROM `db`.`tab` LIMIT 10;

-
- SELECT CENTROID(CIRCLE('ICRS', 10.0, -10.5, 2.0)) FROM db.tab;
- SELECT scenter(scircle(spoint(RADIANS(10.0), RADIANS(-10.5)), RADIANS(2.0))) FROM `db`.`tab`;

-
- SELECT TOP 10 ra, dec FROM db.tab WHERE 1=CONTAINS(POINT('ICRS', ra, dec), BOX('ICRS', -3.0, 5.0, 4.0, 10.0));
- SELECT `ra`, `dec` FROM `db`.`tab` WHERE 1 = srcontainsl(spoint(RADIANS(`ra`), RADIANS(`dec`)), sbox(spoint(RADIANS(-5.000000000000),RADIANS(0.000000000000)),spoint(RADIANS(-1.000000000000),RADIANS(10.000000000000)))) LIMIT 10;
Expand Down Expand Up @@ -847,10 +843,6 @@ adql_postgresql_tests:
- SELECT CIRCLE(POINT(10.0, -10.5), 2.0) FROM db.tab;
- SELECT scircle_to_array_deg(scircle(spoint(RADIANS(10.0), RADIANS(-10.5)), RADIANS(2.0))) AS circle FROM db.tab;

-
- SELECT CENTROID(CIRCLE('ICRS', 10.0, -10.5, 2.0)) FROM db.tab;
- SELECT @@ scircle(spoint(RADIANS(10.0), RADIANS(-10.5)), RADIANS(2.0)) FROM db.tab;

-
- SELECT TOP 10 ra, dec FROM db.tab WHERE 1=CONTAINS(POINT('ICRS', ra, dec), BOX('ICRS', -3.0, 5.0, 4.0, 10.0));
- SELECT ra, dec FROM db.tab WHERE spoint(RADIANS(ra), RADIANS(dec)) @ sbox(spoint(RADIANS(-5.000000000000),RADIANS(0.000000000000)),spoint(RADIANS(-1.000000000000),RADIANS(10.000000000000))) LIMIT 10;
Expand Down

0 comments on commit ea6900b

Please sign in to comment.