Skip to content

Commit

Permalink
TEIID-5499 adding a test that highlights casting
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Oct 11, 2018
1 parent 350e051 commit 9316aab
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import org.junit.Test;
import org.teiid.core.types.BlobType;
import org.teiid.query.metadata.TransformationMetadata;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.unittest.RealMetadataFactory;

Expand Down Expand Up @@ -109,4 +110,21 @@ public class TestJSONProcessing {
helpProcess(plan, fdm, expected);
}

@Test public void testJSONCasts() throws Exception {
TransformationMetadata tm = RealMetadataFactory.fromDDL("create view json as select jsonParse('{}', true) as col", "x", "y");

String sql = "select cast(jsonObject(col) as string), cast(cast(jsonParse(col, true) as clob) as string) from json"; //$NON-NLS-1$

//note in the first results contains the nested json, not a nested string
List<?>[] expected = new List[] {
Arrays.asList("{\"col\":{}}", "{}"),
};
HardcodedDataManager hdm = new HardcodedDataManager();
ProcessorPlan plan = helpGetPlan(sql, tm);
helpProcess(plan, hdm, expected);

//small breaking potential - if we explicitly expect clob results
//tm = RealMetadataFactory.fromDDL("create view json (col clob) as select jsonParse('{}', true) as col", "x", "y");
}

}

0 comments on commit 9316aab

Please sign in to comment.