Search in sources :

Example 1 with SimpleDBSQLVisitor

use of org.teiid.translator.simpledb.SimpleDBSQLVisitor 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 2 with SimpleDBSQLVisitor

use of org.teiid.translator.simpledb.SimpleDBSQLVisitor 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 3 with SimpleDBSQLVisitor

use of org.teiid.translator.simpledb.SimpleDBSQLVisitor 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)

Example 4 with SimpleDBSQLVisitor

use of org.teiid.translator.simpledb.SimpleDBSQLVisitor 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());
}
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 SimpleDBSQLVisitor

use of org.teiid.translator.simpledb.SimpleDBSQLVisitor 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());
}
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)

Aggregations

Test (org.junit.Test)14 TranslationUtility (org.teiid.cdk.api.TranslationUtility)14 Command (org.teiid.language.Command)14 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)14 SimpleDBSQLVisitor (org.teiid.translator.simpledb.SimpleDBSQLVisitor)14 MetadataFactory (org.teiid.metadata.MetadataFactory)7 FunctionTree (org.teiid.query.function.FunctionTree)7 UDFSource (org.teiid.query.function.UDFSource)7 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)7 SimpleDBExecutionFactory (org.teiid.translator.simpledb.SimpleDBExecutionFactory)7