Search in sources :

Example 66 with Expression

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

the class TestGeometry method testIntersection.

@Test
public void testIntersection() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("ST_AsText(st_intersection(ST_GeomFromText('POLYGON ((0 50, 50 50, 40 0, 0 0, 0 50))'), ST_GeomFromText('POLYGON ((0 50, 40 50, 40 0, 0 0, 0 50))')))");
    ClobType intersection = (ClobType) Evaluator.evaluate(ex);
    assertEquals("POLYGON ((0 50, 40 50, 40 0, 0 0, 0 50))", ClobType.getString(intersection));
    ex = TestFunctionResolving.getExpression("ST_AsText(st_intersection(ST_GeomFromText('POLYGON ((0 50, 50 50, 40 0, 0 0, 0 50))'), ST_GeomFromText('POLYGON ((150 50, 200 50, 190 0, 150 0, 150 50))')))");
    intersection = (ClobType) Evaluator.evaluate(ex);
    assertEquals("POLYGON EMPTY", ClobType.getString(intersection));
}
Also used : ClobType(org.teiid.core.types.ClobType) Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 67 with Expression

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

the class TestGeometry method testOrderingEquals.

@Test
public void testOrderingEquals() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("ST_OrderingEquals(ST_GeomFromText('LINESTRING(0 0, 10 10)'),ST_GeomFromText('LINESTRING(0 0, 0 0, 10 10)'))");
    assertFalse((Boolean) Evaluator.evaluate(ex));
}
Also used : Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 68 with Expression

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

the class TestGeometry method testEndPoint.

@Test
public void testEndPoint() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("ST_AsText(st_endpoint(ST_GEOMFROMTEXT('LINESTRING(0 0, 1 3)'))))");
    assertEquals("POINT (1 3)", 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 69 with Expression

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

the class TestGeometry method testForce2d.

@Test
public void testForce2d() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("st_astext(st_force_2d(ST_GEOMFROMTEXT('LINESTRING(0 0, 1 3)')))");
    assertEquals("LINESTRING (0 0, 1 3)", 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 70 with Expression

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

the class TestGeometry method testTextError.

@Test
public void testTextError() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("ST_GeomFromText('''hello''')");
    try {
        Evaluator.evaluate(ex);
        fail();
    } catch (ExpressionEvaluationException e) {
        assertNull(ExceptionUtil.getExceptionOfType(e, NullPointerException.class));
    }
}
Also used : ExpressionEvaluationException(org.teiid.api.exception.query.ExpressionEvaluationException) 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