Skip to content

Commit

Permalink
more error check
Browse files Browse the repository at this point in the history
  • Loading branch information
burnout87 committed Jun 25, 2024
1 parent 5526e61 commit 7d099aa
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions cdci_data_analysis/analysis/ivoa_helper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from queryparser.adql import ADQLQueryTranslator
from queryparser.postgresql import PostgreSQLQueryProcessor
from queryparser.exceptions import QuerySyntaxError

from ..app_logging import app_logging

Expand All @@ -8,14 +9,22 @@


def parse_adql_query(query):
adt = ADQLQueryTranslator(query)
qp = PostgreSQLQueryProcessor()
qp.set_query(adt.to_postgresql())
qp.process_query()

output_obj = dict(
columns = qp.columns,
display_columns = qp.display_columns,
)
try:
adt = ADQLQueryTranslator(query)
qp = PostgreSQLQueryProcessor()
qp.set_query(adt.to_postgresql())
qp.process_query()

output_obj = dict(
columns = qp.columns,
display_columns = qp.display_columns,
tables = qp.tables,
)
except QuerySyntaxError as qe:
logger.error(f'Error parsing ADQL query: {qe}')
output_obj = dict(
columns = [],
display_columns = [],
tables = [],
)
return output_obj

0 comments on commit 7d099aa

Please sign in to comment.