Search in sources :

Example 1 with TextComparisonOperator

use of org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator in project geowave by locationtech.

the class DeleteStatementTest method testComplexStatement.

@Test
public void testComplexStatement() {
    final DataStore dataStore = createDataStore();
    final Statement statement = GWQLParser.parseStatement(dataStore, "DELETE FROM type " + "WHERE (pop < 1) " + "AND ((pop > 48 OR pid > 'a') AND (pop BETWEEN 0 AND 10 OR pid <= 'b'))");
    assertTrue(statement instanceof DeleteStatement);
    final DeleteStatement<?> deleteStatement = (DeleteStatement<?>) statement;
    assertNotNull(deleteStatement.getAdapter());
    assertEquals("type", deleteStatement.getAdapter().getTypeName());
    assertNotNull(deleteStatement.getFilter());
    final Filter filter = deleteStatement.getFilter();
    assertTrue(filter instanceof And);
    And andFilter = (And) filter;
    assertTrue(andFilter.getChildren().length == 2);
    assertTrue(andFilter.getChildren()[0] instanceof NumericComparisonOperator);
    NumericComparisonOperator compareOp = (NumericComparisonOperator) andFilter.getChildren()[0];
    assertTrue(compareOp.getCompareOp().equals(CompareOp.LESS_THAN));
    assertTrue(compareOp.getExpression1() instanceof NumericFieldValue);
    assertEquals("pop", ((NumericFieldValue) compareOp.getExpression1()).getFieldName());
    assertTrue(compareOp.getExpression2() instanceof NumericLiteral);
    assertEquals(1, ((NumericLiteral) compareOp.getExpression2()).getValue(), 0.00001);
    assertTrue(andFilter.getChildren()[1] instanceof And);
    andFilter = (And) andFilter.getChildren()[1];
    assertTrue(andFilter.getChildren().length == 2);
    assertTrue(andFilter.getChildren()[0] instanceof Or);
    Or orFilter = (Or) andFilter.getChildren()[0];
    assertTrue(orFilter.getChildren().length == 2);
    assertTrue(orFilter.getChildren()[0] instanceof NumericComparisonOperator);
    final NumericComparisonOperator numericCompare = (NumericComparisonOperator) orFilter.getChildren()[0];
    assertTrue(numericCompare.getExpression1() instanceof NumericFieldValue);
    assertEquals("pop", ((NumericFieldValue) numericCompare.getExpression1()).getFieldName());
    assertTrue(numericCompare.getExpression2() instanceof NumericLiteral);
    assertEquals(48, ((NumericLiteral) numericCompare.getExpression2()).evaluateValue(null), 0.00001);
    assertTrue(orFilter.getChildren()[1] instanceof TextComparisonOperator);
    TextComparisonOperator textCompareOp = (TextComparisonOperator) orFilter.getChildren()[1];
    assertTrue(textCompareOp.getCompareOp().equals(CompareOp.GREATER_THAN));
    assertTrue(textCompareOp.getExpression1() instanceof TextFieldValue);
    assertEquals("pid", ((TextFieldValue) textCompareOp.getExpression1()).getFieldName());
    assertTrue(textCompareOp.getExpression2() instanceof TextLiteral);
    assertEquals("a", ((TextLiteral) textCompareOp.getExpression2()).getValue());
    assertTrue(andFilter.getChildren()[1] instanceof Or);
    orFilter = (Or) andFilter.getChildren()[1];
    assertTrue(orFilter.getChildren().length == 2);
    assertTrue(orFilter.getChildren()[0] instanceof NumericBetween);
    NumericBetween between = (NumericBetween) orFilter.getChildren()[0];
    assertTrue(between.getValue() instanceof NumericFieldValue);
    assertEquals("pop", ((NumericFieldValue) between.getValue()).getFieldName());
    assertTrue(between.getLowerBound() instanceof NumericLiteral);
    assertEquals(0, ((NumericLiteral) between.getLowerBound()).getValue(), 0.00001);
    assertTrue(between.getUpperBound() instanceof NumericLiteral);
    assertEquals(10, ((NumericLiteral) between.getUpperBound()).getValue(), 0.00001);
    assertTrue(orFilter.getChildren()[1] instanceof TextComparisonOperator);
    textCompareOp = (TextComparisonOperator) orFilter.getChildren()[1];
    assertTrue(textCompareOp.getCompareOp().equals(CompareOp.LESS_THAN_OR_EQUAL));
    assertTrue(textCompareOp.getExpression1() instanceof TextFieldValue);
    assertEquals("pid", ((TextFieldValue) textCompareOp.getExpression1()).getFieldName());
    assertTrue(textCompareOp.getExpression2() instanceof TextLiteral);
    assertEquals("b", ((TextLiteral) textCompareOp.getExpression2()).getValue());
}
Also used : Or(org.locationtech.geowave.core.store.query.filter.expression.Or) TextComparisonOperator(org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator) NumericLiteral(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericLiteral) NumericComparisonOperator(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericComparisonOperator) DeleteStatement(org.locationtech.geowave.core.store.query.gwql.statement.DeleteStatement) Statement(org.locationtech.geowave.core.store.query.gwql.statement.Statement) NumericBetween(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericBetween) NumericFieldValue(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericFieldValue) DeleteStatement(org.locationtech.geowave.core.store.query.gwql.statement.DeleteStatement) TextFieldValue(org.locationtech.geowave.core.store.query.filter.expression.text.TextFieldValue) Filter(org.locationtech.geowave.core.store.query.filter.expression.Filter) And(org.locationtech.geowave.core.store.query.filter.expression.And) DataStore(org.locationtech.geowave.core.store.api.DataStore) TextLiteral(org.locationtech.geowave.core.store.query.filter.expression.text.TextLiteral) Test(org.junit.Test)

Example 2 with TextComparisonOperator

use of org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator in project geowave by locationtech.

the class SelectStatementTest method testAllColumnsWithFilterAndLimit.

@Test
public void testAllColumnsWithFilterAndLimit() throws ParseException, IOException {
    final DataStore dataStore = createDataStore();
    final String statement = "SELECT * FROM type WHERE pop BETWEEN 1000 AND 2000 and pid > 'abc' LIMIT 1";
    final Statement gwStatement = GWQLParser.parseStatement(dataStore, statement);
    assertTrue(gwStatement instanceof SelectStatement);
    final SelectStatement<?> selectStatement = (SelectStatement<?>) gwStatement;
    assertFalse(selectStatement.isAggregation());
    assertNotNull(selectStatement.getAdapter());
    assertEquals("type", selectStatement.getAdapter().getTypeName());
    assertNotNull(selectStatement.getFilter());
    Filter filter = selectStatement.getFilter();
    assertTrue(filter instanceof And);
    And andFilter = (And) filter;
    assertTrue(andFilter.getChildren().length == 2);
    assertTrue(andFilter.getChildren()[0] instanceof NumericBetween);
    assertTrue(andFilter.getChildren()[1] instanceof TextComparisonOperator);
    assertNotNull(selectStatement.getLimit());
    assertEquals(1, selectStatement.getLimit().intValue());
}
Also used : SelectStatement(org.locationtech.geowave.core.store.query.gwql.statement.SelectStatement) TextComparisonOperator(org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator) Filter(org.locationtech.geowave.core.store.query.filter.expression.Filter) SelectStatement(org.locationtech.geowave.core.store.query.gwql.statement.SelectStatement) Statement(org.locationtech.geowave.core.store.query.gwql.statement.Statement) And(org.locationtech.geowave.core.store.query.filter.expression.And) DataStore(org.locationtech.geowave.core.store.api.DataStore) NumericBetween(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericBetween) Test(org.junit.Test)

Example 3 with TextComparisonOperator

use of org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator in project geowave by locationtech.

the class SelectStatementTest method testAllColumnsWithFilter.

@Test
public void testAllColumnsWithFilter() throws ParseException, IOException {
    final DataStore dataStore = createDataStore();
    final String statement = "SELECT * FROM type WHERE pop BETWEEN 1000 AND 2000 and pid > 'abc'";
    final Statement gwStatement = GWQLParser.parseStatement(dataStore, statement);
    assertTrue(gwStatement instanceof SelectStatement);
    final SelectStatement<?> selectStatement = (SelectStatement<?>) gwStatement;
    assertFalse(selectStatement.isAggregation());
    assertNotNull(selectStatement.getAdapter());
    assertEquals("type", selectStatement.getAdapter().getTypeName());
    assertNotNull(selectStatement.getFilter());
    Filter filter = selectStatement.getFilter();
    assertTrue(filter instanceof And);
    And andFilter = (And) filter;
    assertTrue(andFilter.getChildren().length == 2);
    assertTrue(andFilter.getChildren()[0] instanceof NumericBetween);
    assertTrue(andFilter.getChildren()[1] instanceof TextComparisonOperator);
    assertNull(selectStatement.getLimit());
}
Also used : SelectStatement(org.locationtech.geowave.core.store.query.gwql.statement.SelectStatement) TextComparisonOperator(org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator) Filter(org.locationtech.geowave.core.store.query.filter.expression.Filter) SelectStatement(org.locationtech.geowave.core.store.query.gwql.statement.SelectStatement) Statement(org.locationtech.geowave.core.store.query.gwql.statement.Statement) And(org.locationtech.geowave.core.store.query.filter.expression.And) DataStore(org.locationtech.geowave.core.store.api.DataStore) NumericBetween(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericBetween) Test(org.junit.Test)

Example 4 with TextComparisonOperator

use of org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator in project geowave by locationtech.

the class DeleteStatementTest method testDeleteWithFilter.

@Test
public void testDeleteWithFilter() throws ParseException, IOException {
    final DataStore dataStore = createDataStore();
    final String statement = "DELETE FROM type WHERE pop BETWEEN 1000 AND 2000 and pid > 'abc'";
    final Statement gwStatement = GWQLParser.parseStatement(dataStore, statement);
    assertTrue(gwStatement instanceof DeleteStatement);
    final DeleteStatement<?> deleteStatement = (DeleteStatement<?>) gwStatement;
    assertNotNull(deleteStatement.getAdapter());
    assertEquals("type", deleteStatement.getAdapter().getTypeName());
    assertNotNull(deleteStatement.getFilter());
    final Filter filter = deleteStatement.getFilter();
    assertTrue(filter instanceof And);
    final And andFilter = (And) filter;
    assertTrue(andFilter.getChildren().length == 2);
    assertTrue(andFilter.getChildren()[0] instanceof NumericBetween);
    assertTrue(andFilter.getChildren()[1] instanceof TextComparisonOperator);
}
Also used : TextComparisonOperator(org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator) Filter(org.locationtech.geowave.core.store.query.filter.expression.Filter) DeleteStatement(org.locationtech.geowave.core.store.query.gwql.statement.DeleteStatement) Statement(org.locationtech.geowave.core.store.query.gwql.statement.Statement) And(org.locationtech.geowave.core.store.query.filter.expression.And) DataStore(org.locationtech.geowave.core.store.api.DataStore) NumericBetween(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericBetween) DeleteStatement(org.locationtech.geowave.core.store.query.gwql.statement.DeleteStatement) Test(org.junit.Test)

Example 5 with TextComparisonOperator

use of org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator in project geowave by locationtech.

the class GWQLParserTest method testCasting.

@Test
public void testCasting() {
    final DataStore dataStore = createDataStore();
    String statement = "SELECT * FROM type WHERE pop::text = '15'";
    Statement gwStatement = GWQLParser.parseStatement(dataStore, statement);
    assertTrue(gwStatement instanceof SelectStatement);
    SelectStatement<?> selectStatement = (SelectStatement<?>) gwStatement;
    assertNotNull(selectStatement.getFilter());
    Filter filter = selectStatement.getFilter();
    assertTrue(filter instanceof TextComparisonOperator);
    final TextComparisonOperator textCompare = (TextComparisonOperator) filter;
    assertEquals(CompareOp.EQUAL_TO, textCompare.getCompareOp());
    assertTrue(textCompare.getExpression1() instanceof TextFieldValue);
    assertEquals("pop", ((TextFieldValue) textCompare.getExpression1()).getFieldName());
    assertTrue(textCompare.getExpression2() instanceof TextLiteral);
}
Also used : SelectStatement(org.locationtech.geowave.core.store.query.gwql.statement.SelectStatement) TextComparisonOperator(org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator) Filter(org.locationtech.geowave.core.store.query.filter.expression.Filter) Statement(org.locationtech.geowave.core.store.query.gwql.statement.Statement) SelectStatement(org.locationtech.geowave.core.store.query.gwql.statement.SelectStatement) DataStore(org.locationtech.geowave.core.store.api.DataStore) TextLiteral(org.locationtech.geowave.core.store.query.filter.expression.text.TextLiteral) TextFieldValue(org.locationtech.geowave.core.store.query.filter.expression.text.TextFieldValue) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 Filter (org.locationtech.geowave.core.store.query.filter.expression.Filter)6 TextComparisonOperator (org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator)6 DataStore (org.locationtech.geowave.core.store.api.DataStore)5 And (org.locationtech.geowave.core.store.query.filter.expression.And)5 NumericBetween (org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericBetween)5 Statement (org.locationtech.geowave.core.store.query.gwql.statement.Statement)5 TextFieldValue (org.locationtech.geowave.core.store.query.filter.expression.text.TextFieldValue)3 TextLiteral (org.locationtech.geowave.core.store.query.filter.expression.text.TextLiteral)3 SelectStatement (org.locationtech.geowave.core.store.query.gwql.statement.SelectStatement)3 Or (org.locationtech.geowave.core.store.query.filter.expression.Or)2 Instant (java.time.Instant)1 BBox (org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.BBox)1 Crosses (org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.Crosses)1 Disjoint (org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.Disjoint)1 Intersects (org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.Intersects)1 Overlaps (org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.Overlaps)1 SpatialContains (org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.SpatialContains)1 SpatialEqualTo (org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.SpatialEqualTo)1 SpatialFieldValue (org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.SpatialFieldValue)1