Search in sources :

Example 86 with ParseException

use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.

the class WhindexVisitorTest method reverseIncompleteMappingIntersectsTest.

@Test
public void reverseIncompleteMappingIntersectsTest() throws ParseException {
    String query = "(TOPPINGS == 'HOT_FUDGE' || TOPPINGS == 'BANANA' || TOPPINGS == 'CHERRY') && geowave:intersects(ICE_CREAM, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')";
    ShardQueryConfiguration config = new ShardQueryConfiguration();
    config.setWhindexMappingFields(mappingFields);
    config.setWhindexFieldMappings(multipleFieldMapping);
    ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
    jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
    Assert.assertEquals("(geowave:intersects(ICE_CREAM, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))') && TOPPINGS == 'CHERRY') || geowave:intersects(HOT_FUDGE_SUNDAE, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))') || geowave:intersects(BANANA_SPLIT, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 87 with ParseException

use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.

the class WhindexVisitorTest method manyToManyMultipleIntersectsTest.

@Test
public void manyToManyMultipleIntersectsTest() throws ParseException {
    String query = "geowave:intersects((ICE_CREAM || SHERBERT), 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))') && TOPPINGS == 'PEANUT' && (TOPPINGS == 'HOT_FUDGE' || TOPPINGS == 'BANANA')";
    ShardQueryConfiguration config = new ShardQueryConfiguration();
    config.setWhindexMappingFields(mappingFields);
    config.setWhindexFieldMappings(multipleFieldMapping);
    ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
    jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
    Assert.assertEquals("(TOPPINGS == 'PEANUT' && ((TOPPINGS == 'HOT_FUDGE' && geowave:intersects(SHERBERT, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')) || geowave:intersects(HOT_FUDGE_SUNDAE, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))'))) || (TOPPINGS == 'PEANUT' && ((TOPPINGS == 'BANANA' && geowave:intersects(SHERBERT, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')) || geowave:intersects(BANANA_SPLIT, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')))", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 88 with ParseException

use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.

the class WhindexVisitorTest method reverseOneToManyIntersectsDistributedUnchangedTest.

@Test
public void reverseOneToManyIntersectsDistributedUnchangedTest() throws ParseException {
    String query = "(TOPPINGS == 'HOT_FUDGE' || TOPPINGS == 'BANANA') && FIELD == 'VALUE'";
    ShardQueryConfiguration config = new ShardQueryConfiguration();
    config.setWhindexMappingFields(mappingFields);
    config.setWhindexFieldMappings(multipleFieldMapping);
    ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
    jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
    Assert.assertEquals("(TOPPINGS == 'HOT_FUDGE' || TOPPINGS == 'BANANA') && FIELD == 'VALUE'", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 89 with ParseException

use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.

the class WhindexVisitorTest method oneToOneAltFieldIntersectsTest.

@Test
public void oneToOneAltFieldIntersectsTest() throws ParseException {
    String query = "geowave:intersects(ICE_CREAM, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))') && FIXINGS == 'HOT_FUDGE'";
    ShardQueryConfiguration config = new ShardQueryConfiguration();
    config.setWhindexMappingFields(mappingFields);
    config.setWhindexFieldMappings(singleFieldMapping);
    ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
    jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
    Assert.assertEquals("geowave:intersects(HOT_FUDGE_SUNDAE, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 90 with ParseException

use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.

the class WhindexVisitorTest method incompleteMappingIntersectsTest.

@Test
public void incompleteMappingIntersectsTest() throws ParseException {
    String query = "geowave:intersects(ICE_CREAM, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))') && (TOPPINGS == 'HOT_FUDGE' || TOPPINGS == 'BANANA' || TOPPINGS == 'CHERRY')";
    ShardQueryConfiguration config = new ShardQueryConfiguration();
    config.setWhindexMappingFields(mappingFields);
    config.setWhindexFieldMappings(multipleFieldMapping);
    ASTJexlScript jexlScript = JexlASTHelper.parseJexlQuery(query);
    jexlScript = WhindexVisitor.apply(jexlScript, config, new Date(), metadataHelper);
    Assert.assertEquals("(geowave:intersects(ICE_CREAM, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))') && TOPPINGS == 'CHERRY') || geowave:intersects(HOT_FUDGE_SUNDAE, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))') || geowave:intersects(BANANA_SPLIT, 'POLYGON((-10 -10, 10 -10, 10 10, -10 10, -10 -10))')", JexlStringBuildingVisitor.buildQuery(jexlScript));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)258 Test (org.junit.Test)214 JexlNode (org.apache.commons.jexl2.parser.JexlNode)56 ShardQueryConfiguration (datawave.query.config.ShardQueryConfiguration)36 Date (java.util.Date)33 ParseException (org.apache.commons.jexl2.parser.ParseException)18 HashSet (java.util.HashSet)14 Key (org.apache.accumulo.core.data.Key)9 ArrayList (java.util.ArrayList)7 DatawaveFatalQueryException (datawave.query.exceptions.DatawaveFatalQueryException)6 IOException (java.io.IOException)5 ASTERNode (org.apache.commons.jexl2.parser.ASTERNode)5 MockMetadataHelper (datawave.query.util.MockMetadataHelper)4 PartialKey (org.apache.accumulo.core.data.PartialKey)4 Document (datawave.query.attributes.Document)3 JexlEvaluation (datawave.query.function.JexlEvaluation)3 DatawaveJexlContext (datawave.query.jexl.DatawaveJexlContext)3 DefaultArithmetic (datawave.query.jexl.DefaultArithmetic)3 StringReader (java.io.StringReader)3 AbstractMap (java.util.AbstractMap)3