Search in sources :

Example 51 with TransformationMetadata

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;
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory)

Example 52 with TransformationMetadata

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) });
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 53 with TransformationMetadata

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);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) ExecutionContext(org.teiid.translator.ExecutionContext) MetadataFactory(org.teiid.metadata.MetadataFactory) RuntimeMetadataImpl(org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl) HotRodTestServer(org.teiid.infinispan.api.HotRodTestServer) TranslationUtility(org.teiid.cdk.api.TranslationUtility) InfinispanConnection(org.teiid.infinispan.api.InfinispanConnection) ProtobufResource(org.teiid.infinispan.api.ProtobufResource) BeforeClass(org.junit.BeforeClass)

Example 54 with TransformationMetadata

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;
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) RuntimeMetadataImpl(org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl) TranslationUtility(org.teiid.cdk.api.TranslationUtility) Select(org.teiid.language.Select)

Example 55 with TransformationMetadata

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());
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) RuntimeMetadataImpl(org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl) TableWireFormat(org.teiid.infinispan.api.TableWireFormat) Test(org.junit.Test)

Aggregations

TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)427 Test (org.junit.Test)352 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)163 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)108 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)97 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)89 List (java.util.List)83 CommandContext (org.teiid.query.util.CommandContext)64 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)63 ArrayList (java.util.ArrayList)56 TranslationUtility (org.teiid.cdk.api.TranslationUtility)35 MetadataFactory (org.teiid.metadata.MetadataFactory)35 FakeDataManager (org.teiid.query.processor.FakeDataManager)35 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)35 Schema (org.teiid.metadata.Schema)33 Table (org.teiid.metadata.Table)27 FunctionTree (org.teiid.query.function.FunctionTree)22 Column (org.teiid.metadata.Column)21 Command (org.teiid.language.Command)20 UDFSource (org.teiid.query.function.UDFSource)20