Search in sources :

Example 16 with ClobType

use of org.teiid.core.types.ClobType in project teiid by teiid.

the class TestTextTable method testTextTableInvalidData.

@Test(expected = TeiidProcessingException.class)
public void testTextTableInvalidData() throws Exception {
    // $NON-NLS-1$
    String sql = "select count(*) from texttable(? COLUMNS PARTNAME string) x";
    FakeDataManager dataManager = new FakeDataManager();
    sampleData1(dataManager);
    char[] data = new char[5000];
    processPreparedStatement(sql, null, dataManager, new DefaultCapabilitiesFinder(), RealMetadataFactory.example1Cached(), Arrays.asList(new ClobType(new SerialClob(data))));
}
Also used : ClobType(org.teiid.core.types.ClobType) SerialClob(javax.sql.rowset.serial.SerialClob) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 17 with ClobType

use of org.teiid.core.types.ClobType in project teiid by teiid.

the class MongoDBSelectVisitor method convertGeometryToJson.

private void convertGeometryToJson(BasicDBObjectBuilder builder, GeometryType object) throws TranslatorException {
    try {
        ClobType clob = GeometryUtils.geometryToGeoJson(object);
        ClobToStringTransform clob2str = new ClobToStringTransform();
        String geometry = (String) clob2str.transform(clob, String.class);
        builder.add("$geometry", geometry);
    } catch (FunctionExecutionException | TransformationException e) {
        throw new TranslatorException(e);
    }
}
Also used : ClobType(org.teiid.core.types.ClobType) TransformationException(org.teiid.core.types.TransformationException) FunctionExecutionException(org.teiid.api.exception.query.FunctionExecutionException) ClobToStringTransform(org.teiid.core.types.basic.ClobToStringTransform) TranslatorException(org.teiid.translator.TranslatorException)

Example 18 with ClobType

use of org.teiid.core.types.ClobType in project teiid by teiid.

the class TestGeometry method testSimplify.

@Test
public void testSimplify() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("ST_AsText(ST_SIMPLIFY(ST_GeomFromText('LINESTRING(1 1,2 2,2 3.5,1 3,1 2,2 1)'), 1))");
    assertEquals("LINESTRING (1 1, 2 3.5, 2 1)", ClobType.getString((ClobType) Evaluator.evaluate(ex)));
    // ensure it creates an empty geometry
    ex = TestFunctionResolving.getExpression("ST_ISEmpty(ST_Simplify(ST_GeomFromText('POLYGON((6 3,1 -2,-4 3,1 8,6 3))'),5))");
    assertTrue((Boolean) Evaluator.evaluate(ex));
}
Also used : ClobType(org.teiid.core.types.ClobType) Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 19 with ClobType

use of org.teiid.core.types.ClobType 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 20 with ClobType

use of org.teiid.core.types.ClobType 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)

Aggregations

ClobType (org.teiid.core.types.ClobType)49 Test (org.junit.Test)31 ClobImpl (org.teiid.core.types.ClobImpl)20 Expression (org.teiid.query.sql.symbol.Expression)16 SQLException (java.sql.SQLException)8 InputStreamFactory (org.teiid.core.types.InputStreamFactory)8 IOException (java.io.IOException)7 BlobType (org.teiid.core.types.BlobType)6 Reader (java.io.Reader)4 Blob (java.sql.Blob)4 ArrayList (java.util.ArrayList)4 SerialBlob (javax.sql.rowset.serial.SerialBlob)4 SerialClob (javax.sql.rowset.serial.SerialClob)4 BlobImpl (org.teiid.core.types.BlobImpl)4 XMLType (org.teiid.core.types.XMLType)4 FunctionExecutionException (org.teiid.api.exception.query.FunctionExecutionException)3 TeiidProcessingException (org.teiid.core.TeiidProcessingException)3 BlobInputStreamFactory (org.teiid.core.types.InputStreamFactory.BlobInputStreamFactory)3 SQLXMLImpl (org.teiid.core.types.SQLXMLImpl)3 ReaderInputStream (org.teiid.core.util.ReaderInputStream)3