Search in sources :

Example 1 with Divide

use of org.locationtech.geowave.core.store.query.filter.expression.numeric.Divide in project geowave by locationtech.

the class FilterExpressionTest method testNumericExpressions.

@Test
public void testNumericExpressions() {
    final DataTypeAdapter<TestType> adapter = new TestTypeBasicDataAdapter();
    final TestType entry = new TestType("test", 1.3, 5, true);
    final TestType entryNulls = new TestType(null, null, null, null);
    final NumericLiteral doubleLit = NumericLiteral.of(0.5);
    final NumericLiteral integerLit = NumericLiteral.of(1);
    final NumericFieldValue doubleField = NumericFieldValue.of("doubleField");
    final NumericFieldValue intField = NumericFieldValue.of("intField");
    assertEquals(1.3, (double) doubleField.evaluateValue(adapter, entry), EPSILON);
    assertEquals(5, intField.evaluateValue(adapter, entry).intValue());
    // Test comparisons
    assertTrue(doubleLit.isLessThan(integerLit).evaluate(adapter, entry));
    assertFalse(integerLit.isLessThan(doubleLit).evaluate(adapter, entry));
    assertTrue(doubleField.isLessThan(1.5).evaluate(adapter, entry));
    assertFalse(doubleField.isLessThan(doubleLit).evaluate(adapter, entry));
    assertFalse(doubleField.isLessThan(integerLit).evaluate(adapter, entry));
    assertTrue(doubleField.isLessThan(intField).evaluate(adapter, entry));
    assertFalse(intField.isLessThan(doubleField).evaluate(adapter, entry));
    assertTrue(doubleLit.isGreaterThan(0).evaluate(adapter, entry));
    assertFalse(doubleLit.isGreaterThan(1).evaluate(adapter, entry));
    assertTrue(intField.isGreaterThan(1.0).evaluate(adapter, entry));
    assertTrue(intField.isGreaterThan(doubleLit).evaluate(adapter, entry));
    assertTrue(intField.isGreaterThan(integerLit).evaluate(adapter, entry));
    assertFalse(intField.isGreaterThan(6).evaluate(adapter, entry));
    assertTrue(intField.isGreaterThan(doubleField).evaluate(adapter, entry));
    assertFalse(doubleField.isGreaterThan(intField).evaluate(adapter, entry));
    assertTrue(integerLit.isGreaterThanOrEqualTo(0).evaluate(adapter, entry));
    assertTrue(integerLit.isGreaterThanOrEqualTo(integerLit).evaluate(adapter, entry));
    assertFalse(integerLit.isGreaterThanOrEqualTo(2).evaluate(adapter, entry));
    assertTrue(doubleLit.isLessThanOrEqualTo(1).evaluate(adapter, entry));
    assertTrue(doubleLit.isLessThanOrEqualTo(0.5).evaluate(adapter, entry));
    assertFalse(doubleLit.isLessThanOrEqualTo(0).evaluate(adapter, entry));
    assertTrue(doubleLit.isEqualTo(0.5).evaluate(adapter, entry));
    assertFalse(doubleLit.isEqualTo(0.4).evaluate(adapter, entry));
    assertTrue(doubleLit.isNotEqualTo(0.4).evaluate(adapter, entry));
    assertFalse(doubleLit.isNotEqualTo(0.5).evaluate(adapter, entry));
    assertFalse(doubleLit.isNull().evaluate(adapter, entry));
    assertFalse(integerLit.isNull().evaluate(adapter, entry));
    assertFalse(doubleField.isNull().evaluate(adapter, entry));
    assertFalse(intField.isNull().evaluate(adapter, entry));
    assertTrue(doubleField.isNull().evaluate(adapter, entryNulls));
    assertTrue(intField.isNull().evaluate(adapter, entryNulls));
    assertTrue(doubleLit.isNotNull().evaluate(adapter, entry));
    assertTrue(integerLit.isNotNull().evaluate(adapter, entry));
    assertTrue(doubleField.isNotNull().evaluate(adapter, entry));
    assertTrue(intField.isNotNull().evaluate(adapter, entry));
    assertFalse(doubleField.isNotNull().evaluate(adapter, entryNulls));
    assertFalse(intField.isNotNull().evaluate(adapter, entryNulls));
    assertFalse(doubleField.isLessThan(null).evaluate(adapter, entry));
    assertFalse(doubleField.isGreaterThan(null).evaluate(adapter, entry));
    assertFalse(doubleField.isLessThanOrEqualTo(null).evaluate(adapter, entry));
    assertFalse(doubleField.isGreaterThanOrEqualTo(null).evaluate(adapter, entry));
    assertFalse(doubleField.isEqualTo(null).evaluate(adapter, entry));
    assertTrue(doubleField.isNotEqualTo(null).evaluate(adapter, entry));
    assertTrue(doubleField.isEqualTo(intField).evaluate(adapter, entryNulls));
    assertFalse(doubleField.isEqualTo(doubleLit).evaluate(adapter, entryNulls));
    assertFalse(doubleField.isNotEqualTo(null).evaluate(adapter, entryNulls));
    assertTrue(doubleField.isNotEqualTo(doubleLit).evaluate(adapter, entryNulls));
    assertTrue(doubleLit.isBetween(0, 1).evaluate(adapter, entry));
    assertFalse(doubleLit.isBetween(integerLit, intField).evaluate(adapter, entry));
    assertTrue(doubleField.isBetween(doubleLit, intField).evaluate(adapter, entry));
    assertFalse(doubleField.isBetween(doubleLit, intField).evaluate(adapter, entryNulls));
    assertFalse(doubleLit.isBetween(integerLit, intField).evaluate(adapter, entryNulls));
    assertFalse(doubleLit.isBetween(intField, integerLit).evaluate(adapter, entryNulls));
    assertFalse(intField.isBetween(doubleLit, integerLit).evaluate(adapter, entry));
    assertTrue(integerLit.add(1).isLiteral());
    assertFalse(intField.add(1).isLiteral());
    assertTrue(integerLit.add(doubleLit).isLiteral());
    assertFalse(integerLit.add(doubleField).isLiteral());
    assertTrue(doubleLit.abs().isLiteral());
    assertFalse(doubleField.abs().isLiteral());
    // Test math
    assertNull(doubleField.abs().evaluateValue(adapter, entryNulls));
    assertEquals(5.3, (double) NumericLiteral.of(-5.3).abs().evaluateValue(null, null), EPSILON);
    assertEquals(5.3, (double) NumericLiteral.of(5.3).abs().evaluateValue(null, null), EPSILON);
    assertEquals(2.7, (double) doubleField.abs().evaluateValue(adapter, new TestType("test", -2.7, 5, true)), EPSILON);
    assertEquals(5, (double) intField.abs().evaluateValue(adapter, new TestType("test", -2.7, 5, true)), EPSILON);
    assertEquals(28, (double) NumericLiteral.of(5).add(15).divideBy(4).multiplyBy(8).subtract(12).evaluateValue(null, null), EPSILON);
    assertNull(doubleField.add(1).evaluateValue(adapter, entryNulls));
    assertNull(doubleLit.add(intField).evaluateValue(adapter, entryNulls));
    assertNull(doubleField.add(intField).evaluateValue(adapter, entryNulls));
    // Test complex
    // ((1.3 + 0.8) * (5 - 1)) / 3.2
    assertEquals(2.625, (double) doubleField.add(0.8).multiplyBy(intField.subtract(integerLit)).divideBy(3.2).evaluateValue(adapter, entry), EPSILON);
    try {
        integerLit.add("test");
        fail();
    } catch (RuntimeException e) {
    // Expected
    }
    // Test serialization
    byte[] bytes = PersistenceUtils.toBinary(doubleField.add(5));
    final Add add = (Add) PersistenceUtils.fromBinary(bytes);
    assertTrue(add.getExpression1() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) add.getExpression1()).getFieldName());
    assertTrue(add.getExpression2() instanceof NumericLiteral);
    assertEquals(5L, ((Number) ((NumericLiteral) add.getExpression2()).getValue()).longValue());
    bytes = PersistenceUtils.toBinary(doubleField.subtract(5));
    final Subtract subtract = (Subtract) PersistenceUtils.fromBinary(bytes);
    assertTrue(subtract.getExpression1() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) subtract.getExpression1()).getFieldName());
    assertTrue(subtract.getExpression2() instanceof NumericLiteral);
    assertEquals(5L, ((Number) ((NumericLiteral) subtract.getExpression2()).getValue()).longValue());
    bytes = PersistenceUtils.toBinary(doubleField.multiplyBy(5));
    final Multiply multiply = (Multiply) PersistenceUtils.fromBinary(bytes);
    assertTrue(multiply.getExpression1() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) multiply.getExpression1()).getFieldName());
    assertTrue(multiply.getExpression2() instanceof NumericLiteral);
    assertEquals(5L, ((Number) ((NumericLiteral) multiply.getExpression2()).getValue()).longValue());
    bytes = PersistenceUtils.toBinary(doubleField.divideBy(null));
    final Divide divide = (Divide) PersistenceUtils.fromBinary(bytes);
    assertTrue(divide.getExpression1() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) divide.getExpression1()).getFieldName());
    assertTrue(divide.getExpression2() instanceof NumericLiteral);
    assertNull(((NumericLiteral) divide.getExpression2()).getValue());
    bytes = PersistenceUtils.toBinary(doubleField.abs());
    final Abs abs = (Abs) PersistenceUtils.fromBinary(bytes);
    assertTrue(abs.getExpression() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) abs.getExpression()).getFieldName());
    bytes = PersistenceUtils.toBinary(doubleField.isLessThan(5));
    NumericComparisonOperator compareOp = (NumericComparisonOperator) PersistenceUtils.fromBinary(bytes);
    assertEquals(CompareOp.LESS_THAN, compareOp.getCompareOp());
    assertTrue(compareOp.getExpression1() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) compareOp.getExpression1()).getFieldName());
    assertTrue(compareOp.getExpression2() instanceof NumericLiteral);
    assertEquals(5L, ((Number) ((NumericLiteral) compareOp.getExpression2()).getValue()).longValue());
    bytes = PersistenceUtils.toBinary(doubleField.isLessThanOrEqualTo(5));
    compareOp = (NumericComparisonOperator) PersistenceUtils.fromBinary(bytes);
    assertEquals(CompareOp.LESS_THAN_OR_EQUAL, compareOp.getCompareOp());
    assertTrue(compareOp.getExpression1() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) compareOp.getExpression1()).getFieldName());
    assertTrue(compareOp.getExpression2() instanceof NumericLiteral);
    assertEquals(5L, ((Number) ((NumericLiteral) compareOp.getExpression2()).getValue()).longValue());
    bytes = PersistenceUtils.toBinary(doubleField.isGreaterThan(5));
    compareOp = (NumericComparisonOperator) PersistenceUtils.fromBinary(bytes);
    assertEquals(CompareOp.GREATER_THAN, compareOp.getCompareOp());
    assertTrue(compareOp.getExpression1() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) compareOp.getExpression1()).getFieldName());
    assertTrue(compareOp.getExpression2() instanceof NumericLiteral);
    assertEquals(5L, ((Number) ((NumericLiteral) compareOp.getExpression2()).getValue()).longValue());
    bytes = PersistenceUtils.toBinary(doubleField.isGreaterThanOrEqualTo(5));
    compareOp = (NumericComparisonOperator) PersistenceUtils.fromBinary(bytes);
    assertEquals(CompareOp.GREATER_THAN_OR_EQUAL, compareOp.getCompareOp());
    assertTrue(compareOp.getExpression1() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) compareOp.getExpression1()).getFieldName());
    assertTrue(compareOp.getExpression2() instanceof NumericLiteral);
    assertEquals(5L, ((Number) ((NumericLiteral) compareOp.getExpression2()).getValue()).longValue());
    bytes = PersistenceUtils.toBinary(doubleField.isEqualTo(5));
    compareOp = (NumericComparisonOperator) PersistenceUtils.fromBinary(bytes);
    assertEquals(CompareOp.EQUAL_TO, compareOp.getCompareOp());
    assertTrue(compareOp.getExpression1() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) compareOp.getExpression1()).getFieldName());
    assertTrue(compareOp.getExpression2() instanceof NumericLiteral);
    assertEquals(5L, ((Number) ((NumericLiteral) compareOp.getExpression2()).getValue()).longValue());
    bytes = PersistenceUtils.toBinary(doubleField.isNotEqualTo(5));
    compareOp = (NumericComparisonOperator) PersistenceUtils.fromBinary(bytes);
    assertEquals(CompareOp.NOT_EQUAL_TO, compareOp.getCompareOp());
    assertTrue(compareOp.getExpression1() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) compareOp.getExpression1()).getFieldName());
    assertTrue(compareOp.getExpression2() instanceof NumericLiteral);
    assertEquals(5L, ((Number) ((NumericLiteral) compareOp.getExpression2()).getValue()).longValue());
    bytes = PersistenceUtils.toBinary(doubleField.isBetween(5, 10));
    final Between<?, ?> between = (Between<?, ?>) PersistenceUtils.fromBinary(bytes);
    assertTrue(between.getValue() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) between.getValue()).getFieldName());
    assertTrue(between.getLowerBound() instanceof NumericLiteral);
    assertEquals(5L, ((Number) ((NumericLiteral) between.getLowerBound()).getValue()).longValue());
    assertTrue(between.getUpperBound() instanceof NumericLiteral);
    assertEquals(10L, ((Number) ((NumericLiteral) between.getUpperBound()).getValue()).longValue());
    bytes = PersistenceUtils.toBinary(doubleField.isNull());
    final IsNull isNull = (IsNull) PersistenceUtils.fromBinary(bytes);
    assertTrue(isNull.getExpression() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) isNull.getExpression()).getFieldName());
    bytes = PersistenceUtils.toBinary(doubleField.isNotNull());
    final IsNotNull isNotNull = (IsNotNull) PersistenceUtils.fromBinary(bytes);
    assertTrue(isNotNull.getExpression() instanceof NumericFieldValue);
    assertEquals("doubleField", ((NumericFieldValue) isNotNull.getExpression()).getFieldName());
    try {
        NumericFieldValue.of("name").evaluateValue(adapter, entry);
        fail();
    } catch (RuntimeException e) {
    // expected
    }
}
Also used : Add(org.locationtech.geowave.core.store.query.filter.expression.numeric.Add) NumericLiteral(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericLiteral) NumericComparisonOperator(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericComparisonOperator) NumericFieldValue(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericFieldValue) TestType(org.locationtech.geowave.core.store.adapter.AbstractDataTypeAdapterTest.TestType) TestTypeBasicDataAdapter(org.locationtech.geowave.core.store.adapter.AbstractDataTypeAdapterTest.TestTypeBasicDataAdapter) Divide(org.locationtech.geowave.core.store.query.filter.expression.numeric.Divide) Abs(org.locationtech.geowave.core.store.query.filter.expression.numeric.Abs) Multiply(org.locationtech.geowave.core.store.query.filter.expression.numeric.Multiply) Subtract(org.locationtech.geowave.core.store.query.filter.expression.numeric.Subtract) Test(org.junit.Test)

Example 2 with Divide

use of org.locationtech.geowave.core.store.query.filter.expression.numeric.Divide in project geowave by locationtech.

the class GWQLParserTest method testMathExpression.

@Test
public void testMathExpression() {
    final DataStore dataStore = createDataStore();
    String statement = "SELECT * FROM type WHERE pop + 5 > 25";
    Statement gwStatement = GWQLParser.parseStatement(dataStore, statement);
    assertTrue(gwStatement instanceof SelectStatement);
    SelectStatement<?> selectStatement = (SelectStatement<?>) gwStatement;
    assertNotNull(selectStatement.getFilter());
    Filter filter = selectStatement.getFilter();
    assertTrue(filter instanceof NumericComparisonOperator);
    NumericComparisonOperator compare = (NumericComparisonOperator) filter;
    assertEquals(CompareOp.GREATER_THAN, compare.getCompareOp());
    assertTrue(compare.getExpression1() instanceof Add);
    Add add = (Add) compare.getExpression1();
    assertTrue(add.getExpression1() instanceof NumericFieldValue);
    assertEquals("pop", ((NumericFieldValue) add.getExpression1()).getFieldName());
    assertTrue(add.getExpression2() instanceof NumericLiteral);
    assertEquals(5, ((NumericLiteral) add.getExpression2()).getValue(), 0.000001);
    assertTrue(compare.getExpression2() instanceof NumericLiteral);
    assertEquals(25, ((NumericLiteral) compare.getExpression2()).getValue(), 0.000001);
    statement = "SELECT * FROM type WHERE pop - 5 > 25";
    gwStatement = GWQLParser.parseStatement(dataStore, statement);
    assertTrue(gwStatement instanceof SelectStatement);
    selectStatement = (SelectStatement<?>) gwStatement;
    assertNotNull(selectStatement.getFilter());
    filter = selectStatement.getFilter();
    assertTrue(filter instanceof NumericComparisonOperator);
    compare = (NumericComparisonOperator) filter;
    assertEquals(CompareOp.GREATER_THAN, compare.getCompareOp());
    assertTrue(compare.getExpression1() instanceof Subtract);
    Subtract subtract = (Subtract) compare.getExpression1();
    assertTrue(subtract.getExpression1() instanceof NumericFieldValue);
    assertEquals("pop", ((NumericFieldValue) subtract.getExpression1()).getFieldName());
    assertTrue(subtract.getExpression2() instanceof NumericLiteral);
    assertEquals(5, ((NumericLiteral) subtract.getExpression2()).getValue(), 0.000001);
    assertTrue(compare.getExpression2() instanceof NumericLiteral);
    assertEquals(25, ((NumericLiteral) compare.getExpression2()).getValue(), 0.000001);
    statement = "SELECT * FROM type WHERE pop * 5 > 25";
    gwStatement = GWQLParser.parseStatement(dataStore, statement);
    assertTrue(gwStatement instanceof SelectStatement);
    selectStatement = (SelectStatement<?>) gwStatement;
    assertNotNull(selectStatement.getFilter());
    filter = selectStatement.getFilter();
    assertTrue(filter instanceof NumericComparisonOperator);
    compare = (NumericComparisonOperator) filter;
    assertEquals(CompareOp.GREATER_THAN, compare.getCompareOp());
    assertTrue(compare.getExpression1() instanceof Multiply);
    Multiply multiply = (Multiply) compare.getExpression1();
    assertTrue(multiply.getExpression1() instanceof NumericFieldValue);
    assertEquals("pop", ((NumericFieldValue) multiply.getExpression1()).getFieldName());
    assertTrue(multiply.getExpression2() instanceof NumericLiteral);
    assertEquals(5, ((NumericLiteral) multiply.getExpression2()).getValue(), 0.000001);
    assertTrue(compare.getExpression2() instanceof NumericLiteral);
    assertEquals(25, ((NumericLiteral) compare.getExpression2()).getValue(), 0.000001);
    statement = "SELECT * FROM type WHERE pop / 5 > 25";
    gwStatement = GWQLParser.parseStatement(dataStore, statement);
    assertTrue(gwStatement instanceof SelectStatement);
    selectStatement = (SelectStatement<?>) gwStatement;
    assertNotNull(selectStatement.getFilter());
    filter = selectStatement.getFilter();
    assertTrue(filter instanceof NumericComparisonOperator);
    compare = (NumericComparisonOperator) filter;
    assertEquals(CompareOp.GREATER_THAN, compare.getCompareOp());
    assertTrue(compare.getExpression1() instanceof Divide);
    Divide divide = (Divide) compare.getExpression1();
    assertTrue(divide.getExpression1() instanceof NumericFieldValue);
    assertEquals("pop", ((NumericFieldValue) divide.getExpression1()).getFieldName());
    assertTrue(divide.getExpression2() instanceof NumericLiteral);
    assertEquals(5, ((NumericLiteral) divide.getExpression2()).getValue(), 0.000001);
    assertTrue(compare.getExpression2() instanceof NumericLiteral);
    assertEquals(25, ((NumericLiteral) compare.getExpression2()).getValue(), 0.000001);
    // Test order of operations
    // (pop + ((5 * (pop - 8)) / 6))
    statement = "SELECT * FROM type WHERE pop + 5 * (pop - 8) / 6 > 25";
    gwStatement = GWQLParser.parseStatement(dataStore, statement);
    assertTrue(gwStatement instanceof SelectStatement);
    selectStatement = (SelectStatement<?>) gwStatement;
    assertNotNull(selectStatement.getFilter());
    filter = selectStatement.getFilter();
    assertTrue(filter instanceof NumericComparisonOperator);
    compare = (NumericComparisonOperator) filter;
    assertEquals(CompareOp.GREATER_THAN, compare.getCompareOp());
    assertTrue(compare.getExpression1() instanceof Add);
    add = (Add) compare.getExpression1();
    assertTrue(add.getExpression1() instanceof NumericFieldValue);
    assertEquals("pop", ((NumericFieldValue) add.getExpression1()).getFieldName());
    assertTrue(add.getExpression2() instanceof Divide);
    divide = (Divide) add.getExpression2();
    assertTrue(divide.getExpression1() instanceof Multiply);
    multiply = (Multiply) divide.getExpression1();
    assertTrue(multiply.getExpression1() instanceof NumericLiteral);
    assertEquals(5, ((NumericLiteral) multiply.getExpression1()).getValue(), 0.000001);
    assertTrue(multiply.getExpression2() instanceof Subtract);
    subtract = (Subtract) multiply.getExpression2();
    assertTrue(subtract.getExpression1() instanceof NumericFieldValue);
    assertEquals("pop", ((NumericFieldValue) subtract.getExpression1()).getFieldName());
    assertTrue(subtract.getExpression2() instanceof NumericLiteral);
    assertEquals(8, ((NumericLiteral) subtract.getExpression2()).getValue(), 0.000001);
    assertTrue(divide.getExpression2() instanceof NumericLiteral);
    assertEquals(6, ((NumericLiteral) divide.getExpression2()).getValue(), 0.000001);
    assertTrue(compare.getExpression2() instanceof NumericLiteral);
    assertEquals(25, ((NumericLiteral) compare.getExpression2()).getValue(), 0.000001);
}
Also used : Add(org.locationtech.geowave.core.store.query.filter.expression.numeric.Add) NumericLiteral(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericLiteral) NumericComparisonOperator(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericComparisonOperator) Statement(org.locationtech.geowave.core.store.query.gwql.statement.Statement) SelectStatement(org.locationtech.geowave.core.store.query.gwql.statement.SelectStatement) NumericFieldValue(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericFieldValue) SelectStatement(org.locationtech.geowave.core.store.query.gwql.statement.SelectStatement) Divide(org.locationtech.geowave.core.store.query.filter.expression.numeric.Divide) Filter(org.locationtech.geowave.core.store.query.filter.expression.Filter) DataStore(org.locationtech.geowave.core.store.api.DataStore) Multiply(org.locationtech.geowave.core.store.query.filter.expression.numeric.Multiply) Subtract(org.locationtech.geowave.core.store.query.filter.expression.numeric.Subtract) Test(org.junit.Test)

Example 3 with Divide

use of org.locationtech.geowave.core.store.query.filter.expression.numeric.Divide in project geowave by locationtech.

the class CQLToGeoWaveFilterTest method testCQLtoGeoWaveFilter.

@Test
public void testCQLtoGeoWaveFilter() throws CQLException, ParseException {
    Filter f = fromCQL("EMPLOYED < 15000000");
    assertTrue(f instanceof NumericComparisonOperator);
    assertEquals(CompareOp.LESS_THAN, ((NumericComparisonOperator) f).getCompareOp());
    assertTrue(((NumericComparisonOperator) f).getExpression1() instanceof NumericFieldValue);
    assertEquals("EMPLOYED", ((NumericFieldValue) ((NumericComparisonOperator) f).getExpression1()).getFieldName());
    assertTrue(((NumericComparisonOperator) f).getExpression2() instanceof NumericLiteral);
    assertEquals(15000000L, ((NumericLiteral) ((NumericComparisonOperator) f).getExpression2()).getValue().longValue());
    f = fromCQL("EMPLOYED BETWEEN 1000000 AND 3000000");
    assertTrue(f instanceof NumericBetween);
    assertTrue(((NumericBetween) f).getValue() instanceof NumericFieldValue);
    assertEquals("EMPLOYED", ((NumericFieldValue) ((NumericBetween) f).getValue()).getFieldName());
    assertTrue(((NumericBetween) f).getLowerBound() instanceof NumericLiteral);
    assertEquals(1000000L, ((NumericLiteral) ((NumericBetween) f).getLowerBound()).getValue().longValue());
    assertTrue(((NumericBetween) f).getUpperBound() instanceof NumericLiteral);
    assertEquals(3000000L, ((NumericLiteral) ((NumericBetween) f).getUpperBound()).getValue().longValue());
    f = fromCQL("name = 'California'");
    assertTrue(f instanceof TextComparisonOperator);
    assertEquals(CompareOp.EQUAL_TO, ((TextComparisonOperator) f).getCompareOp());
    assertTrue(((TextComparisonOperator) f).getExpression1() instanceof TextFieldValue);
    assertEquals("name", ((TextFieldValue) ((TextComparisonOperator) f).getExpression1()).getFieldName());
    assertTrue(((TextComparisonOperator) f).getExpression2() instanceof TextLiteral);
    assertEquals("California", ((TextLiteral) ((TextComparisonOperator) f).getExpression2()).getValue());
    f = fromCQL("UNEMPLOY / (EMPLOYED + UNEMPLOY) > 0.07");
    assertTrue(f instanceof NumericComparisonOperator);
    assertEquals(CompareOp.GREATER_THAN, ((NumericComparisonOperator) f).getCompareOp());
    assertTrue(((NumericComparisonOperator) f).getExpression1() instanceof Divide);
    Divide divide = (Divide) ((NumericComparisonOperator) f).getExpression1();
    assertTrue(divide.getExpression1() instanceof NumericFieldValue);
    assertEquals("UNEMPLOY", ((NumericFieldValue) divide.getExpression1()).getFieldName());
    assertTrue(divide.getExpression2() instanceof Add);
    Add add = (Add) divide.getExpression2();
    assertTrue(add.getExpression1() instanceof NumericFieldValue);
    assertEquals("EMPLOYED", ((NumericFieldValue) add.getExpression1()).getFieldName());
    assertTrue(add.getExpression2() instanceof NumericFieldValue);
    assertEquals("UNEMPLOY", ((NumericFieldValue) add.getExpression2()).getFieldName());
    assertTrue(((NumericComparisonOperator) f).getExpression2() instanceof NumericLiteral);
    assertEquals(0.07, ((NumericLiteral) ((NumericComparisonOperator) f).getExpression2()).getValue(), EPSILON);
    f = fromCQL("A <> B AND B <= 8.1");
    assertTrue(f instanceof And);
    assertTrue(((And) f).getChildren().length == 2);
    assertTrue(((And) f).getChildren()[0] instanceof Not);
    assertTrue(((Not) ((And) f).getChildren()[0]).getFilter() instanceof NumericComparisonOperator);
    NumericComparisonOperator equalTo = (NumericComparisonOperator) ((Not) ((And) f).getChildren()[0]).getFilter();
    assertEquals(CompareOp.EQUAL_TO, equalTo.getCompareOp());
    assertTrue(equalTo.getExpression1() instanceof NumericFieldValue);
    assertEquals("A", ((NumericFieldValue) equalTo.getExpression1()).getFieldName());
    assertTrue(equalTo.getExpression2() instanceof NumericFieldValue);
    assertEquals("B", ((NumericFieldValue) equalTo.getExpression2()).getFieldName());
    assertTrue(((And) f).getChildren()[1] instanceof NumericComparisonOperator);
    NumericComparisonOperator lessThan = (NumericComparisonOperator) ((And) f).getChildren()[1];
    assertEquals(CompareOp.LESS_THAN_OR_EQUAL, lessThan.getCompareOp());
    assertTrue(lessThan.getExpression1() instanceof NumericFieldValue);
    assertEquals("B", ((NumericFieldValue) lessThan.getExpression1()).getFieldName());
    assertTrue(lessThan.getExpression2() instanceof NumericLiteral);
    assertEquals(8.1, ((NumericLiteral) lessThan.getExpression2()).getValue(), EPSILON);
    // Order of operations should be preserved
    f = fromCQL("A + B - (C * D) / 8.5 >= E");
    assertTrue(f instanceof NumericComparisonOperator);
    assertEquals(CompareOp.GREATER_THAN_OR_EQUAL, ((NumericComparisonOperator) f).getCompareOp());
    assertTrue(((NumericComparisonOperator) f).getExpression1() instanceof Subtract);
    Subtract subtract = (Subtract) ((NumericComparisonOperator) f).getExpression1();
    assertTrue(subtract.getExpression1() instanceof Add);
    add = (Add) subtract.getExpression1();
    assertTrue(add.getExpression1() instanceof NumericFieldValue);
    assertEquals("A", ((NumericFieldValue) add.getExpression1()).getFieldName());
    assertTrue(add.getExpression2() instanceof NumericFieldValue);
    assertEquals("B", ((NumericFieldValue) add.getExpression2()).getFieldName());
    assertTrue(subtract.getExpression2() instanceof Divide);
    divide = (Divide) subtract.getExpression2();
    assertTrue(divide.getExpression1() instanceof Multiply);
    Multiply multiply = (Multiply) divide.getExpression1();
    assertTrue(multiply.getExpression1() instanceof NumericFieldValue);
    assertEquals("C", ((NumericFieldValue) multiply.getExpression1()).getFieldName());
    assertTrue(multiply.getExpression2() instanceof NumericFieldValue);
    assertEquals("D", ((NumericFieldValue) multiply.getExpression2()).getFieldName());
    assertTrue(divide.getExpression2() instanceof NumericLiteral);
    assertEquals(8.5, ((NumericLiteral) divide.getExpression2()).getValue(), EPSILON);
    assertTrue(((NumericComparisonOperator) f).getExpression2() instanceof NumericFieldValue);
    assertEquals("E", ((NumericFieldValue) ((NumericComparisonOperator) f).getExpression2()).getFieldName());
    f = fromCQL("BBOX(geom, -90, 40, -60, 45)");
    assertTrue(f instanceof BBox);
    assertTrue(((BBox) f).getExpression1() instanceof SpatialFieldValue);
    assertEquals("geom", ((SpatialFieldValue) ((BBox) f).getExpression1()).getFieldName());
    assertTrue(((BBox) f).getExpression2() instanceof SpatialLiteral);
    SpatialLiteral spatialLit = (SpatialLiteral) ((BBox) f).getExpression2();
    assertTrue(spatialLit.getValue() instanceof UnpreparedFilterGeometry);
    Geometry geom = ((UnpreparedFilterGeometry) spatialLit.getValue()).getGeometry();
    assertTrue(geom.equalsTopo(GeometryUtils.GEOMETRY_FACTORY.toGeometry(new Envelope(-90, -60, 40, 45))));
    f = fromCQL("DISJOINT(geom, POLYGON((-90 40, -90 45, -60 45, -60 40, -90 40)))");
    assertTrue(f instanceof Disjoint);
    assertTrue(((Disjoint) f).getExpression1() instanceof SpatialFieldValue);
    assertEquals("geom", ((SpatialFieldValue) ((Disjoint) f).getExpression1()).getFieldName());
    assertTrue(((Disjoint) f).getExpression2() instanceof SpatialLiteral);
    spatialLit = (SpatialLiteral) ((Disjoint) f).getExpression2();
    assertTrue(spatialLit.getValue() instanceof UnpreparedFilterGeometry);
    geom = ((UnpreparedFilterGeometry) spatialLit.getValue()).getGeometry();
    assertTrue(geom.equalsTopo(GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-90, 40), new Coordinate(-90, 45), new Coordinate(-60, 45), new Coordinate(-60, 40), new Coordinate(-90, 40) })));
    f = fromCQL("EQUALS(geom, POLYGON((-90 40, -90 45, -60 45, -60 40, -90 40)))");
    assertTrue(f instanceof SpatialEqualTo);
    assertTrue(((SpatialEqualTo) f).getExpression1() instanceof SpatialFieldValue);
    assertEquals("geom", ((SpatialFieldValue) ((SpatialEqualTo) f).getExpression1()).getFieldName());
    assertTrue(((SpatialEqualTo) f).getExpression2() instanceof SpatialLiteral);
    spatialLit = (SpatialLiteral) ((SpatialEqualTo) f).getExpression2();
    assertTrue(spatialLit.getValue() instanceof UnpreparedFilterGeometry);
    geom = ((UnpreparedFilterGeometry) spatialLit.getValue()).getGeometry();
    assertTrue(geom.equalsTopo(GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-90, 40), new Coordinate(-90, 45), new Coordinate(-60, 45), new Coordinate(-60, 40), new Coordinate(-90, 40) })));
    f = fromCQL("CONTAINS(geom, POLYGON((-90 40, -90 45, -60 45, -60 40, -90 40)))");
    assertTrue(f instanceof SpatialContains);
    assertTrue(((SpatialContains) f).getExpression1() instanceof SpatialFieldValue);
    assertEquals("geom", ((SpatialFieldValue) ((SpatialContains) f).getExpression1()).getFieldName());
    assertTrue(((SpatialContains) f).getExpression2() instanceof SpatialLiteral);
    spatialLit = (SpatialLiteral) ((SpatialContains) f).getExpression2();
    assertTrue(spatialLit.getValue() instanceof UnpreparedFilterGeometry);
    geom = ((UnpreparedFilterGeometry) spatialLit.getValue()).getGeometry();
    assertTrue(geom.equalsTopo(GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-90, 40), new Coordinate(-90, 45), new Coordinate(-60, 45), new Coordinate(-60, 40), new Coordinate(-90, 40) })));
    f = fromCQL("CROSSES(geom, POLYGON((-90 40, -90 45, -60 45, -60 40, -90 40)))");
    assertTrue(f instanceof Crosses);
    assertTrue(((Crosses) f).getExpression1() instanceof SpatialFieldValue);
    assertEquals("geom", ((SpatialFieldValue) ((Crosses) f).getExpression1()).getFieldName());
    assertTrue(((Crosses) f).getExpression2() instanceof SpatialLiteral);
    spatialLit = (SpatialLiteral) ((Crosses) f).getExpression2();
    assertTrue(spatialLit.getValue() instanceof UnpreparedFilterGeometry);
    geom = ((UnpreparedFilterGeometry) spatialLit.getValue()).getGeometry();
    assertTrue(geom.equalsTopo(GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-90, 40), new Coordinate(-90, 45), new Coordinate(-60, 45), new Coordinate(-60, 40), new Coordinate(-90, 40) })));
    f = fromCQL("INTERSECTS(geom, POLYGON((-90 40, -90 45, -60 45, -60 40, -90 40)))");
    assertTrue(f instanceof Intersects);
    assertTrue(((Intersects) f).getExpression1() instanceof SpatialFieldValue);
    assertEquals("geom", ((SpatialFieldValue) ((Intersects) f).getExpression1()).getFieldName());
    assertTrue(((Intersects) f).getExpression2() instanceof SpatialLiteral);
    spatialLit = (SpatialLiteral) ((Intersects) f).getExpression2();
    assertTrue(spatialLit.getValue() instanceof UnpreparedFilterGeometry);
    geom = ((UnpreparedFilterGeometry) spatialLit.getValue()).getGeometry();
    assertTrue(geom.equalsTopo(GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-90, 40), new Coordinate(-90, 45), new Coordinate(-60, 45), new Coordinate(-60, 40), new Coordinate(-90, 40) })));
    f = fromCQL("OVERLAPS(geom, POLYGON((-90 40, -90 45, -60 45, -60 40, -90 40)))");
    assertTrue(f instanceof Overlaps);
    assertTrue(((Overlaps) f).getExpression1() instanceof SpatialFieldValue);
    assertEquals("geom", ((SpatialFieldValue) ((Overlaps) f).getExpression1()).getFieldName());
    assertTrue(((Overlaps) f).getExpression2() instanceof SpatialLiteral);
    spatialLit = (SpatialLiteral) ((Overlaps) f).getExpression2();
    assertTrue(spatialLit.getValue() instanceof UnpreparedFilterGeometry);
    geom = ((UnpreparedFilterGeometry) spatialLit.getValue()).getGeometry();
    assertTrue(geom.equalsTopo(GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-90, 40), new Coordinate(-90, 45), new Coordinate(-60, 45), new Coordinate(-60, 40), new Coordinate(-90, 40) })));
    f = fromCQL("TOUCHES(geom, POLYGON((-90 40, -90 45, -60 45, -60 40, -90 40)))");
    assertTrue(f instanceof Touches);
    assertTrue(((Touches) f).getExpression1() instanceof SpatialFieldValue);
    assertEquals("geom", ((SpatialFieldValue) ((Touches) f).getExpression1()).getFieldName());
    assertTrue(((Touches) f).getExpression2() instanceof SpatialLiteral);
    spatialLit = (SpatialLiteral) ((Touches) f).getExpression2();
    assertTrue(spatialLit.getValue() instanceof UnpreparedFilterGeometry);
    geom = ((UnpreparedFilterGeometry) spatialLit.getValue()).getGeometry();
    assertTrue(geom.equalsTopo(GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-90, 40), new Coordinate(-90, 45), new Coordinate(-60, 45), new Coordinate(-60, 40), new Coordinate(-90, 40) })));
    f = fromCQL("WITHIN(geom, POLYGON((-90 40, -90 45, -60 45, -60 40, -90 40)))");
    assertTrue(f instanceof Within);
    assertTrue(((Within) f).getExpression1() instanceof SpatialFieldValue);
    assertEquals("geom", ((SpatialFieldValue) ((Within) f).getExpression1()).getFieldName());
    assertTrue(((Within) f).getExpression2() instanceof SpatialLiteral);
    spatialLit = (SpatialLiteral) ((Within) f).getExpression2();
    assertTrue(spatialLit.getValue() instanceof UnpreparedFilterGeometry);
    geom = ((UnpreparedFilterGeometry) spatialLit.getValue()).getGeometry();
    assertTrue(geom.equalsTopo(GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-90, 40), new Coordinate(-90, 45), new Coordinate(-60, 45), new Coordinate(-60, 40), new Coordinate(-90, 40) })));
    final Instant date1 = Instant.parse("2020-01-25T00:28:32Z");
    final Instant date2 = Instant.parse("2021-03-02T13:08:45Z");
    f = fromCQL("date AFTER 2020-01-25T00:28:32Z");
    assertTrue(f instanceof After);
    assertTrue(((After) f).getExpression1() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) ((After) f).getExpression1()).getFieldName());
    assertTrue(((After) f).getExpression2() instanceof TemporalLiteral);
    Interval interval = ((TemporalLiteral) ((After) f).getExpression2()).getValue();
    assertEquals(date1.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date1.getEpochSecond(), interval.getEnd().getEpochSecond());
    f = fromCQL("date > 2020-01-25T00:28:32Z");
    assertTrue(f instanceof After);
    assertTrue(((After) f).getExpression1() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) ((After) f).getExpression1()).getFieldName());
    assertTrue(((After) f).getExpression2() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) ((After) f).getExpression2()).getValue();
    assertEquals(date1.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date1.getEpochSecond(), interval.getEnd().getEpochSecond());
    f = fromCQL("date BEFORE 2021-03-02T13:08:45Z");
    assertTrue(f instanceof Before);
    assertTrue(((Before) f).getExpression1() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) ((Before) f).getExpression1()).getFieldName());
    assertTrue(((Before) f).getExpression2() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) ((Before) f).getExpression2()).getValue();
    assertEquals(date2.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date2.getEpochSecond(), interval.getEnd().getEpochSecond());
    f = fromCQL("date < 2021-03-02T13:08:45Z");
    assertTrue(f instanceof Before);
    assertTrue(((Before) f).getExpression1() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) ((Before) f).getExpression1()).getFieldName());
    assertTrue(((Before) f).getExpression2() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) ((Before) f).getExpression2()).getValue();
    assertEquals(date2.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date2.getEpochSecond(), interval.getEnd().getEpochSecond());
    f = fromCQL("date DURING 2020-01-25T00:28:32Z/2021-03-02T13:08:45Z");
    assertTrue(f instanceof During);
    assertTrue(((During) f).getExpression1() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) ((During) f).getExpression1()).getFieldName());
    assertTrue(((During) f).getExpression2() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) ((During) f).getExpression2()).getValue();
    assertEquals(date1.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date2.getEpochSecond(), interval.getEnd().getEpochSecond());
    // GeoWave has a BeforeOrDuring class, but the CQL filter translates it using OR
    f = fromCQL("date BEFORE OR DURING 2020-01-25T00:28:32Z/2021-03-02T13:08:45Z");
    assertTrue(f instanceof Or);
    assertTrue(((Or) f).getChildren().length == 2);
    assertTrue(((Or) f).getChildren()[0] instanceof Before);
    Before before = (Before) ((Or) f).getChildren()[0];
    assertTrue(before.getExpression1() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) before.getExpression1()).getFieldName());
    assertTrue(before.getExpression2() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) before.getExpression2()).getValue();
    assertEquals(date1.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date1.getEpochSecond(), interval.getEnd().getEpochSecond());
    assertTrue(((Or) f).getChildren()[1] instanceof During);
    During during = (During) ((Or) f).getChildren()[1];
    assertTrue(during.getExpression1() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) during.getExpression1()).getFieldName());
    assertTrue(during.getExpression2() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) during.getExpression2()).getValue();
    assertEquals(date1.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date2.getEpochSecond(), interval.getEnd().getEpochSecond());
    f = fromCQL("date DURING OR AFTER 2020-01-25T00:28:32Z/2021-03-02T13:08:45Z");
    assertTrue(f instanceof Or);
    assertTrue(((Or) f).getChildren().length == 2);
    assertTrue(((Or) f).getChildren()[0] instanceof During);
    during = (During) ((Or) f).getChildren()[0];
    assertTrue(during.getExpression1() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) during.getExpression1()).getFieldName());
    assertTrue(during.getExpression2() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) during.getExpression2()).getValue();
    assertEquals(date1.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date2.getEpochSecond(), interval.getEnd().getEpochSecond());
    assertTrue(((Or) f).getChildren()[1] instanceof After);
    After after = (After) ((Or) f).getChildren()[1];
    assertTrue(after.getExpression1() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) after.getExpression1()).getFieldName());
    assertTrue(after.getExpression2() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) after.getExpression2()).getValue();
    assertEquals(date2.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date2.getEpochSecond(), interval.getEnd().getEpochSecond());
    f = fromCQL("date <= 2020-01-25T00:28:32Z");
    assertTrue(f instanceof BeforeOrDuring);
    assertTrue(((BeforeOrDuring) f).getExpression1() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) ((BeforeOrDuring) f).getExpression1()).getFieldName());
    assertTrue(((BeforeOrDuring) f).getExpression2() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) ((BeforeOrDuring) f).getExpression2()).getValue();
    assertEquals(date1.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date1.getEpochSecond(), interval.getEnd().getEpochSecond());
    f = fromCQL("date >= 2020-01-25T00:28:32Z");
    assertTrue(f instanceof DuringOrAfter);
    assertTrue(((DuringOrAfter) f).getExpression1() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) ((DuringOrAfter) f).getExpression1()).getFieldName());
    assertTrue(((DuringOrAfter) f).getExpression2() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) ((DuringOrAfter) f).getExpression2()).getValue();
    assertEquals(date1.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date1.getEpochSecond(), interval.getEnd().getEpochSecond());
    f = fromCQL("date BETWEEN 2020-01-25T00:28:32Z AND 2021-03-02T13:08:45Z");
    assertTrue(f instanceof TemporalBetween);
    assertTrue(((TemporalBetween) f).getValue() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) ((TemporalBetween) f).getValue()).getFieldName());
    assertTrue(((TemporalBetween) f).getLowerBound() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) (((TemporalBetween) f).getLowerBound())).getValue();
    assertEquals(date1.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date1.getEpochSecond(), interval.getEnd().getEpochSecond());
    assertTrue(((TemporalBetween) f).getUpperBound() instanceof TemporalLiteral);
    interval = ((TemporalLiteral) (((TemporalBetween) f).getUpperBound())).getValue();
    assertEquals(date2.getEpochSecond(), interval.getStart().getEpochSecond());
    assertEquals(date2.getEpochSecond(), interval.getEnd().getEpochSecond());
    f = fromCQL("date IS NULL");
    assertTrue(f instanceof IsNull);
    assertTrue(((IsNull) f).getExpression() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) ((IsNull) f).getExpression()).getFieldName());
    f = fromCQL("date IS NOT NULL");
    assertTrue(f instanceof Not);
    assertTrue(((Not) f).getFilter() instanceof IsNull);
    assertTrue(((IsNull) ((Not) f).getFilter()).getExpression() instanceof TemporalFieldValue);
    assertEquals("date", ((TemporalFieldValue) ((IsNull) ((Not) f).getFilter()).getExpression()).getFieldName());
    f = fromCQL("INCLUDE");
    assertTrue(f instanceof Include);
    f = fromCQL("EXCLUDE");
    assertTrue(f instanceof Exclude);
    f = fromCQL("bool = TRUE");
    assertTrue(f instanceof GenericEqualTo);
    assertTrue(((GenericEqualTo) f).getExpression1() instanceof BooleanFieldValue);
    assertEquals("bool", ((BooleanFieldValue) ((GenericEqualTo) f).getExpression1()).getFieldName());
    assertTrue(((GenericEqualTo) f).getExpression2() instanceof BooleanLiteral);
    assertTrue((boolean) ((BooleanLiteral) ((GenericEqualTo) f).getExpression2()).getValue());
    f = fromCQL("name LIKE '%value'");
    assertTrue(f instanceof EndsWith);
    assertTrue(((EndsWith) f).getExpression1() instanceof TextFieldValue);
    assertEquals("name", ((TextFieldValue) ((EndsWith) f).getExpression1()).getFieldName());
    assertTrue(((EndsWith) f).getExpression2() instanceof TextLiteral);
    assertEquals("value", ((TextLiteral) ((EndsWith) f).getExpression2()).getValue());
    f = fromCQL("name LIKE 'value%'");
    assertTrue(f instanceof StartsWith);
    assertTrue(((StartsWith) f).getExpression1() instanceof TextFieldValue);
    assertEquals("name", ((TextFieldValue) ((StartsWith) f).getExpression1()).getFieldName());
    assertTrue(((StartsWith) f).getExpression2() instanceof TextLiteral);
    assertEquals("value", ((TextLiteral) ((StartsWith) f).getExpression2()).getValue());
    f = fromCQL("name LIKE '%value%'");
    assertTrue(f instanceof Contains);
    assertTrue(((Contains) f).getExpression1() instanceof TextFieldValue);
    assertEquals("name", ((TextFieldValue) ((Contains) f).getExpression1()).getFieldName());
    assertTrue(((Contains) f).getExpression2() instanceof TextLiteral);
    assertEquals("value", ((TextLiteral) ((Contains) f).getExpression2()).getValue());
    f = fromCQL("name LIKE 'a\\_value'");
    assertTrue(f instanceof TextComparisonOperator);
    assertEquals(CompareOp.EQUAL_TO, ((TextComparisonOperator) f).getCompareOp());
    assertTrue(((TextComparisonOperator) f).getExpression1() instanceof TextFieldValue);
    assertEquals("name", ((TextFieldValue) ((TextComparisonOperator) f).getExpression1()).getFieldName());
    assertTrue(((TextComparisonOperator) f).getExpression2() instanceof TextLiteral);
    assertEquals("a_value", ((TextLiteral) ((TextComparisonOperator) f).getExpression2()).getValue());
    try {
        // _ is a single character wild card, so this is not supported
        f = fromCQL("name LIKE 'a_value'");
        fail();
    } catch (CQLToGeoWaveConversionException e) {
    // expected
    }
}
Also used : Add(org.locationtech.geowave.core.store.query.filter.expression.numeric.Add) TextComparisonOperator(org.locationtech.geowave.core.store.query.filter.expression.text.TextComparisonOperator) Or(org.locationtech.geowave.core.store.query.filter.expression.Or) GenericEqualTo(org.locationtech.geowave.core.store.query.filter.expression.GenericEqualTo) Include(org.locationtech.geowave.core.store.query.filter.expression.Include) TemporalFieldValue(org.locationtech.geowave.core.geotime.store.query.filter.expression.temporal.TemporalFieldValue) BooleanFieldValue(org.locationtech.geowave.core.store.query.filter.expression.BooleanFieldValue) Divide(org.locationtech.geowave.core.store.query.filter.expression.numeric.Divide) Multiply(org.locationtech.geowave.core.store.query.filter.expression.numeric.Multiply) Intersects(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.Intersects) Touches(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.Touches) TextLiteral(org.locationtech.geowave.core.store.query.filter.expression.text.TextLiteral) SpatialFieldValue(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.SpatialFieldValue) NumericBetween(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericBetween) Instant(java.time.Instant) Not(org.locationtech.geowave.core.store.query.filter.expression.Not) Coordinate(org.locationtech.jts.geom.Coordinate) And(org.locationtech.geowave.core.store.query.filter.expression.And) BBox(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.BBox) SpatialContains(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.SpatialContains) Contains(org.locationtech.geowave.core.store.query.filter.expression.text.Contains) Subtract(org.locationtech.geowave.core.store.query.filter.expression.numeric.Subtract) EndsWith(org.locationtech.geowave.core.store.query.filter.expression.text.EndsWith) Interval(org.threeten.extra.Interval) Before(org.locationtech.geowave.core.geotime.store.query.filter.expression.temporal.Before) Overlaps(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.Overlaps) Exclude(org.locationtech.geowave.core.store.query.filter.expression.Exclude) NumericLiteral(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericLiteral) NumericComparisonOperator(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericComparisonOperator) BooleanLiteral(org.locationtech.geowave.core.store.query.filter.expression.BooleanLiteral) NumericFieldValue(org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericFieldValue) Envelope(org.locationtech.jts.geom.Envelope) StartsWith(org.locationtech.geowave.core.store.query.filter.expression.text.StartsWith) TextFieldValue(org.locationtech.geowave.core.store.query.filter.expression.text.TextFieldValue) BeforeOrDuring(org.locationtech.geowave.core.geotime.store.query.filter.expression.temporal.BeforeOrDuring) During(org.locationtech.geowave.core.geotime.store.query.filter.expression.temporal.During) Crosses(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.Crosses) DuringOrAfter(org.locationtech.geowave.core.geotime.store.query.filter.expression.temporal.DuringOrAfter) Disjoint(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.Disjoint) TemporalLiteral(org.locationtech.geowave.core.geotime.store.query.filter.expression.temporal.TemporalLiteral) UnpreparedFilterGeometry(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.UnpreparedFilterGeometry) Geometry(org.locationtech.jts.geom.Geometry) UnpreparedFilterGeometry(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.UnpreparedFilterGeometry) SpatialEqualTo(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.SpatialEqualTo) SpatialContains(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.SpatialContains) Filter(org.locationtech.geowave.core.store.query.filter.expression.Filter) Within(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.Within) After(org.locationtech.geowave.core.geotime.store.query.filter.expression.temporal.After) DuringOrAfter(org.locationtech.geowave.core.geotime.store.query.filter.expression.temporal.DuringOrAfter) IsNull(org.locationtech.geowave.core.store.query.filter.expression.IsNull) SpatialLiteral(org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.SpatialLiteral) BeforeOrDuring(org.locationtech.geowave.core.geotime.store.query.filter.expression.temporal.BeforeOrDuring) TemporalBetween(org.locationtech.geowave.core.geotime.store.query.filter.expression.temporal.TemporalBetween) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 Add (org.locationtech.geowave.core.store.query.filter.expression.numeric.Add)3 Divide (org.locationtech.geowave.core.store.query.filter.expression.numeric.Divide)3 Multiply (org.locationtech.geowave.core.store.query.filter.expression.numeric.Multiply)3 NumericComparisonOperator (org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericComparisonOperator)3 NumericFieldValue (org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericFieldValue)3 NumericLiteral (org.locationtech.geowave.core.store.query.filter.expression.numeric.NumericLiteral)3 Subtract (org.locationtech.geowave.core.store.query.filter.expression.numeric.Subtract)3 Filter (org.locationtech.geowave.core.store.query.filter.expression.Filter)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 SpatialLiteral (org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.SpatialLiteral)1 Touches (org.locationtech.geowave.core.geotime.store.query.filter.expression.spatial.Touches)1