use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestMetaDataProcessor method testWindowFunction.
@Test
public void testWindowFunction() throws Exception {
QueryMetadataInterface metadata = TestMetaDataProcessor.examplePrivatePhysicalModel();
// $NON-NLS-1$
String sql = "SELECT min(e1) over () FROM pm1.g2";
MetadataResult response = helpTestQuery(metadata, sql, TestMetaDataProcessor.examplePrivatePhysicalModelVDB());
helpCheckNumericAttributes(response, 0, 21, 19, 4);
// $NON-NLS-1$
assertEquals("e1", response.getColumnMetadata()[0].get(ResultsMetadataConstants.ELEMENT_NAME));
// $NON-NLS-1$
assertEquals("expr1", response.getColumnMetadata()[0].get(ResultsMetadataConstants.ELEMENT_LABEL));
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestPreparedStatement method testCopiedWhere.
@Test
public void testCopiedWhere() throws Exception {
String preparedSql = "SELECT mediuma.bigdecimalvalue as a FROM bqt1.smalla inner join bqt1.mediuma " + "on (smalla.bigdecimalvalue = mediuma.bigdecimalvalue) " + // $NON-NLS-1$
"WHERE smalla.bigdecimalvalue in (?,?) and mediuma.bigdecimalvalue in (1,2)";
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
List<?> values = Arrays.asList(0, 1);
PreparedStatementRequest plan = helpGetProcessorPlan(preparedSql, values, capFinder, metadata, new SessionAwareCache<PreparedPlan>("preparedplan", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.PREPAREDPLAN, 0), SESSION_ID, false, false, RealMetadataFactory.exampleBQTVDB());
TestOptimizer.checkNodeTypes(plan.processPlan, TestOptimizer.FULL_PUSHDOWN);
TestOptimizer.checkAtomicQueries(new String[] { "SELECT g_1.BigDecimalValue FROM BQT1.SmallA AS g_0, BQT1.MediumA AS g_1 WHERE (g_0.BigDecimalValue = g_1.BigDecimalValue) AND (g_0.BigDecimalValue IN (?, ?)) AND (g_0.BigDecimalValue IN (1, 2)) AND (g_1.BigDecimalValue IN (1, 2)) AND (g_1.BigDecimalValue IN (?, ?))" }, plan.processPlan);
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestMultiSourcePlanToProcessConverter method testAggParitioned.
@Test
public void testAggParitioned() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
// $NON-NLS-1$
final String userSql = "SELECT max(phys.a), source_name FROM MultiModel.Phys group by Phys.source_name";
// $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", "a"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Arrays.asList("y", "b") };
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<?>[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
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
0, // 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 testMultiUpdateAll.
@Test
public void testMultiUpdateAll() throws Exception {
final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
// $NON-NLS-1$
final String userSql = "update MultiModel.Phys set a = '1' where b = 'z'";
// $NON-NLS-1$
final String multiModel = "MultiModel";
final int sources = 3;
final List<?>[] expected = new List<?>[] { Arrays.asList(3) };
final MultiSourceDataManager dataMgr = new MultiSourceDataManager();
dataMgr.setMustRegisterCommands(true);
// $NON-NLS-1$
dataMgr.addData("UPDATE MultiModel.Phys SET a = '1' WHERE b = 'z'", new List<?>[] { Arrays.asList(1) });
helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestMultiSourcePlanToProcessConverter method testUnsupportedPredicate.
@Test
public void testUnsupportedPredicate() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
// $NON-NLS-1$
final String userSql = "SELECT phys.a FROM MultiModel.Phys where Phys.source_name like 'a%'";
// $NON-NLS-1$
final String multiModel = "MultiModel";
final int sources = 2;
final List<?>[] expected = new List<?>[] { Arrays.asList("a") };
final HardcodedDataManager dataMgr = new HardcodedDataManager();
// $NON-NLS-1$
dataMgr.addData(// $NON-NLS-1$
"SELECT MultiModel.Phys.a FROM MultiModel.Phys", new List<?>[] { Arrays.asList("a") });
helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB(), null, new Options().implicitMultiSourceJoin(false), new BasicSourceCapabilities());
assertEquals(3, dataMgr.getCommandHistory().size());
}
Aggregations