Search in sources :

Example 1 with OracleExecutionFactory

use of org.teiid.translator.jdbc.oracle.OracleExecutionFactory in project teiid by teiid.

the class TestDynamicImportedMetaData method testImportFunction.

@Test
public void testImportFunction() throws Exception {
    MetadataFactory mf = createMetadataFactory("x", new Properties());
    Table dup = mf.addTable("dup");
    mf.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup);
    MetadataStore ms = mf.asMetadataStore();
    server.deployVDB("test", ms);
    // $NON-NLS-1$
    Connection conn = server.createConnection("jdbc:teiid:test");
    Properties importProperties = new Properties();
    importProperties.setProperty(NativeMetadataRepository.IMPORT_PUSHDOWN_FUNCTIONS, Boolean.TRUE.toString());
    mf = createMetadataFactory("test", importProperties);
    NativeMetadataRepository nmr = new NativeMetadataRepository();
    OracleExecutionFactory oef = new OracleExecutionFactory();
    oef.start();
    DataSource ds = Mockito.mock(DataSource.class);
    Mockito.stub(ds.getConnection()).toReturn(conn);
    nmr.loadMetadata(mf, oef, ds);
    Map<String, FunctionMethod> functions = mf.asMetadataStore().getSchemas().get("TEST").getFunctions();
    assertEquals(18, functions.size());
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) OracleExecutionFactory(org.teiid.translator.jdbc.oracle.OracleExecutionFactory) Table(org.teiid.metadata.Table) MetadataFactory(org.teiid.metadata.MetadataFactory) NativeMetadataRepository(org.teiid.query.metadata.NativeMetadataRepository) Connection(java.sql.Connection) FunctionMethod(org.teiid.metadata.FunctionMethod) Properties(java.util.Properties) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 2 with OracleExecutionFactory

use of org.teiid.translator.jdbc.oracle.OracleExecutionFactory in project teiid by teiid.

the class TestTPCR method testMultiLevelCorrelationWithSubqueryMergeJoin.

public void testMultiLevelCorrelationWithSubqueryMergeJoin() throws Exception {
    FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
    String ddl = ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("tpch.ddl"));
    TransformationMetadata tm = RealMetadataFactory.fromDDL("x", new RealMetadataFactory.DDLHolder("tpch1", ddl), new RealMetadataFactory.DDLHolder("tpch2", ddl));
    OracleExecutionFactory oef = new OracleExecutionFactory();
    oef.setDatabaseVersion(Version.getVersion("11.0"));
    SourceCapabilities bsc1 = CapabilitiesConverter.convertCapabilities(oef, 1);
    SourceCapabilities bsc2 = CapabilitiesConverter.convertCapabilities(oef, 2);
    // $NON-NLS-1$
    finder.addCapabilities("tpch1", bsc1);
    // $NON-NLS-1$
    finder.addCapabilities("tpch2", bsc2);
    HardcodedDataManager dm = new HardcodedDataManager(tm);
    dm.addData("SELECT g_0.\"S_SUPPLIERKEY\" AS c_0, g_0.\"S_NAME\" AS c_1, g_0.\"S_ADDRESS\" AS c_2 FROM \"SOAEDS\".\"SUPPLIER\" AS g_0, \"SOAEDS\".\"NATION\" AS g_1 WHERE g_0.\"S_NATIONKEY\" = g_1.\"N_NATIONKEY\" AND g_1.\"N_NAME\" = 'BRAZIL' ORDER BY c_0", Arrays.asList(1, "x", "y"));
    dm.addData("SELECT g_0.\"PS_SUPPLIERKEY\" AS c_0 FROM \"SOAEDS\".\"PARTSUPP\" AS g_0 WHERE g_0.\"PS_PARTKEY\" IN (SELECT g_1.\"P_PARTKEY\" FROM \"SOAEDS\".\"PART\" AS g_1 WHERE g_1.\"P_NAME\" LIKE 'powder%') AND g_0.\"PS_AVAILQTY\" > (SELECT (0.5 * SUM(g_2.\"L_QUANTITY\")) FROM \"SOAEDS\".\"LINEITEM\" AS g_2 WHERE g_2.\"L_PARTKEY\" = g_0.\"PS_PARTKEY\" AND g_2.\"L_SUPPLIERKEY\" = g_0.\"PS_SUPPLIERKEY\" AND g_2.\"L_SHIPDATE\" >= {ts '1994-01-01 00:00:00.0'} AND g_2.\"L_SHIPDATE\" < {ts '1995-01-01 00:00:00.0'}) ORDER BY c_0", Arrays.asList(1));
    String sql = "select s_name, s_address from tpch1.soaeds.supplier, tpch1.soaeds.nation where s_supplierkey in ( select ps_supplierkey from tpch2.soaeds.partsupp where ps_partkey in ( select p_partkey from tpch2.soaeds.part where p_name like 'powder%' ) and ps_availqty > ( select 0.5 * sum(l_quantity) from tpch2.soaeds.lineitem where l_partkey = ps_partkey and l_supplierkey = ps_supplierkey and l_shipdate >= '1994-01-01' and l_shipdate < TIMESTAMPADD(SQL_TSI_YEAR,'1', '1994-01-01') ) ) and s_nationkey = n_nationkey and n_name = 'BRAZIL' order by s_name;";
    List<?>[] expected = new List<?>[] { Arrays.asList("x", "y") };
    doProcess(tm, sql, finder, dm, expected, DEBUG);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) OracleExecutionFactory(org.teiid.translator.jdbc.oracle.OracleExecutionFactory) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) SourceCapabilities(org.teiid.query.optimizer.capabilities.SourceCapabilities)

Example 3 with OracleExecutionFactory

use of org.teiid.translator.jdbc.oracle.OracleExecutionFactory in project teiid by teiid.

the class TestTPCR method oracleCapabilities.

public static SourceCapabilities oracleCapabilities() {
    OracleExecutionFactory oef = new OracleExecutionFactory();
    oef.setDatabaseVersion(Version.DEFAULT_VERSION);
    return CapabilitiesConverter.convertCapabilities(oef);
}
Also used : OracleExecutionFactory(org.teiid.translator.jdbc.oracle.OracleExecutionFactory)

Aggregations

OracleExecutionFactory (org.teiid.translator.jdbc.oracle.OracleExecutionFactory)3 Connection (java.sql.Connection)1 List (java.util.List)1 Properties (java.util.Properties)1 DataSource (javax.sql.DataSource)1 Test (org.junit.Test)1 FunctionMethod (org.teiid.metadata.FunctionMethod)1 MetadataFactory (org.teiid.metadata.MetadataFactory)1 MetadataStore (org.teiid.metadata.MetadataStore)1 Table (org.teiid.metadata.Table)1 NativeMetadataRepository (org.teiid.query.metadata.NativeMetadataRepository)1 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)1 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)1 SourceCapabilities (org.teiid.query.optimizer.capabilities.SourceCapabilities)1 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)1 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)1