use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testArrayCompare.
@Test
public void testArrayCompare() throws Exception {
SimpleDBExecutionFactory translator = new SimpleDBExecutionFactory();
translator.start();
MetadataFactory mf = TestDDLParser.helpParse("create foreign table item (\"itemName()\" integer, attribute string[]);", "y");
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "x", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions())));
TranslationUtility tu = new TranslationUtility(metadata);
Command c = tu.parseCommand("select * from item where attribute = ('1','2')");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT attribute FROM item WHERE attribute = '1' OR attribute = '2'", visitor.toString());
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testEvery.
@Test
public void testEvery() throws Exception {
SimpleDBExecutionFactory translator = new SimpleDBExecutionFactory();
translator.start();
MetadataFactory mf = TestDDLParser.helpParse("create foreign table item (\"itemName()\" integer, attribute string[]);", "y");
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "x", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions())));
TranslationUtility tu = new TranslationUtility(metadata);
Command c = tu.parseCommand("select * from item where simpledb.every(attribute) = '1'");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT attribute FROM item WHERE SIMPLEDB.EVERY(attribute) = '1'", visitor.toString());
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestPreparedStatementBatchedUpdate method testBatchedUpdatePushdown2.
/**
* Test batch handling when a function cannot be pushed
*/
@Test
public void testBatchedUpdatePushdown2() throws Exception {
// TODO: just use straight ddl
TransformationMetadata metadata = RealMetadataFactory.example1Cached();
// $NON-NLS-1$
String preparedSql = "insert into pm1.g1 (e1) values (? + 1)";
// Create a testable prepared plan cache
SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>("preparedplan", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.PREPAREDPLAN, 0);
// Construct data manager with data
HardcodedDataManager dataManager = new HardcodedDataManager(metadata);
dataManager.addData("INSERT INTO g1 (e1) VALUES ('4')", Arrays.asList(1));
dataManager.addData("INSERT INTO g1 (e1) VALUES ('6')", Arrays.asList(1));
// Source capabilities must support batched updates
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setFunctionSupport(SourceSystemFunctions.CONVERT, false);
caps.setCapabilitySupport(Capability.BULK_UPDATE, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// batch with two commands
ArrayList<ArrayList<Object>> values = new ArrayList<ArrayList<Object>>(2);
// $NON-NLS-1$
values.add(new ArrayList<Object>(Arrays.asList(3)));
values.add(new ArrayList<Object>(Arrays.asList(5)));
List<?>[] expected = new List[] { Arrays.asList(1), Arrays.asList(1) };
// Create the plan and process the query
TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager, capFinder, metadata, prepPlanCache, false, false, false, RealMetadataFactory.example1VDB());
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestMultiSourcePlanToProcessConverter method testGroupByCountPushdownMultiSource.
@Test
public void testGroupByCountPushdownMultiSource() throws Exception {
String userSql = "SELECT s.e1, m.e1, COUNT(*) FROM pm1.g1 AS s INNER JOIN pm2.g2 AS m ON s.e2 = m.e2 GROUP BY s.e1, m.e1";
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT g_0.e2, COUNT(*) FROM pm1.g1 AS g_0 GROUP BY g_0.e2", Arrays.asList(1, 2));
hdm.addData("SELECT g_0.e2 AS c_0, g_0.e1 AS c_1 FROM pm2.g2 AS g_0 ORDER BY c_0", Arrays.asList(1, "other"));
BasicSourceCapabilities bsc = TestAggregatePushdown.getAggregateCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
bsc.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
TransformationMetadata metadata = RealMetadataFactory.example1Cached();
final List<?>[] expected = new List<?>[] { Arrays.asList("a", "other", 2), Arrays.asList("b", "other", 2) };
VDBMetaData vdb = new VDBMetaData();
vdb.setName("exampleMultiBinding");
vdb.setVersion(1);
ModelMetaData model = new ModelMetaData();
model.setName("pm1");
model.setModelType(Model.Type.PHYSICAL);
model.setVisible(true);
model.setSupportsMultiSourceBindings(true);
model.addProperty(MultiSourceMetadataWrapper.MULTISOURCE_COLUMN_NAME, "e1");
vdb.addModel(model);
helpTestMultiSourcePlan(metadata, userSql, "pm1", 2, hdm, expected, vdb, null, new Options().implicitMultiSourceJoin(false), bsc);
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestMetadataFactory method setUp.
@Before
public void setUp() {
MetadataStore metadataStore = new MetadataStore();
CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
VDBMetaData vdbMetaData = new VDBMetaData();
// $NON-NLS-1$
vdbMetaData.setName("foo");
vdbMetaData.setVersion(1);
Map<String, VDBResources.Resource> vdbEntries = new LinkedHashMap<String, VDBResources.Resource>();
vdbEntries.put(MY_RESOURCE_PATH, new VDBResources.Resource(root.getChild("foo")));
metadataFactory = new RuntimeMetadataImpl(new TransformationMetadata(vdbMetaData, store, vdbEntries, null, null));
}
Aggregations