Search in sources :

Example 76 with Expression

use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.

the class TestGeometry method testEnvelope.

@Test
public void testEnvelope() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("ST_AsText(ST_Envelope(ST_GEOMFROMTEXT('LINESTRING(0 0, 1 3)')))");
    ClobType c = (ClobType) Evaluator.evaluate(ex);
    assertEquals("POLYGON ((0 0, 0 3, 1 3, 1 0, 0 0))", ClobType.getString(c));
}
Also used : ClobType(org.teiid.core.types.ClobType) Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 77 with Expression

use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.

the class TestGeometry method testStartPoint.

@Test
public void testStartPoint() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("ST_AsText(st_startpoint(ST_GEOMFROMTEXT('LINESTRING(0 0, 1 3)'))))");
    assertEquals("POINT (0 0)", ClobType.getString((ClobType) Evaluator.evaluate(ex)));
}
Also used : ClobType(org.teiid.core.types.ClobType) Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 78 with Expression

use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.

the class TestGeometry method testRelate.

@Test
public void testRelate() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("ST_Relate(ST_GeomFromText('POINT(1 2)'), ST_Buffer(ST_GeomFromText('POINT(1 2)'),2))");
    assertEquals("0FFFFF212", Evaluator.evaluate(ex));
}
Also used : Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 79 with Expression

use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.

the class TestGeometry method testEwkb.

@Test(expected = ExpressionEvaluationException.class)
public void testEwkb() throws Exception {
    WKBWriter writer = new WKBWriter(3, true);
    GeometryFactory gf = new GeometryFactory();
    Point point = gf.createPoint(new Coordinate(0, 0, 0));
    point.setSRID(100);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writer.write(point, new OutputStreamOutStream(baos));
    Expression ex1 = TestFunctionResolving.getExpression("ST_GeomFromBinary(X'" + new BinaryType(baos.toByteArray()) + "', 8307)");
    Evaluator.evaluate(ex1);
}
Also used : WKBWriter(com.vividsolutions.jts.io.WKBWriter) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) BinaryType(org.teiid.core.types.BinaryType) Coordinate(com.vividsolutions.jts.geom.Coordinate) Expression(org.teiid.query.sql.symbol.Expression) Point(com.vividsolutions.jts.geom.Point) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStreamOutStream(com.vividsolutions.jts.io.OutputStreamOutStream) Test(org.junit.Test)

Example 80 with Expression

use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.

the class TestGeometry method testCoordDims.

@Test
public void testCoordDims() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("ST_CoordDim(ST_GEOMFROMTEXT('LINESTRING EMPTY'))");
    assertEquals(2, Evaluator.evaluate(ex));
}
Also used : Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Aggregations

Expression (org.teiid.query.sql.symbol.Expression)257 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)104 ArrayList (java.util.ArrayList)74 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)54 Test (org.junit.Test)53 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)50 List (java.util.List)49 Constant (org.teiid.query.sql.symbol.Constant)38 SymbolMap (org.teiid.query.sql.util.SymbolMap)37 HashMap (java.util.HashMap)22 LinkedList (java.util.LinkedList)22 Criteria (org.teiid.query.sql.lang.Criteria)22 Map (java.util.Map)21 ClobType (org.teiid.core.types.ClobType)16 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)16 HashSet (java.util.HashSet)13 LinkedHashSet (java.util.LinkedHashSet)13 AliasSymbol (org.teiid.query.sql.symbol.AliasSymbol)13 SearchedCaseExpression (org.teiid.query.sql.symbol.SearchedCaseExpression)13 OrderBy (org.teiid.query.sql.lang.OrderBy)12