use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestUnionPlanning method partitionedStartSchema.
private TransformationMetadata partitionedStartSchema() throws Exception, TeiidComponentException, QueryMetadataException {
TransformationMetadata tm = RealMetadataFactory.fromDDL("x", new RealMetadataFactory.DDLHolder("source1", "create foreign table fact (id integer, dim_id1 integer, dim_id2 integer);" + "create foreign table dim1 (id integer, val string);" + "create foreign table dim2 (id integer, val string);"), new RealMetadataFactory.DDLHolder("source2", "create foreign table fact (id integer, dim_id1 integer, dim_id2 integer);" + "create foreign table dim1 (id integer, val string);" + "create foreign table dim2 (id integer, val string);"), new RealMetadataFactory.DDLHolder("v", "create view combined_fact as select id, dim_id1, dim_id2, 1 as part from source1.fact union all select id, dim_id1, dim_id2, 2 as part from source2.fact;" + "create view combined_dim1 as select id, val, 1 as part from source1.dim1 union all select id, val, 2 as part from source2.dim1;" + "create view combined_dim2 as select id, val, 1 as part from source1.dim2 union all select id, val, 2 as part from source2.dim2;"));
tm.getModelID("v").setProperty("implicit_partition.columnName", "part");
return tm;
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestLimit method testPushSortOverAliases.
@Test
public void testPushSortOverAliases() throws Exception {
String sql = "select column_a, column_b from (select sum(column_a) over (partition by key_column) as column_a, key_column from a ) a left outer join ( " + " select sum(column_b) over (partition by key_column) as column_b, key_column from b) b on a.key_column = b.key_column order by column_a desc limit 10";
TransformationMetadata tm = RealMetadataFactory.fromDDL("create foreign table a (column_a integer, key_column string primary key);" + " create foreign table b (column_b integer, key_column string primary key);", "x", "y");
ProcessorPlan plan = TestOptimizer.helpPlan(sql, tm, new String[] { "SELECT g_0.key_column, g_0.column_b FROM y.b AS g_0", "SELECT g_0.key_column, g_0.column_a FROM y.a AS g_0" }, TestOptimizer.getGenericFinder(false), ComparisonMode.EXACT_COMMAND_STRING);
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT g_0.key_column, g_0.column_a FROM y.a AS g_0", Arrays.asList("a", 1));
hdm.addData("SELECT g_0.key_column, g_0.column_b FROM y.b AS g_0", Arrays.asList("a", 1));
TestProcessor.helpProcess(plan, hdm, new List[] { Arrays.asList(1l, 1l) });
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestHotrodExecution method setup.
@BeforeClass
public static void setup() throws Exception {
TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT-5"));
SERVER = new HotRodTestServer(PORT);
MetadataFactory mf = TestProtobufMetadataProcessor.protoMatadata("tables.proto");
EF = new InfinispanExecutionFactory();
TransformationMetadata tm = TestProtobufMetadataProcessor.getTransformationMetadata(mf, EF);
// String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
// System.out.println(ddl);
METADATA = new RuntimeMetadataImpl(tm);
UTILITY = new TranslationUtility(tm);
InfinispanConnection connection = SERVER.getConnection();
// only use G2 & G4 as cache only support single id
connection.registerProtobufFile(new ProtobufResource("tables.proto", ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("tables.proto"))));
EC = Mockito.mock(ExecutionContext.class);
Mockito.stub(EC.getBatchSize()).toReturn(512);
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestIckleConversionVisitor method helpExecute.
private IckleConversionVisitor helpExecute(MetadataFactory mf, String query, String expected) throws Exception {
InfinispanExecutionFactory ef = new InfinispanExecutionFactory();
TransformationMetadata metadata = TestProtobufMetadataProcessor.getTransformationMetadata(mf, ef);
TranslationUtility utility = new TranslationUtility(metadata);
Select cmd = (Select) utility.parseCommand(query);
IckleConversionVisitor visitor = new IckleConversionVisitor(new RuntimeMetadataImpl(metadata), false);
visitor.visitNode(cmd);
if (!visitor.exceptions.isEmpty()) {
throw visitor.exceptions.get(0);
}
String actual = visitor.getQuery();
assertEquals(expected, actual);
return visitor;
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestProtobufMetadataProcessor method testTableWireFormat.
@Test
public void testTableWireFormat() throws Exception {
MetadataFactory mf = protoMatadata("tables.proto");
InfinispanExecutionFactory ef = new InfinispanExecutionFactory();
TransformationMetadata metadata = getTransformationMetadata(mf, ef);
TreeMap<Integer, TableWireFormat> map = MarshallerBuilder.getWireMap(mf.getSchema().getTable("G2"), new RuntimeMetadataImpl(metadata));
String expected = "{8=TableWireFormat [expectedTag=8, attributeName=e1, nested=null], " + "18=TableWireFormat [expectedTag=18, attributeName=e2, nested=null], " + "42=TableWireFormat [expectedTag=42, attributeName=pm1.G3, nested={" + "8=TableWireFormat [expectedTag=8, attributeName=pm1.G2/pm1.G3/e1, nested=null], " + "18=TableWireFormat [expectedTag=18, attributeName=pm1.G2/pm1.G3/e2, nested=null]}], " + "50=TableWireFormat [expectedTag=50, attributeName=pm1.G4, nested={" + "8=TableWireFormat [expectedTag=8, attributeName=pm1.G2/pm1.G4/e1, nested=null], " + "18=TableWireFormat [expectedTag=18, attributeName=pm1.G2/pm1.G4/e2, nested=null]}], " + "58=TableWireFormat [expectedTag=58, attributeName=e5, nested=null], " + "65=TableWireFormat [expectedTag=65, attributeName=e6, nested=null]}";
assertEquals(expected, map.toString());
}
Aggregations