Search in sources :

Example 1 with Command

use of org.teiid.language.Command in project teiid by teiid.

the class TestAccumuloQueryVisitor method testWhereComapreNOTEQ.

@Test
public void testWhereComapreNOTEQ() throws Exception {
    Command cmd = this.utility.parseCommand("select firstname from Customer where customer_id <> 2");
    AccumuloQueryVisitor visitor = buildVisitor(cmd);
    assertEquals("customer", visitor.getScanTable().getName());
    assertEquals(2, visitor.getRanges().size());
    assertEquals(new Range(null, true, AccumuloQueryVisitor.buildKey(new Integer(2)), false), visitor.getRanges().get(0));
    assertEquals(new Range(AccumuloQueryVisitor.buildKey(new Integer(2)).followingKey(PartialKey.ROW), null, false, true, false, true), visitor.getRanges().get(1));
}
Also used : Command(org.teiid.language.Command) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 2 with Command

use of org.teiid.language.Command in project teiid by teiid.

the class TestAccumuloQueryVisitor method testWhereComapreGTEQ.

@Test
@Ignore
public void testWhereComapreGTEQ() throws Exception {
    Command cmd = this.utility.parseCommand("select firstname from Customer where customer_id >= 2");
    AccumuloQueryVisitor visitor = buildVisitor(cmd);
    assertEquals("customer", visitor.getScanTable().getName());
    assertEquals(1, visitor.getRanges().size());
    assertEquals(new Range(AccumuloQueryVisitor.buildKey(new Integer(2)), true, null, true), visitor.getRanges().get(0));
}
Also used : Command(org.teiid.language.Command) Range(org.apache.accumulo.core.data.Range) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with Command

use of org.teiid.language.Command in project teiid by teiid.

the class TestAccumuloQueryVisitor method testWhereComapreAND1.

@Test
@Ignore
public void testWhereComapreAND1() throws Exception {
    Command cmd = this.utility.parseCommand("select firstname from Customer where customer_id < 2 and customer_id > 4");
    AccumuloQueryVisitor visitor = buildVisitor(cmd);
    assertEquals("customer", visitor.getScanTable().getName());
    assertEquals(2, visitor.getRanges().size());
    Range r1 = new Range(null, true, AccumuloQueryVisitor.buildKey(new Integer(2)), false);
    Range r2 = new Range(AccumuloQueryVisitor.buildKey(new Integer(4)).followingKey(PartialKey.ROW), null, false, true, false, true);
    assertEquals(Range.mergeOverlapping(Arrays.asList(r1, r2)), visitor.getRanges());
}
Also used : Command(org.teiid.language.Command) Range(org.apache.accumulo.core.data.Range) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with Command

use of org.teiid.language.Command in project teiid by teiid.

the class TestAccumuloQueryVisitor method testWhereIN.

@Test
public void testWhereIN() throws Exception {
    Command cmd = this.utility.parseCommand("select firstname from Customer where customer_id IN (1,2)");
    AccumuloQueryVisitor visitor = buildVisitor(cmd);
    assertEquals("customer", visitor.getScanTable().getName());
    assertEquals(2, visitor.getRanges().size());
    assertEquals(AccumuloQueryVisitor.singleRowRange(AccumuloQueryVisitor.buildKey(new Integer(2))), visitor.getRanges().get(0));
    assertEquals(AccumuloQueryVisitor.singleRowRange(AccumuloQueryVisitor.buildKey(new Integer(1))), visitor.getRanges().get(1));
}
Also used : Command(org.teiid.language.Command) Test(org.junit.Test)

Example 5 with Command

use of org.teiid.language.Command in project teiid by teiid.

the class TestAccumuloQueryVisitor method testSelectColumn.

@Test
public void testSelectColumn() throws Exception {
    Command cmd = this.utility.parseCommand("select firstname from Customer");
    AccumuloQueryVisitor visitor = buildVisitor(cmd);
    assertEquals("customer", visitor.getScanTable().getName());
    assertTrue(visitor.getRanges().isEmpty());
    assertNotNull(visitor.projectedColumns());
    List<Column> columns = visitor.projectedColumns();
    assertEquals(1, columns.size());
    Column name = columns.get(0);
    assertEquals("firstName", name.getName());
    assertEquals("customer", name.getProperty(AccumuloMetadataProcessor.CF, false));
    assertEquals("firstNameAttribute", name.getProperty(AccumuloMetadataProcessor.CQ, false));
}
Also used : Command(org.teiid.language.Command) Column(org.teiid.metadata.Column) Test(org.junit.Test)

Aggregations

Command (org.teiid.language.Command)136 Test (org.junit.Test)99 ExecutionContext (org.teiid.translator.ExecutionContext)62 TranslationUtility (org.teiid.cdk.api.TranslationUtility)52 RuntimeMetadata (org.teiid.metadata.RuntimeMetadata)40 CommandBuilder (org.teiid.cdk.CommandBuilder)25 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)20 ResultSetExecution (org.teiid.translator.ResultSetExecution)18 TranslatedCommand (org.teiid.translator.jdbc.TranslatedCommand)17 UpdateExecution (org.teiid.translator.UpdateExecution)16 SimpleDBSQLVisitor (org.teiid.translator.simpledb.SimpleDBSQLVisitor)14 List (java.util.List)11 Connection (java.sql.Connection)10 LdapContext (javax.naming.ldap.LdapContext)9 Range (org.apache.accumulo.core.data.Range)9 SQLConversionVisitor (org.teiid.translator.jdbc.SQLConversionVisitor)9 MetadataFactory (org.teiid.metadata.MetadataFactory)8 ArrayList (java.util.ArrayList)7 FunctionTree (org.teiid.query.function.FunctionTree)7 UDFSource (org.teiid.query.function.UDFSource)7