use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class TestGeometry method testPointOnSurface.
@Test
public void testPointOnSurface() throws Exception {
Expression ex = TestFunctionResolving.getExpression("ST_AsText(ST_PointOnSurface(ST_GeomFromText('POLYGON ((67 13, 67 18, 59 18, 59 13, 67 13))')));");
ClobType pointOnSurface = (ClobType) Evaluator.evaluate(ex);
assertEquals("POINT (63 15.5)", ClobType.getString(pointOnSurface));
ex = TestFunctionResolving.getExpression("ST_AsText(ST_PointOnSurface(ST_GeomFromText('POLYGON ((50 0, 50 10, 10 10, 10 50, 50 50, 50 60, 0 60, 0 0, 50 0))')));");
pointOnSurface = (ClobType) Evaluator.evaluate(ex);
assertEquals("POINT (5 30)", ClobType.getString(pointOnSurface));
}
use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class TestGeometry method testEwktWithSRID.
@Test
public void testEwktWithSRID() throws Exception {
Expression ex = TestFunctionResolving.getExpression("st_asewkt(ST_GeomFromEwkt('SRID=4326;POINT(0 0)')))");
Evaluator.evaluate(ex);
// whitespace
ex = TestFunctionResolving.getExpression("st_asewkt(ST_GeomFromEwkt(' SRID=4326;POINT(0 0)')))");
Evaluator.evaluate(ex);
// mixed case
ex = TestFunctionResolving.getExpression("st_asewkt(ST_GeomFromEwkt('SrID=4326;POINT(0 0)')))");
assertEquals("SRID=4326;POINT (0 0)", ClobType.getString((ClobType) Evaluator.evaluate(ex)));
}
use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class TestGeometry method testEwkt.
@Test
public void testEwkt() throws Exception {
Expression ex = TestFunctionResolving.getExpression("st_asewkt(ST_GeomFromEwkt('POINT(0 0 0)')))");
assertEquals("POINT (0 0)", ClobType.getString((ClobType) Evaluator.evaluate(ex)));
}
use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class TestGeometry method testRelatePattern.
@Test
public void testRelatePattern() throws Exception {
Expression ex = TestFunctionResolving.getExpression("ST_Relate(ST_GeomFromText('POINT(1 2)'), ST_Buffer(ST_GeomFromText('POINT(1 2)'),2), '*FF*FF212')");
assertEquals(true, Evaluator.evaluate(ex));
}
use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class HardcodedDataManager method registerRequest.
/**
* @see org.teiid.query.processor.ProcessorDataManager#registerRequest(CommandContext, org.teiid.query.sql.lang.Command, java.lang.String, RegisterRequestParameter)
* @since 4.2
*/
public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
if (modelName != null && validModels != null && !validModels.contains(modelName)) {
// $NON-NLS-1$//$NON-NLS-2$
throw new TeiidComponentException("Detected query against invalid model: " + modelName + ": " + command);
}
this.commandHistory.add(command);
List<Expression> projectedSymbols = command.getProjectedSymbols();
String commandString = null;
if (lbf == null) {
if (command instanceof BatchedUpdateCommand && fullBatchedUpdate) {
commandString = ((BatchedUpdateCommand) command).getStringForm(true);
} else {
commandString = command.toString();
}
} else {
org.teiid.language.Command cmd = lbf.translate(command);
this.pushdownCommands.add(cmd);
commandString = cmd.toString();
}
List<?>[] rows = getData(commandString);
if (rows == null) {
if (mustRegisterCommands) {
// $NON-NLS-1$
throw new TeiidComponentException("Unknown command: " + commandString);
}
// Create one row of nulls
rows = new List[1];
rows[0] = new ArrayList();
for (int i = 0; i < projectedSymbols.size(); i++) {
rows[0].add(null);
}
}
FakeTupleSource source = new FakeTupleSource(projectedSymbols, rows);
if (blockOnce) {
source.setBlockOnce();
}
return source;
}
Aggregations