use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestProcessor method testCase4531.
@Test
public void testCase4531() {
// $NON-NLS-1$
String sql = "select intkey, intnum from (select intnum as intkey, 1 as intnum from bqt1.smalla union all select intkey, intnum from bqt1.smalla union all select intkey, intnum from bqt2.smalla) x";
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_UNION, true);
caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
// $NON-NLS-1$
capFinder.addCapabilities("BQT2", caps);
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, RealMetadataFactory.exampleBQTCached(), capFinder);
// Run query
// Create expected results
List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(1), new Integer(1) }), Arrays.asList(new Object[] { new Integer(1), new Integer(1) }), Arrays.asList(new Object[] { new Integer(1), new Integer(1) }) };
// Construct data manager with data
HardcodedDataManager dataManager = new HardcodedDataManager();
// $NON-NLS-1$
dataManager.addData(// $NON-NLS-1$
"SELECT g_0.IntKey, g_0.IntNum FROM BQT2.SmallA AS g_0", new List[] { Arrays.asList(new Object[] { new Integer(1), new Integer(1) }) });
// $NON-NLS-1$
dataManager.addData(// $NON-NLS-1$
"SELECT g_1.IntNum AS c_0, 1 AS c_1 FROM BQT1.SmallA AS g_1 UNION ALL SELECT g_0.IntKey AS c_0, g_0.IntNum AS c_1 FROM BQT1.SmallA AS g_0", new List[] { Arrays.asList(new Object[] { new Integer(1), new Integer(1) }), Arrays.asList(new Object[] { new Integer(1), new Integer(1) }) });
helpProcess(plan, dataManager, expected);
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestProcessor method testMultipleAliasInUnionAll.
@Test
public void testMultipleAliasInUnionAll() {
String sql = "SELECT enterprise_id FROM ( " + "SELECT * FROM ( " + " SELECT id, id AS display_id, 103 AS enterprise_id FROM (" + " SELECT 'x' as id, e1 FROM pm1.g1) AS nexted103) as table103Source " + "UNION ALL " + "SELECT 'x', 'x' AS display_id, 101 AS enterprise_id FROM (" + " SELECT 'x', e1 FROM pm1.g1) AS nested101 " + "UNION ALL " + "SELECT 'x', 'x' AS display_id, 100 AS enterprise_id FROM (" + " SELECT 'x', e1 FROM pm1.g1) AS nested100) as tableFrom1stSelect " + "WHERE enterprise_id = 100";
// Create expected results - would expect these to be:
List[] expected = new List[] { Arrays.asList(100) };
// Construct data manager with data
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT 100 FROM pm1.g1 AS g_0", new List[] { Arrays.asList(100) });
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, RealMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder(false));
// Run query
helpProcess(plan, dataManager, expected);
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestProcessor method testPushdownLiteralInSelectUnderAggregate.
@Test
public void testPushdownLiteralInSelectUnderAggregate() {
// $NON-NLS-1$
String sql = "SELECT COUNT(*) FROM (SELECT '' AS y, a.IntKey FROM BQT1.SmallA a union all select '', b.intkey from bqt1.smallb b) AS x";
// Create expected results
List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(30) }) };
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
sampleDataBQT2(dataManager);
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
caps.setCapabilitySupport(Capability.QUERY_UNION, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
// Run query
helpProcess(plan, dataManager, expected);
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestProcessor method testDefect15355d.
@Test
public void testDefect15355d() throws Exception {
// $NON-NLS-1$
String sql = "SELECT StringKey, BigIntegerValue FROM VQT.Defect15355a WHERE StringKey = '0'";
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$ //$NON-NLS-2$
Arrays.asList(new Object[] { "0", new BigInteger("0") }) };
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
sampleDataBQT2a(dataManager);
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
// $NON-NLS-1$
capFinder.addCapabilities("BQT2", caps);
// $NON-NLS-1$
capFinder.addCapabilities("BQT3", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
// Run query
helpProcess(plan, dataManager, expected);
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestProcessor method testDefect15355c.
@Test
public void testDefect15355c() throws Exception {
// $NON-NLS-1$
String sql = "SELECT StringKey, BigIntegerValue FROM VQT.Defect15355 WHERE StringKey = '0'";
// Create expected results
List[] expected = new List[] { // $NON-NLS-1$ //$NON-NLS-2$
Arrays.asList(new Object[] { "0", new BigInteger("0") }) };
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
sampleDataBQT2a(dataManager);
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
// $NON-NLS-1$
capFinder.addCapabilities("BQT2", caps);
// $NON-NLS-1$
capFinder.addCapabilities("BQT3", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
// Run query
helpProcess(plan, dataManager, expected);
}
Aggregations