From 183e660e77ff6fca2d7421aa6a4d2bf93b55dabb Mon Sep 17 00:00:00 2001 From: Tom Arnold Date: Tue, 20 Jan 2015 00:27:49 -0500 Subject: [PATCH] Changed spatial functions to allow pushdown. Fixed issue in MySQL translator that was preventing pushdown. --- .../jdbc/mysql/MySQL5ExecutionFactory.java | 11 +++-- .../function/GeometryFunctionMethods.java | 48 +++++++++++-------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java b/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java index 0fed97a017..676c5ebb35 100644 --- a/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java +++ b/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java @@ -20,8 +20,8 @@ * 02110-1301 USA. */ -package org.teiid.translator.jdbc.mysql; - +package org.teiid.translator.jdbc.mysql; + import java.sql.Blob; import java.sql.CallableStatement; import java.sql.ResultSet; @@ -86,7 +86,7 @@ public List translate(Function function) { return null; } }); - } + } @Override public List getSupportedFunctions() { @@ -107,6 +107,11 @@ public List getSupportedFunctions() { return supportedFunctions; } + @Override + protected boolean usesDatabaseVersion() { + return true; + } + @Override public boolean supportsInlineViews() { return true; diff --git a/engine/src/main/java/org/teiid/query/function/GeometryFunctionMethods.java b/engine/src/main/java/org/teiid/query/function/GeometryFunctionMethods.java index 4e959dbffc..095949d45b 100644 --- a/engine/src/main/java/org/teiid/query/function/GeometryFunctionMethods.java +++ b/engine/src/main/java/org/teiid/query/function/GeometryFunctionMethods.java @@ -28,6 +28,7 @@ import org.teiid.core.types.BlobType; import org.teiid.core.types.ClobType; import org.teiid.core.types.GeometryType; +import org.teiid.metadata.FunctionMethod.PushDown; import org.teiid.query.function.metadata.FunctionCategoryConstants; import org.teiid.translator.SourceSystemFunctions; @@ -49,78 +50,85 @@ public static BlobType asBlob(GeometryType geometry) { } @TeiidFunction(name=SourceSystemFunctions.ST_GEOMFROMBINARY, - category=FunctionCategoryConstants.GEOMETRY, - nullOnNull=true) + category=FunctionCategoryConstants.GEOMETRY, + nullOnNull=true) public static GeometryType geoFromBlob(BlobType wkb) throws FunctionExecutionException { return GeometryUtils.geometryFromBlob(wkb); } @TeiidFunction(name=SourceSystemFunctions.ST_GEOMFROMBINARY, - category=FunctionCategoryConstants.GEOMETRY, - nullOnNull=true) + category=FunctionCategoryConstants.GEOMETRY, + nullOnNull=true) public static GeometryType geoFromBlob(BlobType wkb, int srid) throws FunctionExecutionException { return GeometryUtils.geometryFromBlob(wkb, srid); } @TeiidFunction(name=SourceSystemFunctions.ST_GEOMFROMTEXT, - category=FunctionCategoryConstants.GEOMETRY, - nullOnNull=true) + category=FunctionCategoryConstants.GEOMETRY, + nullOnNull=true) public static GeometryType geomFromText(ClobType wkt) throws FunctionExecutionException { return GeometryUtils.geometryFromClob(wkt); } @TeiidFunction(name=SourceSystemFunctions.ST_GEOMFROMTEXT, - category=FunctionCategoryConstants.GEOMETRY, - nullOnNull=true) + category=FunctionCategoryConstants.GEOMETRY, + nullOnNull=true) public static GeometryType geomFromText(ClobType wkt, int srid) throws FunctionExecutionException { return GeometryUtils.geometryFromClob(wkt, srid); } @TeiidFunction(name=SourceSystemFunctions.ST_INTERSECTS, category=FunctionCategoryConstants.GEOMETRY, - nullOnNull=true) + nullOnNull=true, + pushdown=PushDown.CAN_PUSHDOWN) public static Boolean intersects(GeometryType geom1, GeometryType geom2) throws FunctionExecutionException { return GeometryUtils.intersects(geom1, geom2); } @TeiidFunction(name=SourceSystemFunctions.ST_CONTAINS, category=FunctionCategoryConstants.GEOMETRY, - nullOnNull=true) + nullOnNull=true, + pushdown=PushDown.CAN_PUSHDOWN) public static Boolean contains(GeometryType geom1, GeometryType geom2) throws FunctionExecutionException { return GeometryUtils.contains(geom1, geom2); } @TeiidFunction(name=SourceSystemFunctions.ST_CROSSES, - category=FunctionCategoryConstants.GEOMETRY, - nullOnNull=true) + category=FunctionCategoryConstants.GEOMETRY, + nullOnNull=true, + pushdown=PushDown.CAN_PUSHDOWN) public static Boolean crosses(GeometryType geom1, GeometryType geom2) throws FunctionExecutionException { return GeometryUtils.crosses(geom1, geom2); } @TeiidFunction(name=SourceSystemFunctions.ST_DISJOINT, - category=FunctionCategoryConstants.GEOMETRY, - nullOnNull=true) + category=FunctionCategoryConstants.GEOMETRY, + nullOnNull=true, + pushdown=PushDown.CAN_PUSHDOWN) public static Boolean disjoint(GeometryType geom1, GeometryType geom2) throws FunctionExecutionException { return GeometryUtils.disjoint(geom1, geom2); } @TeiidFunction(name=SourceSystemFunctions.ST_DISTANCE, - category=FunctionCategoryConstants.GEOMETRY, - nullOnNull=true) + category=FunctionCategoryConstants.GEOMETRY, + nullOnNull=true, + pushdown=PushDown.CAN_PUSHDOWN) public static Double distance(GeometryType geom1, GeometryType geom2) throws FunctionExecutionException { return GeometryUtils.distance(geom1, geom2); } @TeiidFunction(name=SourceSystemFunctions.ST_OVERLAPS, - category=FunctionCategoryConstants.GEOMETRY, - nullOnNull=true) + category=FunctionCategoryConstants.GEOMETRY, + nullOnNull=true, + pushdown=PushDown.CAN_PUSHDOWN) public static Boolean overlaps(GeometryType geom1, GeometryType geom2) throws FunctionExecutionException { return GeometryUtils.overlaps(geom1, geom2); } @TeiidFunction(name=SourceSystemFunctions.ST_TOUCHES, - category=FunctionCategoryConstants.GEOMETRY, - nullOnNull=true) + category=FunctionCategoryConstants.GEOMETRY, + nullOnNull=true, + pushdown=PushDown.CAN_PUSHDOWN) public static Boolean touches(GeometryType geom1, GeometryType geom2) throws FunctionExecutionException { return GeometryUtils.touches(geom1, geom2); }