Search in sources :

Example 81 with Expression

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));
}
Also used : ClobType(org.teiid.core.types.ClobType) Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 82 with Expression

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)));
}
Also used : ClobType(org.teiid.core.types.ClobType) Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 83 with Expression

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)));
}
Also used : ClobType(org.teiid.core.types.ClobType) Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 84 with Expression

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));
}
Also used : Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 85 with Expression

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;
}
Also used : ArrayList(java.util.ArrayList) BatchedUpdateCommand(org.teiid.query.sql.lang.BatchedUpdateCommand) Expression(org.teiid.query.sql.symbol.Expression) TeiidComponentException(org.teiid.core.TeiidComponentException) ArrayList(java.util.ArrayList) List(java.util.List)

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