Search in sources :

Example 96 with TransformationMetadata

use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.

the class TestProcedureProcessor method testDynamicCommandRecursion.

@Test
public void testDynamicCommandRecursion() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    addProc(metadata, "sq2", // $NON-NLS-1$ //$NON-NLS-2$
    "CREATE VIRTUAL PROCEDURE BEGIN\n" + "execute string 'EXEC pm1.sq2(''First'')' as e1 string, e2 integer; END", new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }, new String[] { "in" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq2('First')";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    helpTestProcessFailure(plan, dataMgr, "TEIID30168 Couldn't execute the dynamic SQL command \"EXECUTE IMMEDIATE 'EXEC pm1.sq2(''First'')' AS e1 string, e2 integer\" with the SQL statement \"EXEC pm1.sq2('First')\" due to: TEIID30347 There is a recursive invocation of group 'pm1.sq2'. Please correct the SQL.", // $NON-NLS-1$
    metadata);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FakeDataManager(org.teiid.query.processor.FakeDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 97 with TransformationMetadata

use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.

the class TestProcedureProcessor method testEvaluatableSelectWithOrderBy1.

@Test
public void testEvaluatableSelectWithOrderBy1() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    StringBuffer procedure = // $NON-NLS-1$
    new StringBuffer("CREATE VIRTUAL PROCEDURE \n").append(// $NON-NLS-1$
    "BEGIN\n").append(// $NON-NLS-1$
    "SELECT param from pm1.g1 union select e1 from pm1.g1 order by param limit 2;\n").append(// $NON-NLS-1$
    "END");
    addProc(metadata, "sq1", procedure.toString(), new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }, new String[] { "param" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq1(1)";
    FakeDataManager dataMgr = exampleDataManager(metadata);
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    helpTestProcess(plan, new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { "1" }), // $NON-NLS-1$
    Arrays.asList(new Object[] { "First" }) }, dataMgr, metadata);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FakeDataManager(org.teiid.query.processor.FakeDataManager) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 98 with TransformationMetadata

use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.

the class TestProcedureProcessor method testTeiid5001.

@Test
public void testTeiid5001() throws Exception {
    ParseInfo.REQUIRE_UNQUALIFIED_NAMES = false;
    try {
        String sql = "SELECT d.id FROM ( SELECT 'l1' as domain ) dim_md_domains_to_load, table(CALL testcase.proc_web_avg_visit_duration_empty(\"domain\" => domain)) x JOIN testcase.dim_md_date_ranges d ON true";
        TransformationMetadata tm = RealMetadataFactory.fromDDL("CREATE VIEW testcase.dim_md_date_ranges AS SELECT 1 as \"id\" union all select 2 " + "CREATE VIRTUAL PROCEDURE proc_web_avg_visit_duration_empty( domain string ) RETURNS (i integer) AS BEGIN select 1; END", "x", "testcase");
        ProcessorPlan plan = getProcedurePlan(sql, tm);
        HardcodedDataManager dataManager = new HardcodedDataManager(tm);
        // $NON-NLS-1$
        List[] expected = new List[] { Arrays.asList(1), Arrays.asList(2) };
        helpTestProcess(plan, expected, dataManager, tm);
    } finally {
        ParseInfo.REQUIRE_UNQUALIFIED_NAMES = true;
    }
}
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 99 with TransformationMetadata

use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.

the class TestProcedureProcessor method testEvaluatableLimit.

@Test
public void testEvaluatableLimit() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.example1();
    StringBuffer procedure = // $NON-NLS-1$
    new StringBuffer("CREATE VIRTUAL PROCEDURE \n").append(// $NON-NLS-1$
    "BEGIN\n").append(// $NON-NLS-1$
    "SELECT e1 from pm1.g1 limit param;\n").append(// $NON-NLS-1$
    "END");
    addProc(metadata, "sq1", procedure.toString(), new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }, new String[] { "param" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
    FakeDataManager dataMgr = exampleDataManager(metadata);
    // $NON-NLS-1$
    String userUpdateStr = "EXEC pm1.sq1(1)";
    ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
    helpTestProcess(plan, new List[] { Arrays.asList(new Object[] { "First" }) }, dataMgr, // $NON-NLS-1$
    metadata);
    // $NON-NLS-1$
    userUpdateStr = "EXEC pm1.sq1(-1)";
    plan = getProcedurePlan(userUpdateStr, metadata);
    try {
        helpTestProcess(plan, new List[] { Arrays.asList(new Object[] { "First" }) }, dataMgr, // $NON-NLS-1$
        metadata);
        fail();
    } catch (QueryValidatorException e) {
    // shouldn't allow -1
    }
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FakeDataManager(org.teiid.query.processor.FakeDataManager) QueryValidatorException(org.teiid.api.exception.query.QueryValidatorException) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 100 with TransformationMetadata

use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.

the class TestProcedureProcessor method testDepJoinFullProcessing.

@Test
public void testDepJoinFullProcessing() throws Exception {
    String sql = " BEGIN" + "\n    create local temporary table ssid_version (sysplex varchar, lpar varchar, ssid varchar, version varchar);" + "\n  insert into ssid_version(sysplex, lpar, ssid, version) values ('plex1', 'ca11', 'd91a', 'v5');" + "\n    insert into ssid_version(sysplex, lpar, ssid, version) values ('plex1', 'ca11', 'd91b', 'v6');" + "\n create local temporary table table_spaces_v5 (sysplex varchar, lpar varchar, ssid varchar, table_space_id varchar);" + "\n    insert into table_spaces_v5 (sysplex, lpar, ssid, table_space_id) values ('plex1', 'ca11', 'd91a', 'ts1');" + "\n create local temporary table table_spaces_v6 (sysplex varchar, lpar varchar, ssid varchar, table_space_id varchar);" + "\n    insert into table_spaces_v6 (sysplex, lpar, ssid, table_space_id) values ('plex1', 'ca11', 'd91b', 'ts2');" + "\n select table_space_id from ( select * from (select v.sysplex, v.lpar, v.ssid, t.table_space_id from ssid_version v join table_spaces_v5 t on t.sysplex=v.sysplex and t.lpar=v.lpar and t.ssid=v.ssid option makedep table_spaces_v5) t" + " union all select * from (select v.sysplex, v.lpar, v.ssid, t.table_space_id from ssid_version v join table_spaces_v6 t on t.sysplex=v.sysplex and t.lpar=v.lpar and t.ssid=v.ssid option makedep table_spaces_v6) t" + " ) t where ssid='d91a';" + // + " raise e.exception;"
    "\n   END";
    TransformationMetadata tm = RealMetadataFactory.example1Cached();
    ProcessorPlan plan = getProcedurePlan(sql, tm);
    HardcodedDataManager dataManager = new HardcodedDataManager(tm);
    dataManager.addData("SELECT g1.e1 FROM g1", new List<?>[] { Arrays.asList("a") });
    // $NON-NLS-1$
    List[] expected = new List[] { Arrays.asList("ts1") };
    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

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