use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class EvaluatorIterator method init.
@Override
public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException {
super.init(source, options, env);
try {
GroupSymbol gs = null;
String query = options.get(QUERYSTRING);
TransformationMetadata tm = createTransformationMetadata(options.get(DDL));
this.criteria = QueryParser.getQueryParser().parseCriteria(query);
this.elementsInExpression = ElementCollectorVisitor.getElements(this.criteria, false);
for (ElementSymbol es : this.elementsInExpression) {
gs = es.getGroupSymbol();
ResolverUtil.resolveGroup(gs, tm);
}
ResolverVisitor.resolveLanguageObject(this.criteria, tm);
this.evaluatorUtil = new EvaluatorUtil(gs);
} catch (QueryParserException e) {
throw new IOException(e);
} catch (ClassNotFoundException e) {
throw new IOException(e);
} catch (QueryResolverException e) {
throw new IOException(e);
} catch (TeiidComponentException e) {
throw new IOException(e);
}
CommandContext cc = new CommandContext();
this.evaluator = new Evaluator(this.evaluatorUtil.getElementMap(), null, cc);
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestSimpleDBExecution method setup.
@Before
public void setup() throws Exception {
translator = new SimpleDBExecutionFactory();
translator.start();
TransformationMetadata tm = RealMetadataFactory.fromDDL("create foreign table item (\"itemName()\" string, attribute string, somedate timestamp, strarray string[]);", "x", "y");
utility = new TranslationUtility(tm);
connection = Mockito.mock(SimpleDBConnection.class);
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testIN.
@Test
public void testIN() throws Exception {
TransformationMetadata tm = RealMetadataFactory.fromDDL("create foreign table item (\"itemName()\" integer, attribute string);", "x", "y");
TranslationUtility tu = new TranslationUtility(tm);
Command c = tu.parseCommand("select * from item where \"itemName()\" in (1, 2)");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT attribute FROM item WHERE itemName() IN ('1', '2')", visitor.toString());
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testEveryNotNull.
@Test
public void testEveryNotNull() 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) is not null");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
assertEquals("SELECT attribute FROM item WHERE SIMPLEDB.EVERY(attribute) IS NOT NULL", visitor.toString());
}
use of org.teiid.query.metadata.TransformationMetadata in project teiid by teiid.
the class TestSimpleDBSQLVisitor method testOrderByAllow.
@Test
public void testOrderByAllow() throws Exception {
TransformationMetadata tm = RealMetadataFactory.fromDDL("create foreign table item (\"itemName()\" string, attribute string);", "x", "y");
TranslationUtility tu = new TranslationUtility(tm);
Command c = tu.parseCommand("select * from item where \"itemName()\" = 'name' order by \"itemName()\"");
SimpleDBSQLVisitor visitor = new SimpleDBSQLVisitor();
visitor.append(c);
visitor.checkExceptions();
assertEquals("SELECT attribute FROM item WHERE itemName() = 'name' ORDER BY itemName()", visitor.toString());
}
Aggregations