Skip to content
Snippets Groups Projects
Commit 0ee4525f authored by vforchi's avatar vforchi
Browse files

Merge remote-tracking branch 'upstream/master'

parents dcff1b87 3306decd
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ package adql.query; ...@@ -16,7 +16,7 @@ package adql.query;
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>. * along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2012-2016 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI) * Astronomisches Rechen Institut (ARI)
*/ */
...@@ -35,6 +35,7 @@ import adql.query.operand.ADQLColumn; ...@@ -35,6 +35,7 @@ import adql.query.operand.ADQLColumn;
import adql.query.operand.ADQLOperand; import adql.query.operand.ADQLOperand;
import adql.query.operand.function.DefaultUDF; import adql.query.operand.function.DefaultUDF;
import adql.query.operand.function.geometry.BoxFunction; import adql.query.operand.function.geometry.BoxFunction;
import adql.query.operand.function.geometry.CentroidFunction;
import adql.query.operand.function.geometry.CircleFunction; import adql.query.operand.function.geometry.CircleFunction;
import adql.query.operand.function.geometry.PointFunction; import adql.query.operand.function.geometry.PointFunction;
import adql.query.operand.function.geometry.PolygonFunction; import adql.query.operand.function.geometry.PolygonFunction;
...@@ -46,7 +47,7 @@ import adql.search.ISearchHandler; ...@@ -46,7 +47,7 @@ import adql.search.ISearchHandler;
* <p>The resulting object of the {@link ADQLParser} is an object of this class.</p> * <p>The resulting object of the {@link ADQLParser} is an object of this class.</p>
* *
* @author Gr&eacute;gory Mantelet (CDS;ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 1.4 (03/2016) * @version 1.4 (02/2017)
*/ */
public class ADQLQuery implements ADQLObject { public class ADQLQuery implements ADQLObject {
...@@ -321,7 +322,7 @@ public class ADQLQuery implements ADQLObject { ...@@ -321,7 +322,7 @@ public class ADQLQuery implements ADQLObject {
}else{ }else{
// Create the DBColumn: // Create the DBColumn:
DBColumn col = null; DBColumn col = null;
// ...whose the name will be set with the SELECT item's alias: // ...whose the name will be set with the SELECT item's alias:
if (item.hasAlias()){ if (item.hasAlias()){
if (operand instanceof ADQLColumn && ((ADQLColumn)operand).getDBLink() != null){ if (operand instanceof ADQLColumn && ((ADQLColumn)operand).getDBLink() != null){
col = ((ADQLColumn)operand).getDBLink(); col = ((ADQLColumn)operand).getDBLink();
...@@ -333,11 +334,11 @@ public class ADQLQuery implements ADQLObject { ...@@ -333,11 +334,11 @@ public class ADQLQuery implements ADQLObject {
else{ else{
if (operand instanceof ADQLColumn && ((ADQLColumn)operand).getDBLink() != null) if (operand instanceof ADQLColumn && ((ADQLColumn)operand).getDBLink() != null)
col = ((ADQLColumn)operand).getDBLink(); col = ((ADQLColumn)operand).getDBLink();
if (col == null) else
col = new DefaultDBColumn(item.getName(), null); col = new DefaultDBColumn(item.getName(), null);
} }
/* For columns created by default (from functions and operations generally), /* For columns created by default (from functions and operations generally),
* set the adequate type if known: */ * set the adequate type if known: */
// CASE: Well-defined UDF // CASE: Well-defined UDF
if (operand instanceof DefaultUDF && ((DefaultUDF)operand).getDefinition() != null){ if (operand instanceof DefaultUDF && ((DefaultUDF)operand).getDefinition() != null){
...@@ -345,7 +346,7 @@ public class ADQLQuery implements ADQLObject { ...@@ -345,7 +346,7 @@ public class ADQLQuery implements ADQLObject {
((DefaultDBColumn)col).setDatatype(type); ((DefaultDBColumn)col).setDatatype(type);
} }
// CASE: Point type: // CASE: Point type:
else if (operand instanceof PointFunction) else if (operand instanceof PointFunction || operand instanceof CentroidFunction)
((DefaultDBColumn)col).setDatatype(new DBType(DBDatatype.POINT)); ((DefaultDBColumn)col).setDatatype(new DBType(DBDatatype.POINT));
// CASE: Region type: // CASE: Region type:
else if (operand instanceof RegionFunction || operand instanceof CircleFunction || operand instanceof BoxFunction || operand instanceof PolygonFunction) else if (operand instanceof RegionFunction || operand instanceof CircleFunction || operand instanceof BoxFunction || operand instanceof PolygonFunction)
......
package adql; package adql.query;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
......
package adql; package adql.query;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
...@@ -14,13 +14,6 @@ import org.junit.Test; ...@@ -14,13 +14,6 @@ import org.junit.Test;
import adql.db.DBType; import adql.db.DBType;
import adql.db.DBType.DBDatatype; import adql.db.DBType.DBDatatype;
import adql.db.FunctionDef; import adql.db.FunctionDef;
import adql.query.ADQLObject;
import adql.query.ADQLOrder;
import adql.query.ADQLQuery;
import adql.query.ClauseADQL;
import adql.query.ClauseConstraints;
import adql.query.ClauseSelect;
import adql.query.SelectItem;
import adql.query.constraint.Comparison; import adql.query.constraint.Comparison;
import adql.query.constraint.ComparisonOperator; import adql.query.constraint.ComparisonOperator;
import adql.query.constraint.ConstraintsGroup; import adql.query.constraint.ConstraintsGroup;
...@@ -39,7 +32,10 @@ import adql.query.operand.function.MathFunctionType; ...@@ -39,7 +32,10 @@ import adql.query.operand.function.MathFunctionType;
import adql.query.operand.function.SQLFunction; import adql.query.operand.function.SQLFunction;
import adql.query.operand.function.SQLFunctionType; import adql.query.operand.function.SQLFunctionType;
import adql.query.operand.function.geometry.BoxFunction; import adql.query.operand.function.geometry.BoxFunction;
import adql.query.operand.function.geometry.CentroidFunction;
import adql.query.operand.function.geometry.CircleFunction; import adql.query.operand.function.geometry.CircleFunction;
import adql.query.operand.function.geometry.GeometryFunction;
import adql.query.operand.function.geometry.GeometryFunction.GeometryValue;
import adql.query.operand.function.geometry.PointFunction; import adql.query.operand.function.geometry.PointFunction;
import adql.query.operand.function.geometry.PolygonFunction; import adql.query.operand.function.geometry.PolygonFunction;
import adql.query.operand.function.geometry.RegionFunction; import adql.query.operand.function.geometry.RegionFunction;
...@@ -195,8 +191,10 @@ public class TestADQLQuery { ...@@ -195,8 +191,10 @@ public class TestADQLQuery {
try{ try{
select.clear(); select.clear();
select.add(new PointFunction(new StringConstant(""), new ADQLColumn("ra"), new ADQLColumn("dec"))); select.add(new PointFunction(new StringConstant(""), new ADQLColumn("ra"), new ADQLColumn("dec")));
assertEquals(1, query.getResultingColumns().length); select.add(new CentroidFunction(new GeometryValue<GeometryFunction>(new ADQLColumn("aRegion"))));
assertEquals(DBDatatype.POINT, query.getResultingColumns()[0].getDatatype().type); assertEquals(2, query.getResultingColumns().length);
for(int i = 0; i < 2; i++)
assertEquals(DBDatatype.POINT, query.getResultingColumns()[i].getDatatype().type);
}catch(Exception ex){ }catch(Exception ex){
ex.printStackTrace(); ex.printStackTrace();
fail("The POINT function is well defined. This error should have occurred."); fail("The POINT function is well defined. This error should have occurred.");
......
package adql; package adql.query;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
......
package adql; package adql.query.constraint;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment