Search in sources :

Example 1 with TransformationMetadata

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);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) QueryParserException(org.teiid.api.exception.query.QueryParserException) CommandContext(org.teiid.query.util.CommandContext) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) TeiidComponentException(org.teiid.core.TeiidComponentException) IOException(java.io.IOException) Evaluator(org.teiid.query.eval.Evaluator) QueryResolverException(org.teiid.api.exception.query.QueryResolverException)

Example 2 with TransformationMetadata

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);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) TranslationUtility(org.teiid.cdk.api.TranslationUtility) SimpleDBExecutionFactory(org.teiid.translator.simpledb.SimpleDBExecutionFactory) SimpleDBConnection(org.teiid.translator.simpledb.api.SimpleDBConnection) Before(org.junit.Before)

Example 3 with TransformationMetadata

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());
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) Command(org.teiid.language.Command) SimpleDBSQLVisitor(org.teiid.translator.simpledb.SimpleDBSQLVisitor) TranslationUtility(org.teiid.cdk.api.TranslationUtility) Test(org.junit.Test)

Example 4 with TransformationMetadata

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());
}
Also used : UDFSource(org.teiid.query.function.UDFSource) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FunctionTree(org.teiid.query.function.FunctionTree) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Command(org.teiid.language.Command) SimpleDBSQLVisitor(org.teiid.translator.simpledb.SimpleDBSQLVisitor) TranslationUtility(org.teiid.cdk.api.TranslationUtility) SimpleDBExecutionFactory(org.teiid.translator.simpledb.SimpleDBExecutionFactory) Test(org.junit.Test)

Example 5 with TransformationMetadata

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());
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) Command(org.teiid.language.Command) SimpleDBSQLVisitor(org.teiid.translator.simpledb.SimpleDBSQLVisitor) TranslationUtility(org.teiid.cdk.api.TranslationUtility) Test(org.junit.Test)

Aggregations

TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)427 Test (org.junit.Test)352 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)163 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)108 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)97 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)89 List (java.util.List)83 CommandContext (org.teiid.query.util.CommandContext)64 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)63 ArrayList (java.util.ArrayList)56 TranslationUtility (org.teiid.cdk.api.TranslationUtility)35 MetadataFactory (org.teiid.metadata.MetadataFactory)35 FakeDataManager (org.teiid.query.processor.FakeDataManager)35 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)35 Schema (org.teiid.metadata.Schema)33 Table (org.teiid.metadata.Table)27 FunctionTree (org.teiid.query.function.FunctionTree)22 Column (org.teiid.metadata.Column)21 Command (org.teiid.language.Command)20 UDFSource (org.teiid.query.function.UDFSource)20