Skip to content

Commit

Permalink
Changed spatial functions to allow pushdown. Fixed issue in MySQL tra…
Browse files Browse the repository at this point in the history
…nslator that was preventing pushdown.
  • Loading branch information
Tom9729 committed Jan 20, 2015
1 parent 42dc924 commit 183e660
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -86,7 +86,7 @@ public List<?> translate(Function function) {
return null;
}
});
}
}

@Override
public List<String> getSupportedFunctions() {
Expand All @@ -107,6 +107,11 @@ public List<String> getSupportedFunctions() {
return supportedFunctions;
}

@Override
protected boolean usesDatabaseVersion() {
return true;
}

@Override
public boolean supportsInlineViews() {
return true;
Expand Down
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down

0 comments on commit 183e660

Please sign in to comment.