Commit e377f26c authored by Grégory Mantelet's avatar Grégory Mantelet
Browse files

[ADQL] Add the version of the used ADQL grammar in ADQLQuery + Make geometries

optional features of the ADQL-2.0 grammar (thus, supported geometries must be
declared as in the ADQL-2.1 parser: with the FeatureSet of the parser).

TODO: see how to throw errors when un-supported geometries are used in STC-S
      as done before at the DBChecker level.
parent 0b7cb510
Loading
Loading
Loading
Loading
+191 −143
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ package adql.db;
 * You should have received a copy of the GNU Lesser General Public License
 * along with ADQLLibrary.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright 2011-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 * Copyright 2011-2019 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 *                       Astronomisches Rechen Institut (ARI)
 */

@@ -70,49 +70,69 @@ import adql.search.SimpleReplaceHandler;
import adql.search.SimpleSearchHandler;

/**
 * This {@link QueryChecker} implementation is able to do the following verifications on an ADQL query:
 * This {@link QueryChecker} implementation is able to do the following
 * verifications on an ADQL query:
 * <ol>
 * 	<li>Check the existence of all table and column references found in a query</li>
 * 	<li>Resolve all unknown functions as supported User Defined Functions (UDFs)</li>
 * 	<li>Check whether all used geometrical functions are supported</li>
 * 	<li>Check the existence of all table and column references found in a
 * 		query</li>
 * 	<li>Resolve all unknown functions as supported User Defined Functions
 * 		(UDFs)</li>
 * 	<li>Check whether all used coordinate systems are supported</li>
 * 	<li>Check that types of columns and UDFs match with their context</li>
 * </ol>
 *
 * <p><i><b>IMPORTANT note:</b>
 * 	Since v2.0, the check of supported geometrical functions is performed
 * 	directly in ADQLParser through the notion of Optional Features.
 * 	The declaration of supported geometrical functions must now be done
 * 	with {@link adql.parser.ADQLParser#getSupportedFeatures() ADQLParser.getSupportedFeatures()}
 * 	(see also {@link adql.parser.feature.FeatureSet FeatureSet}).
 * </i></p>
 *
 * <h3>Check tables and columns</h3>
 * <p>
 * 	In addition to check the existence of tables and columns referenced in the query,
 * 	this checked will also attach database metadata on these references ({@link ADQLTable}
 * 	and {@link ADQLColumn} instances when they are resolved.
 * 	In addition to check the existence of tables and columns referenced in the
 * 	query, this checked will also attach database metadata on these references
 * 	({@link ADQLTable} and {@link ADQLColumn} instances when they are resolved.
 * </p>
 *
 * <p>These information are:</p>
 * <ul>
 * 	<li>the corresponding {@link DBTable} or {@link DBColumn} (see getter and setter for DBLink in {@link ADQLTable} and {@link ADQLColumn})</li>
 * 	<li>the corresponding {@link DBTable} or {@link DBColumn} (see getter and
 * 		setter for DBLink in {@link ADQLTable} and {@link ADQLColumn})</li>
 * 	<li>the link between an {@link ADQLColumn} and its {@link ADQLTable}</li>
 * </ul>
 *
 * <p><i><u>Note:</u>
 * 	Knowing DB metadata of {@link ADQLTable} and {@link ADQLColumn} is particularly useful for the translation of the ADQL query to SQL,
 * 	because the ADQL name of columns and tables can be replaced in SQL by their DB name, if different. This mapping is done automatically
 * 	by {@link adql.translator.JDBCTranslator}.
 * 	Knowing DB metadata of {@link ADQLTable} and {@link ADQLColumn} is
 * 	particularly useful for the translation of the ADQL query to SQL, because
 * 	the ADQL name of columns and tables can be replaced in SQL by their DB name,
 * 	if different. This mapping is done automatically by
 * 	{@link adql.translator.JDBCTranslator}.
 * </i></p>
 *
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 1.4 (11/2017)
 * @version 2.0 (07/2019)
 */
public class DBChecker implements QueryChecker {

	/** List of all available tables ({@link DBTable}). */
	protected SearchTableApi lstTables;

	/** <p>List of all allowed geometrical functions (i.e. CONTAINS, REGION, POINT, COORD2, ...).</p>
	/** List of all allowed geometrical functions (i.e. CONTAINS, REGION, POINT,
	 * COORD2, ...).
	 *
	 * <p>
	 * 	If this list is NULL, all geometrical functions are allowed.
	 * 	However, if not, all items of this list must be the only allowed geometrical functions.
	 * 	So, if the list is empty, no such function is allowed.
	 * 	However, if not, all items of this list must be the only allowed
	 * 	geometrical functions. So, if the list is empty, no such function is
	 * 	allowed.
	 * </p>
	 * @since 1.3 */
	 *
	 * @since 1.3
	 * @deprecated Since v2.0, supported geometrical functions must be declared
	 *             in ADQLParser. */
	@Deprecated
	protected String[] allowedGeo = null;

	/** <p>List of all allowed coordinate systems.</p>
@@ -156,7 +176,6 @@ public class DBChecker implements QueryChecker {
	 * <ul>
	 * 	<li>Existence of tables and columns:            <b>NO <i>(even unknown or fake tables and columns are allowed)</i></b></li>
	 * 	<li>Existence of User Defined Functions (UDFs): <b>NO <i>(any "unknown" function is allowed)</i></b></li>
	 * 	<li>Support of geometrical functions:           <b>NO <i>(all valid geometrical functions are allowed)</i></b></li>
	 * 	<li>Support of coordinate systems:              <b>NO <i>(all valid coordinate systems are allowed)</i></b></li>
	 * </ul>
	 */
@@ -171,7 +190,6 @@ public class DBChecker implements QueryChecker {
	 * <ul>
	 * 	<li>Existence of tables and columns:            <b>OK</b></li>
	 * 	<li>Existence of User Defined Functions (UDFs): <b>NO <i>(any "unknown" function is allowed)</i></b></li>
	 * 	<li>Support of geometrical functions:           <b>NO <i>(all valid geometrical functions are allowed)</i></b></li>
	 * 	<li>Support of coordinate systems:              <b>NO <i>(all valid coordinate systems are allowed)</i></b></li>
	 * </ul>
	 *
@@ -188,7 +206,6 @@ public class DBChecker implements QueryChecker {
	 * <ul>
	 * 	<li>Existence of tables and columns:            <b>OK</b></li>
	 * 	<li>Existence of User Defined Functions (UDFs): <b>OK</b></li>
	 * 	<li>Support of geometrical functions:           <b>NO <i>(all valid geometrical functions are allowed)</i></b></li>
	 * 	<li>Support of coordinate systems:              <b>NO <i>(all valid coordinate systems are allowed)</i></b></li>
	 * </ul>
	 *
@@ -251,7 +268,12 @@ public class DBChecker implements QueryChecker {
	 *                       	If it is empty, no coordinate system is allowed (except the default values - generally expressed by an empty string: '').
	 *
	 * @since 1.3
	 * @deprecated	Since v2.0, the check of geometrical functions support is
	 *            	performed in ADQLParser. It must now be done with
	 *            	{@link adql.parser.ADQLParser#getSupportedFeatures() ADQLParser.getSupportedFeatures()}
	 * 	          	(see also {@link adql.parser.feature.FeatureSet FeatureSet}).
	 */
	@Deprecated
	public DBChecker(final Collection<? extends DBTable> tables, final Collection<String> allowedGeoFcts, final Collection<String> allowedCoordSys) throws ParseException {
		this(tables, null, allowedGeoFcts, allowedCoordSys);
	}
@@ -263,10 +285,17 @@ public class DBChecker implements QueryChecker {
	 * <ul>
	 * 	<li>Existence of tables and columns:            <b>OK</b></li>
	 * 	<li>Existence of User Defined Functions (UDFs): <b>OK</b></li>
	 * 	<li>Support of geometrical functions:           <b>OK</b></li>
	 * 	<li>Support of coordinate systems:              <b>OK</b></li>
	 * </ul>
	 *
	 * <p><i><b>IMPORTANT note:</b>
	 * 	Since v2.0, the check of supported geometrical functions is performed
	 * 	directly in ADQLParser through the notion of Optional Features.
	 * 	The declaration of supported geometrical functions must now be done
	 * 	with {@link adql.parser.ADQLParser#getSupportedFeatures() ADQLParser.getSupportedFeatures()}
	 * 	(see also {@link adql.parser.feature.FeatureSet FeatureSet}).
	 * </i></p>
	 *
	 * @param tables			List of all available tables.
	 * @param allowedUdfs		List of all allowed user defined functions.
	 *                   		If NULL, no verification will be done (and so, all UDFs are allowed).
@@ -284,8 +313,13 @@ public class DBChecker implements QueryChecker {
	 *                       	If the given list is NULL, no verification will be done (and so, all coordinate systems are allowed).
	 *                       	If it is empty, no coordinate system is allowed (except the default values - generally expressed by an empty string: '').
	 *
	 * @since 1.3
	 * @since 2.0
	 * @deprecated	Since v2.0, the check of geometrical functions support is
	 *            	performed in ADQLParser. It must now be done with
	 *            	{@link adql.parser.ADQLParser#getSupportedFeatures() ADQLParser.getSupportedFeatures()}
	 * 	          	(see also {@link adql.parser.feature.FeatureSet FeatureSet}).
	 */
	@Deprecated
	public DBChecker(final Collection<? extends DBTable> tables, final Collection<? extends FunctionDef> allowedUdfs, final Collection<String> allowedGeoFcts, final Collection<String> allowedCoordSys) throws ParseException {
		// Set the list of available tables + Set the list of all known UDFs:
		this(tables, allowedUdfs);
@@ -960,16 +994,22 @@ public class DBChecker implements QueryChecker {
	 *
	 * <p>Operations done in this function:</p>
	 * <ol>
	 * 	<li>Check that all geometrical functions are supported</li>
	 * 	<li>Check that all explicit (string constant) coordinate system definitions are supported</i></li>
	 * 	<li>Check all STC-S expressions (only in {@link RegionFunction} for the moment) and
	 * 	    Apply the 2 previous checks on them</li>
	 * </ol>
	 *
	 * <p><i><b>IMPORTANT note:</b>
	 * 	Since v2.0, the check of supported geometrical functions is performed
	 * 	directly in ADQLParser through the notion of Optional Features.
	 * 	The declaration of supported geometrical functions must now be done
	 * 	with {@link adql.parser.ADQLParser#getSupportedFeatures() ADQLParser.getSupportedFeatures()}
	 * 	(see also {@link adql.parser.feature.FeatureSet FeatureSet}).
	 * </i></p>
	 *
	 * @param query		Query in which geometries must be checked.
	 * @param errors	List of errors to complete in this function each time a geometry item is not supported.
	 *
	 * @see #resolveGeometryFunctions(ADQLQuery, BinarySearch, UnresolvedIdentifiersException)
	 * @see #resolveCoordinateSystems(ADQLQuery, UnresolvedIdentifiersException)
	 * @see #resolveSTCSExpressions(ADQLQuery, BinarySearch, UnresolvedIdentifiersException)
	 *
@@ -983,15 +1023,11 @@ public class DBChecker implements QueryChecker {
			}
		};

		// a. Ensure that all used geometry functions are allowed:
		if (allowedGeo != null)
			resolveGeometryFunctions(query, binSearch, errors);

		// b. Check whether the coordinate systems are allowed:
		// a. Check whether the coordinate systems are allowed:
		if (allowedCoordSys != null)
			resolveCoordinateSystems(query, errors);

		// c. Check all STC-S expressions (in RegionFunctions only) + the used coordinate systems (if StringConstant only):
		// b. Check all STC-S expressions (in RegionFunctions only) + the used coordinate systems (if StringConstant only):
		if (allowedGeo == null || (allowedGeo.length > 0 && binSearch.search("REGION", allowedGeo) >= 0))
			resolveSTCSExpressions(query, binSearch, errors);
	}
@@ -1005,8 +1041,14 @@ public class DBChecker implements QueryChecker {
	 * @see #checkGeometryFunction(String, ADQLFunction, BinarySearch, UnresolvedIdentifiersException)
	 *
	 * @since 1.3
	 * @deprecated	No more used since v2.0. Check of the geometric functions is
	 *            	now performed directly in ADQLParser. Geometric functions
	 *            	are optional features and should be declared as such in the
	 *            	ADQLParser if they are supported (see
	 *            	{@link adql.parser.ADQLParser#getSupportedFeatures() ADQLParser.getSupportedFeatures()}).
	 */
	protected void resolveGeometryFunctions(final ADQLQuery query, final BinarySearch<String,String> binSearch, final UnresolvedIdentifiersException errors){
	@Deprecated
	protected final void resolveGeometryFunctions(final ADQLQuery query, final BinarySearch<String, String> binSearch, final UnresolvedIdentifiersException errors) {
		ISearchHandler sHandler = new SearchGeometryHandler();
		sHandler.search(query);

@@ -1034,8 +1076,14 @@ public class DBChecker implements QueryChecker {
	 * @param errors		List of errors to complete in this function each time a geometrical function is not supported.
	 *
	 * @since 1.3
	 * @deprecated	No more used since v2.0. Check of the geometric functions is
	 *            	now performed directly in ADQLParser. Geometric functions
	 *            	are optional features and should be declared as such in the
	 *            	ADQLParser if they are supported (see
	 *            	{@link adql.parser.ADQLParser#getSupportedFeatures() ADQLParser.getSupportedFeatures()}).
	 */
	protected void checkGeometryFunction(final String fctName, final ADQLFunction fct, final BinarySearch<String,String> binSearch, final UnresolvedIdentifiersException errors){
	@Deprecated
	protected final void checkGeometryFunction(final String fctName, final ADQLFunction fct, final BinarySearch<String, String> binSearch, final UnresolvedIdentifiersException errors) {
		int match = -1;
		if (allowedGeo.length != 0)
			match = binSearch.search(fctName, allowedGeo);
+105 −74
Original line number Diff line number Diff line
@@ -26,10 +26,14 @@ import java.util.ArrayList;
import java.util.Stack;
import java.util.Vector;

import adql.db.exception.UnresolvedIdentifiersException;
import adql.db.exception.UnsupportedFeatureException;
import adql.parser.ADQLParserFactory.ADQLVersion;
import adql.parser.ADQLQueryFactory.JoinType;
import adql.parser.IdentifierItems.IdentifierItem;
import adql.parser.feature.FeatureSet;
import adql.parser.feature.LanguageFeature;
import adql.query.ADQLObject;
import adql.query.ADQLOrder;
import adql.query.ADQLQuery;
import adql.query.ClauseADQL;
@@ -67,6 +71,7 @@ import adql.query.operand.function.UserDefinedFunction;
import adql.query.operand.function.geometry.GeometryFunction;
import adql.query.operand.function.geometry.GeometryFunction.GeometryValue;
import adql.query.operand.function.geometry.PointFunction;
import adql.search.SearchOptionalFeaturesHandler;

/**
* Parses an ADQL-2.0 query thanks to the {@link ADQLParser200#Query() Query()} function.
@@ -117,6 +122,12 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {
	/** Tools to build the object representation of the ADQL query. */
	private ADQLQueryFactory queryFactory = new ADQLQueryFactory();

	/** Default set of supported language features.
	* <p><i><b>Note:</b>
	* 	By default, all optional features are supported.
	* </i></p> */
	private FeatureSet supportedFeatures = new FeatureSet(false);

	/** The stack of queries (because there may be some sub-queries). */
	private Stack<ADQLQuery> stackQuery = new Stack<ADQLQuery>();

@@ -137,6 +148,7 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {
	*/
	public ADQLParser200() {
		this(new java.io.ByteArrayInputStream("".getBytes()));
		supportedFeatures.supportAll(LanguageFeature.TYPE_ADQL_GEO);
		setDebug(false);
	}

@@ -188,7 +200,8 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {
	*/
	public ADQLParser200(java.io.InputStream stream, QueryChecker checker, ADQLQueryFactory factory) {
		this(stream);
		setDebug(false);

		supportedFeatures.supportAll(LanguageFeature.TYPE_ADQL_GEO);

		setDebug(false);

@@ -230,6 +243,9 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {
	*/
	public ADQLParser200(java.io.InputStream stream, String encoding, QueryChecker checker, ADQLQueryFactory factory) {
		this(stream, encoding);

		supportedFeatures.supportAll(LanguageFeature.TYPE_ADQL_GEO);

		setDebug(false);

		queryChecker = checker;
@@ -271,7 +287,8 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {
	*/
	public ADQLParser200(java.io.Reader reader, QueryChecker checker, ADQLQueryFactory factory) {
		this(reader);
		setDebug(false);

		supportedFeatures.supportAll(LanguageFeature.TYPE_ADQL_GEO);

		setDebug(false);

@@ -312,7 +329,8 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {
	*/
	public ADQLParser200(ADQLParser200TokenManager tm, QueryChecker checker, ADQLQueryFactory factory) {
		this(tm);
		setDebug(false);

		supportedFeatures.supportAll(LanguageFeature.TYPE_ADQL_GEO);

		setDebug(false);

@@ -380,15 +398,13 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {

	@Override
	public final FeatureSet getSupportedFeatures() {
		FeatureSet languageFeatures = new FeatureSet();
		languageFeatures.unsupportAll();
		return languageFeatures;
		return supportedFeatures;
	}

	@Override
	public final void setSupportedFeatures(final FeatureSet languageFeatures) {
		/* Nothing to do here for ADQL-2.0 because no optional feature can be
		* supported)! */
	public void setSupportedFeatures(final FeatureSet features) {
		if (features != null)
			supportedFeatures = features;
	}

	/* EXCEPTION HELPER FUNCTION */
@@ -533,7 +549,7 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {

		try {
			// Create the query:
			query = queryFactory.createQuery();
			query = queryFactory.createQuery(ADQLVersion.V2_0);

			// Parse the string as a SELECT clause:
			Select();
@@ -555,7 +571,7 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {

		try {
			// Create the query:
			query = queryFactory.createQuery();
			query = queryFactory.createQuery(ADQLVersion.V2_0);

			// Parse the string as a FROM clause:
			From();
@@ -577,7 +593,7 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {

		try {
			// Create the query:
			query = queryFactory.createQuery();
			query = queryFactory.createQuery(ADQLVersion.V2_0);

			// Parse the string as a WHERE clause:
			Where();
@@ -599,7 +615,7 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {

		try {
			// Create the query:
			query = queryFactory.createQuery();
			query = queryFactory.createQuery(ADQLVersion.V2_0);

			// Parse the string as a ORDER BY clause:
			OrderBy();
@@ -621,7 +637,7 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {

		try {
			// Create the query:
			query = queryFactory.createQuery();
			query = queryFactory.createQuery(ADQLVersion.V2_0);

			// Parse the string as a GROUP BY clause:
			GroupBy();
@@ -972,6 +988,21 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {
					jj_consume_token(-1);
					throw new ParseException();
			}
			/* check the optional features before any other check:
					 * (note: this check is very close to grammar check...hence its higher
					 *        priority) */
			UnresolvedIdentifiersException exUnsupportedFeatures = new UnresolvedIdentifiersException("unsupported expression");
			SearchOptionalFeaturesHandler sFeaturesHandler = new SearchOptionalFeaturesHandler(true, false);
			sFeaturesHandler.search(q);
			for(ADQLObject obj : sFeaturesHandler) {
				if (!supportedFeatures.isSupporting(obj.getFeatureDescription()))
					exUnsupportedFeatures.addException(new UnsupportedFeatureException(obj));
			}
			if (exUnsupportedFeatures.getNbErrors() > 0) {
				if (true)
					throw exUnsupportedFeatures;
			}

			// check the query:
			if (queryChecker != null)
				queryChecker.check(q);
@@ -992,7 +1023,7 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {
			TextPosition endPos = null;
			try {
				// create the query:
				query = queryFactory.createQuery();
				query = queryFactory.createQuery(ADQLVersion.V2_0);
				stackQuery.push(query);
			} catch(Exception ex) {
				{
@@ -4428,65 +4459,6 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {
		}
	}

	private boolean jj_3_18() {
		if (jj_3R_16())
			return true;
		return false;
	}

	private boolean jj_3R_55() {
		Token xsp;
		xsp = jj_scanpos;
		if (jj_scan_token(25)) {
			jj_scanpos = xsp;
			if (jj_3R_74())
				return true;
		}
		return false;
	}

	private boolean jj_3R_35() {
		Token xsp;
		xsp = jj_scanpos;
		if (jj_3R_55())
			jj_scanpos = xsp;
		if (jj_scan_token(JOIN))
			return true;
		if (jj_3R_56())
			return true;
		return false;
	}

	private boolean jj_3R_34() {
		if (jj_scan_token(NATURAL))
			return true;
		Token xsp;
		xsp = jj_scanpos;
		if (jj_3R_54())
			jj_scanpos = xsp;
		if (jj_scan_token(JOIN))
			return true;
		return false;
	}

	private boolean jj_3R_28() {
		Token xsp;
		xsp = jj_scanpos;
		if (jj_scan_token(36))
			jj_scanpos = xsp;
		if (jj_scan_token(BETWEEN))
			return true;
		if (jj_3R_51())
			return true;
		return false;
	}

	private boolean jj_3_15() {
		if (jj_3R_28())
			return true;
		return false;
	}

	private boolean jj_3R_17() {
		Token xsp;
		xsp = jj_scanpos;
@@ -6155,6 +6127,65 @@ public class ADQLParser200 implements ADQLParser, ADQLParser200Constants {
		return false;
	}

	private boolean jj_3_18() {
		if (jj_3R_16())
			return true;
		return false;
	}

	private boolean jj_3R_55() {
		Token xsp;
		xsp = jj_scanpos;
		if (jj_scan_token(25)) {
			jj_scanpos = xsp;
			if (jj_3R_74())
				return true;
		}
		return false;
	}

	private boolean jj_3R_35() {
		Token xsp;
		xsp = jj_scanpos;
		if (jj_3R_55())
			jj_scanpos = xsp;
		if (jj_scan_token(JOIN))
			return true;
		if (jj_3R_56())
			return true;
		return false;
	}

	private boolean jj_3R_34() {
		if (jj_scan_token(NATURAL))
			return true;
		Token xsp;
		xsp = jj_scanpos;
		if (jj_3R_54())
			jj_scanpos = xsp;
		if (jj_scan_token(JOIN))
			return true;
		return false;
	}

	private boolean jj_3R_28() {
		Token xsp;
		xsp = jj_scanpos;
		if (jj_scan_token(36))
			jj_scanpos = xsp;
		if (jj_scan_token(BETWEEN))
			return true;
		if (jj_3R_51())
			return true;
		return false;
	}

	private boolean jj_3_15() {
		if (jj_3R_28())
			return true;
		return false;
	}

	/** Generated Token Manager. */
	public ADQLParser200TokenManager token_source;
	SimpleCharStream jj_input_stream;
+3 −0
Original line number Diff line number Diff line
@@ -27,10 +27,12 @@ import java.util.Collection;
import java.io.FileReader;
import java.io.IOException;
import adql.db.exception.UnresolvedIdentifiersException;
import adql.db.exception.UnsupportedFeatureException;
import adql.parser.ADQLParserFactory.ADQLVersion;
import adql.parser.IdentifierItems.IdentifierItem;
import adql.parser.ADQLQueryFactory.JoinType;
import adql.parser.feature.FeatureSet;
import adql.parser.feature.LanguageFeature;
import adql.query.*;
import adql.query.from.*;
import adql.query.constraint.*;
@@ -38,6 +40,7 @@ import adql.query.operand.*;
import adql.query.operand.function.*;
import adql.query.operand.function.geometry.*;
import adql.query.operand.function.geometry.GeometryFunction.GeometryValue;
import adql.search.SearchOptionalFeaturesHandler;
import adql.translator.PostgreSQLTranslator;
import adql.translator.TranslationException;

+6 −6
Original line number Diff line number Diff line
@@ -542,7 +542,7 @@ public class ADQLParser201 implements ADQLParser, ADQLParser201Constants {

		try {
			// Create the query:
			query = queryFactory.createQuery();
			query = queryFactory.createQuery(ADQLVersion.V2_1);

			// Parse the string as a SELECT clause:
			Select();
@@ -564,7 +564,7 @@ public class ADQLParser201 implements ADQLParser, ADQLParser201Constants {

		try {
			// Create the query:
			query = queryFactory.createQuery();
			query = queryFactory.createQuery(ADQLVersion.V2_1);

			// Parse the string as a FROM clause:
			From();
@@ -586,7 +586,7 @@ public class ADQLParser201 implements ADQLParser, ADQLParser201Constants {

		try {
			// Create the query:
			query = queryFactory.createQuery();
			query = queryFactory.createQuery(ADQLVersion.V2_1);

			// Parse the string as a WHERE clause:
			Where();
@@ -608,7 +608,7 @@ public class ADQLParser201 implements ADQLParser, ADQLParser201Constants {

		try {
			// Create the query:
			query = queryFactory.createQuery();
			query = queryFactory.createQuery(ADQLVersion.V2_1);

			// Parse the string as a ORDER BY clause:
			OrderBy();
@@ -630,7 +630,7 @@ public class ADQLParser201 implements ADQLParser, ADQLParser201Constants {

		try {
			// Create the query:
			query = queryFactory.createQuery();
			query = queryFactory.createQuery(ADQLVersion.V2_1);

			// Parse the string as a GROUP BY clause:
			GroupBy();
@@ -1016,7 +1016,7 @@ public class ADQLParser201 implements ADQLParser, ADQLParser201Constants {
			TextPosition endPos = null;
			try {
				// create the query:
				query = queryFactory.createQuery();
				query = queryFactory.createQuery(ADQLVersion.V2_1);
				stackQuery.push(query);
			} catch(Exception ex) {
				{
+23 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ package adql.parser;
import java.util.Collection;

import adql.db.FunctionDef;
import adql.parser.ADQLParserFactory.ADQLVersion;
import adql.parser.IdentifierItems.IdentifierItem;
import adql.query.ADQLOrder;
import adql.query.ADQLQuery;
@@ -88,7 +89,7 @@ import adql.query.operand.function.string.LowerFunction;
 * </p>
 *
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 2.0 (04/2019)
 * @version 2.0 (07/2019)
 *
 * @see ADQLParser
 */
@@ -111,10 +112,30 @@ public class ADQLQueryFactory {
		;
	}

	public ADQLQuery createQuery() throws Exception {
	/**
	 * @deprecated Since v2.0, {@link #createQuery(ADQLVersion)} must be
	 *             used/extended instead. */
	@Deprecated
	public final ADQLQuery createQuery() throws Exception {
		return new ADQLQuery();
	}

	/**
	 * Create an instance of {@link ADQLQuery}.
	 *
	 * @param version	The version of the ADQL grammar followed by the query to
	 *               	create.
	 *
	 * @return	A new {@link ADQLQuery}.
	 *
	 * @throws Exception	If any error occurs while creating a new query.
	 *
	 * @since 2.0
	 */
	public ADQLQuery createQuery(final ADQLVersion version) throws Exception {
		return new ADQLQuery(version);
	}

	public ADQLTable createTable(final IdentifierItems idItems, final IdentifierItem alias) throws Exception {
		ADQLTable t = new ADQLTable(idItems.getCatalog(), idItems.getSchema(), idItems.getTable());

Loading