Search in sources :

Example 46 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager 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 47 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.

the class TestTPCR method testQueryCase3047.

/**
 * Test of case 3047 - need a query planner optimization to recognize when join clause criteria
 * could be migrated to WHERE clause of an atomic query, as long as the join is not being pushed
 * down.  In this case, there is a left outer join.  The join criteria includes
 * O_ORDERDATE < {ts'1992-01-02 00:00:00.0'} which is on the inner side of the outer join and
 * thus cannot normally be moved to the WHERE clause.  However, since the join is cross-data
 * source, the join will be performed in MetaMatrix, and the above criteria could be moved to
 * the WHERE clause of the atomic query, since that WHERE clause will effectively still be
 * applied before the join is processed, and the results will be the same.  This is what the
 * user wants to happen.
 * @throws Exception
 */
public void testQueryCase3047() throws Exception {
    FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
    // $NON-NLS-1$
    finder.addCapabilities("TPCR_Ora", oracleCapabilities());
    // $NON-NLS-1$
    finder.addCapabilities("TPCR_SQLS", sqlServerCapabilities());
    HardcodedDataManager dataMgr = new HardcodedDataManager();
    List<?>[] oracleExpected = new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    Arrays.asList(new Object[] { new Long(5), "Bill", "101 Fake St.", "392839283", "21.12" }), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    Arrays.asList(new Object[] { new Long(6), "Stu", "102 Fake St.", "385729385", "51.50" }) };
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.C_CUSTKEY AS c_0, g_0.C_NAME AS c_1, g_0.C_ADDRESS AS c_2, g_0.C_PHONE AS c_3, g_0.C_ACCTBAL AS c_4 FROM TPCR_Ora.CUSTOMER AS g_0 WHERE g_0.C_ACCTBAL > 50 ORDER BY c_0", oracleExpected);
    List<?>[] sqlServerExpected = new List<?>[] { Arrays.asList(new Object[] { new Integer(5), new Integer(12), new Long(5) }), Arrays.asList(new Object[] { new Integer(5), new Integer(13), new Long(5) }) };
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.O_CUSTKEY AS c_0, g_0.O_ORDERKEY AS c_1, convert(g_0.O_CUSTKEY, long) AS c_2 FROM TPCR_SQLS.ORDERS AS g_0 WHERE g_0.O_ORDERDATE < {ts'1992-01-02 00:00:00.0'} ORDER BY c_2", sqlServerExpected);
    List<?>[] expected = new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    Arrays.asList(new Object[] { new Long(5), "Bill", "101 Fake St.", "392839283", "21.12", new Integer(12) }), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    Arrays.asList(new Object[] { new Long(5), "Bill", "101 Fake St.", "392839283", "21.12", new Integer(13) }), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    Arrays.asList(new Object[] { new Long(6), "Stu", "102 Fake St.", "385729385", "51.50", null }) };
    doProcess(// $NON-NLS-1$
    BaseQueryTest.createMetadata(UnitTestUtil.getTestDataPath() + "/TPCR_3.vdb"), // $NON-NLS-1$
    "SELECT C_CUSTKEY, C_NAME, C_ADDRESS, C_PHONE, C_ACCTBAL, O_ORDERKEY FROM TPCR_Ora.CUSTOMER " + // $NON-NLS-1$
    "LEFT OUTER JOIN TPCR_SQLS.ORDERS ON C_CUSTKEY = O_CUSTKEY " + // $NON-NLS-1$
    "AND O_ORDERDATE < {ts'1992-01-02 00:00:00.0'} " + // $NON-NLS-1$
    "WHERE (C_ACCTBAL > 50)", finder, dataMgr, expected, DEBUG);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List)

Example 48 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.

the class TestProcedureProcessor method testUDF.

@Test
public void testUDF() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.fromDDL("CREATE VIRTUAL FUNCTION f1(VARIADIC e1 integer) RETURNS integer as return array_length(e1);", "x", "y");
    ProcessorPlan plan = helpGetPlan("select f1(1, 2, 1)", metadata);
    CommandContext cc = TestProcessor.createCommandContext();
    cc.setMetadata(metadata);
    helpProcess(plan, cc, new HardcodedDataManager(), new List[] { Arrays.asList(3) });
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CommandContext(org.teiid.query.util.CommandContext) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 49 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.

the class TestProcedureProcessor method testDynamicCreate.

@Test(expected = TeiidProcessingException.class)
public void testDynamicCreate() throws Exception {
    // $NON-NLS-1$
    String sql = "exec p1(1)";
    TransformationMetadata tm = RealMetadataFactory.fromDDL("create virtual procedure p1(a long) returns (res long) as " + "begin execute immediate 'create local temporary table t (x string)' as res long;  end;", "x", "y");
    ProcessorPlan plan = getProcedurePlan(sql, tm);
    HardcodedDataManager dataManager = new HardcodedDataManager(tm);
    // $NON-NLS-1$
    List[] expected = new List[] {};
    helpTestProcess(plan, expected, dataManager, tm);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) ArrayList(java.util.ArrayList) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 50 with HardcodedDataManager

use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.

the class TestProcedureProcessor method testDynamicClob.

@Test
public void testDynamicClob() throws Exception {
    // $NON-NLS-1$
    String sql = "exec p1()";
    TransformationMetadata tm = RealMetadataFactory.fromDDL("create virtual procedure p1() as " + "begin create local temporary table t (x string); execute immediate cast('select * from t' as clob); end;", "x", "y");
    ProcessorPlan plan = getProcedurePlan(sql, tm);
    HardcodedDataManager dataManager = new HardcodedDataManager(tm);
    // $NON-NLS-1$
    List[] expected = new List[] {};
    helpTestProcess(plan, expected, dataManager, tm);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) ArrayList(java.util.ArrayList) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Aggregations

HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)140 Test (org.junit.Test)134 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)97 List (java.util.List)75 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)63 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)53 ArrayList (java.util.ArrayList)44 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)42 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)29 CommandContext (org.teiid.query.util.CommandContext)19 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)14 Options (org.teiid.query.util.Options)6 BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)5 RegisterRequestParameter (org.teiid.query.processor.RegisterRequestParameter)4 Command (org.teiid.query.sql.lang.Command)4 TupleSource (org.teiid.common.buffer.TupleSource)3 Insert (org.teiid.query.sql.lang.Insert)3 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)2 TeiidProcessingException (org.teiid.core.TeiidProcessingException)2 TeiidSQLException (org.teiid.jdbc.TeiidSQLException)2