use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testVarArgs.
@Test
public void testVarArgs() throws Exception {
String ddl = "create foreign procedure proc (x integer, VARIADIC z integer); create virtual procedure vproc (x integer, VARIADIC z integer) returns integer as begin \"return\" = z[2] + array_length(z); call proc(x, z); end;";
TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
// $NON-NLS-1$
String sql = "call vproc(1, 2, 3)";
ProcessorPlan plan = getProcedurePlan(sql, tm);
HardcodedDataManager dataManager = new HardcodedDataManager(tm);
dataManager.addData("EXEC proc(1, 2, 3)", new List<?>[0]);
// Create expected results
// $NON-NLS-1$
List[] expected = new List[] { Arrays.asList(5) };
helpTestProcess(plan, expected, dataManager, tm);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testParameterAssignments.
@Test
public void testParameterAssignments() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.exampleBQTCached();
// $NON-NLS-1$
String userQuery = "EXEC TEIIDSP7(1)";
HardcodedDataManager dataMgr = new HardcodedDataManager();
ProcessorPlan plan = getProcedurePlan(userQuery, metadata);
dataMgr.addData("x = EXEC spTest9(1)", new List[] { Arrays.asList(3) });
dataMgr.addData("EXEC spTest11(3, null)", new List[] { Arrays.asList("1", 1, null), Arrays.asList(null, null, 4) });
List[] expected = new List[] { Arrays.asList("34") };
helpTestProcess(plan, expected, dataMgr, metadata);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testUDFCorrelated.
@Test
public void testUDFCorrelated() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.fromDDL("CREATE VIRTUAL FUNCTION f1(x integer) RETURNS string as return (select e1 from g1 where e2 = x/2);; create foreign table g1 (e1 string, e2 integer);", "x", "y");
ProcessorPlan plan = helpGetPlan("select * from g1, table ( select f1 (g1.e2)) t;", metadata);
CommandContext cc = TestProcessor.createCommandContext();
cc.setMetadata(metadata);
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT y.g1.e1, y.g1.e2 FROM y.g1", Arrays.asList("a", 1), Arrays.asList("b", 2));
hdm.addData("SELECT y.g1.e2, y.g1.e1 FROM y.g1", Arrays.asList(1, "a"), Arrays.asList(2, "b"));
hdm.setBlockOnce(true);
helpProcess(plan, cc, hdm, new List[] { Arrays.asList("a", 1, null), Arrays.asList("b", 2, "a") });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcedureProcessor method testVirtualProcedure16602.
@Test
public void testVirtualProcedure16602() throws Exception {
// $NON-NLS-1$
String userUpdateStr = "EXEC pm1.vsp37()";
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Set up data
HardcodedDataManager dataMgr = new HardcodedDataManager();
dataMgr.addData("INSERT INTO pm1.g1 (e2) VALUES (5)", new List[] { Arrays.asList(1) });
// Create expected results
List[] expected = new List[] { Arrays.asList("1") };
helpTestProcess(plan, expected, dataMgr, metadata);
}
use of org.teiid.query.processor.HardcodedDataManager 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;
}
}
Aggregations