use of org.teiid.query.metadata.QueryMetadataInterface 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 });
}
use of org.teiid.query.metadata.QueryMetadataInterface 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);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestAuthorizationValidationVisitor method testFunction.
@Test
public void testFunction() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
// $NON-NLS-1$
helpTest("SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1);
// $NON-NLS-1$
helpTest("SELECT e1, curdate() FROM pm1.g2 where xyz() > 0", metadata, new String[] { "xyz()" }, RealMetadataFactory.example1VDB(), exampleAuthSvc2);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestOptimizer method testPushFunctionInSelect2.
@Test
public void testPushFunctionInSelect2() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// Add join capability to pm1
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"SELECT lower(e1), upper(e1), e2 FROM pm1.g1 WHERE upper(e1) = 'X'", metadata, null, capFinder, // $NON-NLS-1$
new String[] { "SELECT lower(e1), upper(e1), e2 FROM pm1.g1 WHERE ucase(e1) = 'X'" }, SHOULD_SUCCEED);
checkNodeTypes(plan, FULL_PUSHDOWN);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestOptimizer method helpTestUnionPushdown.
public void helpTestUnionPushdown(boolean queryHasOrderBy, boolean hasUnionCapability, boolean hasUnionOrderByCapability) {
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_UNION, hasUnionCapability);
caps.setCapabilitySupport((Capability.QUERY_ORDERBY), hasUnionOrderByCapability);
caps.setCapabilitySupport((Capability.QUERY_SET_ORDER_BY), hasUnionOrderByCapability);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
// $NON-NLS-1$
String sqlUnion = "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB";
// $NON-NLS-1$
String sqlOrderBy = sqlUnion + " ORDER BY IntKey";
String sql = null;
if (queryHasOrderBy) {
sql = sqlOrderBy;
} else {
sql = sqlUnion;
}
String[] expectedSql = null;
if (hasUnionCapability) {
if (queryHasOrderBy && hasUnionOrderByCapability) {
expectedSql = new String[] { sqlOrderBy };
} else {
expectedSql = new String[] { sqlUnion };
}
} else {
// $NON-NLS-1$//$NON-NLS-2$
expectedSql = new String[] { "SELECT IntKey FROM BQT1.SmallA", "SELECT IntKey FROM BQT1.SmallB" };
}
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, expectedSql, SHOULD_SUCCEED);
int accessCount = hasUnionCapability ? 1 : 2;
int projectCount = 0;
int sortCount = 0;
if (queryHasOrderBy && !(hasUnionCapability && hasUnionOrderByCapability)) {
sortCount = 1;
}
int unionCount = hasUnionCapability ? 0 : 1;
checkNodeTypes(plan, new int[] { // Access
accessCount, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
projectCount, // Select
0, // Sort
sortCount, // UnionAll
unionCount });
}
Aggregations