Commit c2d52759 by Madhan Neethiraj

ATLAS-1866: DSL 'like' operator fails for associated entity attributes

parent 906f3651
...@@ -40,7 +40,6 @@ import org.apache.atlas.groovy.LogicalExpression.LogicalOperator; ...@@ -40,7 +40,6 @@ import org.apache.atlas.groovy.LogicalExpression.LogicalOperator;
import org.apache.atlas.groovy.RangeExpression; import org.apache.atlas.groovy.RangeExpression;
import org.apache.atlas.groovy.TernaryOperatorExpression; import org.apache.atlas.groovy.TernaryOperatorExpression;
import org.apache.atlas.groovy.TraversalStepType; import org.apache.atlas.groovy.TraversalStepType;
import org.apache.atlas.query.Expressions;
import org.apache.atlas.query.GraphPersistenceStrategies; import org.apache.atlas.query.GraphPersistenceStrategies;
import org.apache.atlas.query.TypeUtils.FieldInfo; import org.apache.atlas.query.TypeUtils.FieldInfo;
import org.apache.atlas.typesystem.types.IDataType; import org.apache.atlas.typesystem.types.IDataType;
...@@ -154,9 +153,8 @@ public class Gremlin2ExpressionFactory extends GremlinExpressionFactory { ...@@ -154,9 +153,8 @@ public class Gremlin2ExpressionFactory extends GremlinExpressionFactory {
GroovyExpression nameExpr = new FieldExpression(itExpr, propertyName); GroovyExpression nameExpr = new FieldExpression(itExpr, propertyName);
GroovyExpression matchesExpr = new FunctionCallExpression(nameExpr, MATCHES, escapePropertyValue(propertyValue)); GroovyExpression matchesExpr = new FunctionCallExpression(nameExpr, MATCHES, escapePropertyValue(propertyValue));
GroovyExpression closureExpr = new ClosureExpression(matchesExpr); GroovyExpression closureExpr = new ClosureExpression(matchesExpr);
GroovyExpression filterExpr = new FunctionCallExpression(parent, FILTER_METHOD, closureExpr);
return filterExpr; return new FunctionCallExpression(TraversalStepType.FILTER, parent, FILTER_METHOD, closureExpr);
} }
private GroovyExpression escapePropertyValue(GroovyExpression propertyValue) { private GroovyExpression escapePropertyValue(GroovyExpression propertyValue) {
......
...@@ -250,9 +250,8 @@ public class Gremlin3ExpressionFactory extends GremlinExpressionFactory { ...@@ -250,9 +250,8 @@ public class Gremlin3ExpressionFactory extends GremlinExpressionFactory {
GroovyExpression nameExpr = new FieldExpression(itExpr, propertyName); GroovyExpression nameExpr = new FieldExpression(itExpr, propertyName);
GroovyExpression matchesExpr = new FunctionCallExpression(nameExpr, MATCHES, escapePropertyValue(propertyValue)); GroovyExpression matchesExpr = new FunctionCallExpression(nameExpr, MATCHES, escapePropertyValue(propertyValue));
GroovyExpression closureExpr = new ClosureExpression(matchesExpr); GroovyExpression closureExpr = new ClosureExpression(matchesExpr);
GroovyExpression filterExpr = new FunctionCallExpression(parent, FILTER_METHOD, closureExpr);
return filterExpr; return new FunctionCallExpression(TraversalStepType.FILTER, parent, FILTER_METHOD, closureExpr);
} }
private GroovyExpression escapePropertyValue(GroovyExpression propertyValue) { private GroovyExpression escapePropertyValue(GroovyExpression propertyValue) {
......
...@@ -290,6 +290,9 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { ...@@ -290,6 +290,9 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest {
{"hive_db where hive_db.name like \"R???rt?*\" or hive_db.name like \"S?l?s\" or hive_db.name like\"Log*\"", 3}, {"hive_db where hive_db.name like \"R???rt?*\" or hive_db.name like \"S?l?s\" or hive_db.name like\"Log*\"", 3},
{"hive_db where hive_db.name like \"R???rt?*\" and hive_db.name like \"S?l?s\" and hive_db.name like\"Log*\"", 0}, {"hive_db where hive_db.name like \"R???rt?*\" and hive_db.name like \"S?l?s\" and hive_db.name like\"Log*\"", 0},
{"hive_table where name like 'sales*', db where name like 'Sa?es'", 1}, {"hive_table where name like 'sales*', db where name like 'Sa?es'", 1},
{"hive_table where name like 'sales*' and db.name like 'Sa?es'", 1},
{"hive_table where db.name like \"Sa*\"", 4},
{"hive_table where db.name like \"Sa*\" and name like \"*dim\"", 3},
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment