Search in sources :

Example 16 with HardcodedDataManager

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

the class TestMultiSourcePlanToProcessConverter method testAggNotParitioned.

@Test
public void testAggNotParitioned() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT max(phys.a) FROM MultiModel.Phys";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("y") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT MAX(g_0.a) FROM MultiModel.Phys AS g_0", new List<?>[] { Arrays.asList("y") });
    ProcessorPlan plan = helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    3, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    1, // NestedLoopJoinStrategy
    0, // MergeJoinStrategy
    0, // Null
    0, // PlanExecution
    0, // Project
    1, // Select
    0, // Sort
    0, // UnionAll
    1 });
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 17 with HardcodedDataManager

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

the class TestMultiSourcePlanToProcessConverter method testMultiReplacementWithLimit1.

@Test
public void testMultiReplacementWithLimit1() throws Exception {
    final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
    // $NON-NLS-1$
    final String userSql = "SELECT a, b FROM MultiModel.Phys limit 1, 1";
    // $NON-NLS-1$
    final String multiModel = "MultiModel";
    final int sources = 2;
    final List<?>[] expected = new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("x", "z") };
    final HardcodedDataManager dataMgr = new HardcodedDataManager();
    // $NON-NLS-1$
    dataMgr.addData(// $NON-NLS-1$
    "SELECT g_0.a AS c_0, g_0.b AS c_1 FROM MultiModel.Phys AS g_0 LIMIT 2", new List<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("y", "z"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Arrays.asList("x", "z") });
    RelationalPlan plan = (RelationalPlan) helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
    assertTrue(plan.getRootNode() instanceof LimitNode);
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) LimitNode(org.teiid.query.processor.relational.LimitNode) List(java.util.List) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Test(org.junit.Test)

Example 18 with HardcodedDataManager

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

the class TestAuthorizationValidationVisitor method testCreateForeignTemp.

@Test
public void testCreateForeignTemp() throws Exception {
    DataPolicyMetadata dpm = exampleAuthSvc1();
    dpm.setAllowCreateTemporaryTables(false);
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("create foreign temporary table x (id string) on bqt1", RealMetadataFactory.exampleBQTCached(), new String[] { "x" }, RealMetadataFactory.exampleBQTVDB(), dpm);
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("create foreign temporary table x (id string) on bqt1", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB(), examplePolicyBQT());
    TempTableTestHarness harness = new TempTableTestHarness();
    harness.setUp(RealMetadataFactory.exampleBQTCached(), new HardcodedDataManager());
    harness.execute("create foreign temporary table x (id string) on bqt1", new List[] { Arrays.asList(0) });
    helpTest("insert into x (id) values ('a')", harness.getMetadata(), new String[] { "x.id" }, RealMetadataFactory.exampleBQTVDB(), dpm);
    // we have create on bqt1
    helpTest("insert into x (id) values ('a')", harness.getMetadata(), new String[] {}, RealMetadataFactory.exampleBQTVDB(), examplePolicyBQT());
    // we don't have read on bqt1
    helpTest("select * from x", harness.getMetadata(), new String[] { "x.id" }, RealMetadataFactory.exampleBQTVDB(), examplePolicyBQT());
}
Also used : TempTableTestHarness(org.teiid.query.processor.TempTableTestHarness) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) DataPolicyMetadata(org.teiid.adminapi.impl.DataPolicyMetadata) Test(org.junit.Test)

Example 19 with HardcodedDataManager

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

the class TestCallableStatement method testProcedurePlanCaching.

@Test
public void testProcedurePlanCaching() throws Exception {
    // $NON-NLS-1$
    String sql = "{? = call BQT_V.v_spTest9(?)}";
    List values = new ArrayList();
    values.add(1);
    List[] expected = new List[1];
    expected[0] = Arrays.asList(1);
    HardcodedDataManager dataManager = new HardcodedDataManager();
    dataManager.addData("ret = EXEC pm4.spTest9(1)", expected);
    TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, RealMetadataFactory.exampleBQTCached(), true, RealMetadataFactory.exampleBQTVDB());
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 20 with HardcodedDataManager

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

the class TestCallableStatement method testInvalidReturn.

@Test(expected = QueryResolverException.class)
public void testInvalidReturn() throws Exception {
    // $NON-NLS-1$
    String sql = "{? = call pm2.spTest8(?, ?)}";
    List values = Arrays.asList(2);
    List[] expected = new List[0];
    HardcodedDataManager dataManager = new HardcodedDataManager();
    TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, RealMetadataFactory.exampleBQTCached(), true, RealMetadataFactory.exampleBQTVDB());
}
Also used : HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ArrayList(java.util.ArrayList) List(java.util.List) 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