ATLAS-4300 : DSL Search : Support search by classification and its attribute
Signed-off-by: Pinal <pinal-shah>
diff --git a/docs/src/documents/Search/SearchAdvanced.md b/docs/src/documents/Search/SearchAdvanced.md
index 45e6367..c22981e 100644
--- a/docs/src/documents/Search/SearchAdvanced.md
+++ b/docs/src/documents/Search/SearchAdvanced.md
@@ -110,6 +110,13 @@
{`Table where columns.name="sales"`}
</SyntaxHighlighter>
+Example: To retrieve all the entities of type _Table_ that are tagged with _Dimension_ classification and its attribute _priority_ having 'high'
+
+<SyntaxHighlighter wrapLines={true} language="sql" style={theme.dark}>
+{`Table where Dimension.priority = "high"`}
+</SyntaxHighlighter>
+
+
### Using Date Literals
Dates used in literals need to be specified using the ISO 8601 format.
@@ -225,6 +232,14 @@
{`Dimension`}
</SyntaxHighlighter>
+To search for all entities having a particular classification with its attribute, add filter in where clause.
+
+Example: To retrieve all the entities that are tagged with _Dimension_ classification and its attribute _priority_ having 'high'
+
+<SyntaxHighlighter wrapLines={true} language="sql" style={theme.dark}>
+{`Dimension where Dimension.priority = "high"`}
+</SyntaxHighlighter>
+
###Non Primitive attribute Filtering
In the discussion so far we looked at where clauses with primitive types. This section will look at using properties that are non-primitive types.
diff --git a/repository/src/main/java/org/apache/atlas/query/DSLVisitor.java b/repository/src/main/java/org/apache/atlas/query/DSLVisitor.java
index 80250fb..733d468 100644
--- a/repository/src/main/java/org/apache/atlas/query/DSLVisitor.java
+++ b/repository/src/main/java/org/apache/atlas/query/DSLVisitor.java
@@ -48,6 +48,7 @@
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -257,7 +258,27 @@
if (CollectionUtils.isNotEmpty(expr.exprRight())) {
processExprRight(expr, gremlinQueryComposer);
} else {
+ GremlinQueryComposer original = gremlinQueryComposer.newInstance();
+ original.addAll(gremlinQueryComposer.getQueryClauses());
+
processExpr(expr.compE(), gremlinQueryComposer);
+
+ if (gremlinQueryComposer.hasAnyTraitAttributeClause()) {
+ gremlinQueryComposer.addAll(original.getQueryClauses());
+ processExprForTrait(expr, gremlinQueryComposer);
+ }
+
+ }
+ }
+
+ private void processExprForTrait(final ExprContext expr, GremlinQueryComposer gremlinQueryComposer) {
+ //add AND clause
+ GremlinQueryComposer nestedProcessor = gremlinQueryComposer.createNestedProcessor();
+ processExpr(expr.compE(), nestedProcessor);
+
+ GremlinClauseList clauseList = nestedProcessor.getQueryClauses();
+ if (clauseList.size() > 1) {
+ gremlinQueryComposer.addAndClauses(Collections.singletonList(nestedProcessor));
}
}
diff --git a/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java b/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java
index cff7aff..bc39302 100644
--- a/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java
+++ b/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java
@@ -30,6 +30,7 @@
import org.apache.atlas.type.AtlasStructType;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import java.text.DateFormat;
@@ -82,6 +83,7 @@
private final int providedOffset;
private final Context context;
private final GremlinQueryComposer parent;
+ private boolean hasTrait = false;
public GremlinQueryComposer(Lookup registryLookup, Context context, AtlasDSL.QueryMetadata qmd, int limit, int offset, GremlinQueryComposer parent) {
this.lookup = registryLookup;
@@ -179,6 +181,12 @@
public void addWhere(String lhs, String operator, String rhs) {
String currentType = context.getActiveTypeName();
+
+ //in case if trait type is registered and lhs has trait attributes
+ if (currentType != null && lookup.isTraitType(currentType)) {
+ context.setActiveTypeToUnknown();
+ }
+
IdentifierHelper.Info org = null;
IdentifierHelper.Info lhsI = createInfo(lhs);
boolean rhsIsNotDateOrNumOrBool = false;
@@ -190,6 +198,10 @@
lhsI = createInfo(lhs);
lhsI.setTypeName(org.getTypeName());
+
+ if (org.isTrait()) {
+ setHasTrait();
+ }
}
if (!context.validator.isValidQualifiedName(lhsI.getQualifiedName(), lhsI.getRaw())) {
@@ -254,6 +266,10 @@
}
}
+ private void setHasTrait() {
+ this.hasTrait = true;
+ }
+
private void addForIsIncompleteClause(IdentifierHelper.Info lhsI,SearchParameters.Operator op, String rhs ) {
GremlinClause clause = GremlinClause.HAS_OPERATOR;
@@ -348,6 +364,10 @@
return new GremlinQueryComposer(lookup, this.context, queryMetadata, this.providedLimit, this.providedOffset, this);
}
+ public GremlinQueryComposer newInstance() {
+ return new GremlinQueryComposer(lookup, new Context(lookup), queryMetadata, this.providedLimit, this.providedOffset, null);
+ }
+
public void addFromAlias(String typeName, String alias) {
addFrom(typeName);
addAsClause(alias);
@@ -728,6 +748,19 @@
queryClauses.add(gv);
}
+ public void addAll(GremlinClauseList gcList) {
+ if (gcList != null) {
+ List<GremlinQueryComposer.GremlinClauseValue> list = gcList.getList();
+
+ if (CollectionUtils.isNotEmpty(list)) {
+ queryClauses.clear();
+ for (GremlinClauseValue value : list) {
+ queryClauses.add(value);
+ }
+ }
+ }
+ }
+
private void add(int idx, GremlinClause clause, String... args) {
queryClauses.add(idx, new GremlinClauseValue(clause, args));
}
@@ -748,6 +781,10 @@
return this.context.selectClauseComposer;
}
+ public boolean hasAnyTraitAttributeClause() {
+ return this.hasTrait;
+ }
+
public static class GremlinClauseValue {
private final GremlinClause clause;
private final String value;
@@ -820,6 +857,10 @@
}
}
+ public void setActiveTypeToUnknown() {
+ activeType = UNKNOWN_TYPE;
+ }
+
public void registerActive(IdentifierHelper.Info info) {
if (validator.check(StringUtils.isNotEmpty(info.getTypeName()),
AtlasErrorCode.INVALID_DSL_UNKNOWN_TYPE, info.getRaw())) {
diff --git a/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java b/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java
index d2906ea..fa2217b 100644
--- a/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java
+++ b/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java
@@ -31,6 +31,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static org.apache.atlas.repository.Constants.CLASSIFICATION_LABEL;
+
public class IdentifierHelper {
private static final Pattern SINGLE_QUOTED_IDENTIFIER = Pattern.compile("'(\\w[\\w\\d\\.\\s]*)'");
@@ -186,7 +188,7 @@
updateTypeInfo(lookup, context);
setIsTrait(context, lookup, attributeName);
updateEdgeInfo(lookup, context);
- introduceType = !isPrimitive() && !context.hasAlias(parts[0]);
+ introduceType = (!isPrimitive() && !context.hasAlias(parts[0])) || isTrait;
updateSubTypes(lookup, context);
}
} catch (NullPointerException ex) {
@@ -213,8 +215,11 @@
private void updateEdgeInfo(org.apache.atlas.query.Lookup lookup, GremlinQueryComposer.Context context) {
if (!isPrimitive && !isTrait && typeName != attributeName) {
edgeDirection = lookup.getRelationshipEdgeDirection(context, attributeName);
- edgeLabel = lookup.getRelationshipEdgeLabel(context, attributeName);
- typeName = lookup.getTypeFromEdge(context, attributeName);
+ edgeLabel = lookup.getRelationshipEdgeLabel(context, attributeName);
+ typeName = lookup.getTypeFromEdge(context, attributeName);
+ } else if (isTrait) {
+ edgeDirection = AtlasRelationshipEdgeDirection.OUT;
+ edgeLabel = CLASSIFICATION_LABEL;
}
}
@@ -249,8 +254,11 @@
typeName = context.hasAlias(parts[0]) ?
context.getTypeNameFromAlias(parts[0]) :
parts[0];
-
- attributeName = parts[1];
+ if (typeName != null && lookup.isTraitType(typeName) && !typeName.equals(context.getActiveTypeName())) {
+ attributeName = typeName;
+ } else {
+ attributeName = parts[1];
+ }
}
}
diff --git a/repository/src/main/java/org/apache/atlas/query/RegistryBasedLookup.java b/repository/src/main/java/org/apache/atlas/query/RegistryBasedLookup.java
index eb3c349..57545ea 100644
--- a/repository/src/main/java/org/apache/atlas/query/RegistryBasedLookup.java
+++ b/repository/src/main/java/org/apache/atlas/query/RegistryBasedLookup.java
@@ -71,7 +71,11 @@
@Override
public String getQualifiedName(GremlinQueryComposer.Context context, String name) throws AtlasBaseException {
- AtlasEntityType et = context.getActiveEntityType();
+ AtlasStructType et = context.getActiveEntityType();
+ if (et == null && isClassificationType(context)) {
+ et = (AtlasClassificationType) context.getActiveType();
+ }
+
if (et == null) {
return "";
}
@@ -81,8 +85,12 @@
@Override
public boolean isPrimitive(GremlinQueryComposer.Context context, String attributeName) {
- AtlasEntityType et = context.getActiveEntityType();
- if(et == null) {
+ AtlasStructType et = context.getActiveEntityType();
+ if (et == null && isClassificationType(context)) {
+ et = (AtlasClassificationType) context.getActiveType();
+ }
+
+ if (et == null) {
return false;
}
@@ -140,9 +148,12 @@
@Override
public boolean hasAttribute(GremlinQueryComposer.Context context, String typeName) {
- AtlasEntityType entityType = context.getActiveEntityType();
+ AtlasStructType type = context.getActiveEntityType();
- return getAttribute(entityType, typeName) != null;
+ if (type == null && isClassificationType(context)) {
+ type = (AtlasClassificationType) context.getActiveType();
+ }
+ return getAttribute(type, typeName) != null;
}
@Override
@@ -269,23 +280,41 @@
return attribute.getVertexPropertyName();
}
- private AtlasStructType.AtlasAttribute getAttribute(AtlasEntityType entityType, String attrName) {
+ private AtlasStructType.AtlasAttribute getAttribute(AtlasStructType type, String attrName) {
AtlasStructType.AtlasAttribute ret = null;
- if (entityType != null) {
+ if (type == null) {
+ return ret;
+ }
+
+ if (type instanceof AtlasEntityType) {
+ AtlasEntityType entityType = (AtlasEntityType) type;
ret = entityType.getAttribute(attrName);
if (ret == null) {
ret = entityType.getRelationshipAttribute(attrName, null);
}
+
+ return ret;
+ }
+
+ if (type instanceof AtlasClassificationType) {
+ AtlasClassificationType classificationType = (AtlasClassificationType) type;
+ return classificationType.getAttribute(attrName);
+
}
return ret;
}
- private AtlasType getAttributeType(AtlasEntityType entityType, String attrName) {
+ private AtlasType getAttributeType(AtlasStructType entityType, String attrName) {
AtlasStructType.AtlasAttribute attribute = getAttribute(entityType, attrName);
return attribute != null ? attribute.getAttributeType() : null;
}
+
+ private boolean isClassificationType(GremlinQueryComposer.Context context) {
+ return context.getActiveType() instanceof AtlasClassificationType;
+ }
+
}
diff --git a/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLLexer.java b/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLLexer.java
index 4091fe9..0a60b7d 100644
--- a/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLLexer.java
+++ b/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLLexer.java
@@ -24,7 +24,7 @@
K_RBRACKET=19, K_LT=20, K_LTE=21, K_EQ=22, K_NEQ=23, K_GT=24, K_GTE=25,
K_FROM=26, K_WHERE=27, K_ORDERBY=28, K_GROUPBY=29, K_LIMIT=30, K_SELECT=31,
K_MAX=32, K_MIN=33, K_SUM=34, K_COUNT=35, K_OFFSET=36, K_AS=37, K_ISA=38,
- K_IS=39, K_HAS=40, K_ASC=41, K_DESC=42, K_TRUE=43, K_FALSE=44, K_HASTERM=45,
+ K_IS=39, K_HAS=40, K_ASC=41, K_DESC=42, K_TRUE=43, K_FALSE=44, K_HASTERM=45,
KEYWORD=46, ID=47, STRING=48;
public static String[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
@@ -36,15 +36,15 @@
private static String[] makeRuleNames() {
return new String[] {
- "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
- "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "DIGIT",
- "LETTER", "SINGLE_LINE_COMMENT", "MULTILINE_COMMENT", "WS", "NUMBER",
- "FLOATING_NUMBER", "BOOL", "K_COMMA", "K_PLUS", "K_MINUS", "K_STAR",
- "K_DIV", "K_DOT", "K_LIKE", "K_AND", "K_OR", "K_LPAREN", "K_LBRACKET",
- "K_RPAREN", "K_RBRACKET", "K_LT", "K_LTE", "K_EQ", "K_NEQ", "K_GT", "K_GTE",
- "K_FROM", "K_WHERE", "K_ORDERBY", "K_GROUPBY", "K_LIMIT", "K_SELECT",
- "K_MAX", "K_MIN", "K_SUM", "K_COUNT", "K_OFFSET", "K_AS", "K_ISA", "K_IS",
- "K_HAS", "K_ASC", "K_DESC", "K_TRUE", "K_FALSE", "K_HASTERM", "KEYWORD",
+ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
+ "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "DIGIT",
+ "LETTER", "SINGLE_LINE_COMMENT", "MULTILINE_COMMENT", "WS", "NUMBER",
+ "FLOATING_NUMBER", "BOOL", "K_COMMA", "K_PLUS", "K_MINUS", "K_STAR",
+ "K_DIV", "K_DOT", "K_LIKE", "K_AND", "K_OR", "K_LPAREN", "K_LBRACKET",
+ "K_RPAREN", "K_RBRACKET", "K_LT", "K_LTE", "K_EQ", "K_NEQ", "K_GT", "K_GTE",
+ "K_FROM", "K_WHERE", "K_ORDERBY", "K_GROUPBY", "K_LIMIT", "K_SELECT",
+ "K_MAX", "K_MIN", "K_SUM", "K_COUNT", "K_OFFSET", "K_AS", "K_ISA", "K_IS",
+ "K_HAS", "K_ASC", "K_DESC", "K_TRUE", "K_FALSE", "K_HASTERM", "KEYWORD",
"ID", "STRING"
};
}
@@ -52,19 +52,19 @@
private static String[] makeLiteralNames() {
return new String[] {
- null, null, null, null, null, null, null, "','", "'+'", "'-'", "'*'",
+ null, null, null, null, null, null, null, "','", "'+'", "'-'", "'*'",
"'/'", "'.'", null, null, null, "'('", "'['", "')'", "']'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
- null, "SINGLE_LINE_COMMENT", "MULTILINE_COMMENT", "WS", "NUMBER", "FLOATING_NUMBER",
- "BOOL", "K_COMMA", "K_PLUS", "K_MINUS", "K_STAR", "K_DIV", "K_DOT", "K_LIKE",
- "K_AND", "K_OR", "K_LPAREN", "K_LBRACKET", "K_RPAREN", "K_RBRACKET",
- "K_LT", "K_LTE", "K_EQ", "K_NEQ", "K_GT", "K_GTE", "K_FROM", "K_WHERE",
- "K_ORDERBY", "K_GROUPBY", "K_LIMIT", "K_SELECT", "K_MAX", "K_MIN", "K_SUM",
- "K_COUNT", "K_OFFSET", "K_AS", "K_ISA", "K_IS", "K_HAS", "K_ASC", "K_DESC",
+ null, "SINGLE_LINE_COMMENT", "MULTILINE_COMMENT", "WS", "NUMBER", "FLOATING_NUMBER",
+ "BOOL", "K_COMMA", "K_PLUS", "K_MINUS", "K_STAR", "K_DIV", "K_DOT", "K_LIKE",
+ "K_AND", "K_OR", "K_LPAREN", "K_LBRACKET", "K_RPAREN", "K_RBRACKET",
+ "K_LT", "K_LTE", "K_EQ", "K_NEQ", "K_GT", "K_GTE", "K_FROM", "K_WHERE",
+ "K_ORDERBY", "K_GROUPBY", "K_LIMIT", "K_SELECT", "K_MAX", "K_MIN", "K_SUM",
+ "K_COUNT", "K_OFFSET", "K_AS", "K_ISA", "K_IS", "K_HAS", "K_ASC", "K_DESC",
"K_TRUE", "K_FALSE", "K_HASTERM", "KEYWORD", "ID", "STRING"
};
}
diff --git a/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLParser.g4 b/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLParser.g4
index 4bdf479..3db789e 100644
--- a/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLParser.g4
+++ b/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLParser.g4
@@ -48,7 +48,7 @@
comparisonClause: arithE operator arithE ;
-isClause: arithE (K_ISA | K_IS) identifier ;
+isClause: arithE (K_ISA | K_IS) (identifier | expr ) ;
hasTermClause: arithE K_HASTERM (identifier | expr );
diff --git a/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLParser.java b/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLParser.java
index 04f602c..02b3192 100644
--- a/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLParser.java
+++ b/repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLParser.java
@@ -22,29 +22,29 @@
K_RBRACKET=19, K_LT=20, K_LTE=21, K_EQ=22, K_NEQ=23, K_GT=24, K_GTE=25,
K_FROM=26, K_WHERE=27, K_ORDERBY=28, K_GROUPBY=29, K_LIMIT=30, K_SELECT=31,
K_MAX=32, K_MIN=33, K_SUM=34, K_COUNT=35, K_OFFSET=36, K_AS=37, K_ISA=38,
- K_IS=39, K_HAS=40, K_ASC=41, K_DESC=42, K_TRUE=43, K_FALSE=44, K_HASTERM=45,
+ K_IS=39, K_HAS=40, K_ASC=41, K_DESC=42, K_TRUE=43, K_FALSE=44, K_HASTERM=45,
KEYWORD=46, ID=47, STRING=48;
public static final int
RULE_identifier = 0, RULE_operator = 1, RULE_sortOrder = 2, RULE_valueArray = 3,
RULE_literal = 4, RULE_limitClause = 5, RULE_offsetClause = 6, RULE_atomE = 7,
RULE_multiERight = 8, RULE_multiE = 9, RULE_arithERight = 10, RULE_arithE = 11,
- RULE_comparisonClause = 12, RULE_isClause = 13, RULE_hasTermClause = 14,
- RULE_hasClause = 15, RULE_countClause = 16, RULE_maxClause = 17, RULE_minClause = 18,
- RULE_sumClause = 19, RULE_exprRight = 20, RULE_compE = 21, RULE_expr = 22,
- RULE_limitOffset = 23, RULE_selectExpression = 24, RULE_selectExpr = 25,
- RULE_aliasExpr = 26, RULE_orderByExpr = 27, RULE_fromSrc = 28, RULE_whereClause = 29,
- RULE_fromExpression = 30, RULE_fromClause = 31, RULE_selectClause = 32,
- RULE_singleQrySrc = 33, RULE_groupByExpression = 34, RULE_commaDelimitedQueries = 35,
+ RULE_comparisonClause = 12, RULE_isClause = 13, RULE_hasTermClause = 14,
+ RULE_hasClause = 15, RULE_countClause = 16, RULE_maxClause = 17, RULE_minClause = 18,
+ RULE_sumClause = 19, RULE_exprRight = 20, RULE_compE = 21, RULE_expr = 22,
+ RULE_limitOffset = 23, RULE_selectExpression = 24, RULE_selectExpr = 25,
+ RULE_aliasExpr = 26, RULE_orderByExpr = 27, RULE_fromSrc = 28, RULE_whereClause = 29,
+ RULE_fromExpression = 30, RULE_fromClause = 31, RULE_selectClause = 32,
+ RULE_singleQrySrc = 33, RULE_groupByExpression = 34, RULE_commaDelimitedQueries = 35,
RULE_spaceDelimitedQueries = 36, RULE_querySrc = 37, RULE_query = 38;
private static String[] makeRuleNames() {
return new String[] {
- "identifier", "operator", "sortOrder", "valueArray", "literal", "limitClause",
- "offsetClause", "atomE", "multiERight", "multiE", "arithERight", "arithE",
- "comparisonClause", "isClause", "hasTermClause", "hasClause", "countClause",
- "maxClause", "minClause", "sumClause", "exprRight", "compE", "expr",
- "limitOffset", "selectExpression", "selectExpr", "aliasExpr", "orderByExpr",
- "fromSrc", "whereClause", "fromExpression", "fromClause", "selectClause",
- "singleQrySrc", "groupByExpression", "commaDelimitedQueries", "spaceDelimitedQueries",
+ "identifier", "operator", "sortOrder", "valueArray", "literal", "limitClause",
+ "offsetClause", "atomE", "multiERight", "multiE", "arithERight", "arithE",
+ "comparisonClause", "isClause", "hasTermClause", "hasClause", "countClause",
+ "maxClause", "minClause", "sumClause", "exprRight", "compE", "expr",
+ "limitOffset", "selectExpression", "selectExpr", "aliasExpr", "orderByExpr",
+ "fromSrc", "whereClause", "fromExpression", "fromClause", "selectClause",
+ "singleQrySrc", "groupByExpression", "commaDelimitedQueries", "spaceDelimitedQueries",
"querySrc", "query"
};
}
@@ -52,19 +52,19 @@
private static String[] makeLiteralNames() {
return new String[] {
- null, null, null, null, null, null, null, "','", "'+'", "'-'", "'*'",
+ null, null, null, null, null, null, null, "','", "'+'", "'-'", "'*'",
"'/'", "'.'", null, null, null, "'('", "'['", "')'", "']'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
- null, "SINGLE_LINE_COMMENT", "MULTILINE_COMMENT", "WS", "NUMBER", "FLOATING_NUMBER",
- "BOOL", "K_COMMA", "K_PLUS", "K_MINUS", "K_STAR", "K_DIV", "K_DOT", "K_LIKE",
- "K_AND", "K_OR", "K_LPAREN", "K_LBRACKET", "K_RPAREN", "K_RBRACKET",
- "K_LT", "K_LTE", "K_EQ", "K_NEQ", "K_GT", "K_GTE", "K_FROM", "K_WHERE",
- "K_ORDERBY", "K_GROUPBY", "K_LIMIT", "K_SELECT", "K_MAX", "K_MIN", "K_SUM",
- "K_COUNT", "K_OFFSET", "K_AS", "K_ISA", "K_IS", "K_HAS", "K_ASC", "K_DESC",
+ null, "SINGLE_LINE_COMMENT", "MULTILINE_COMMENT", "WS", "NUMBER", "FLOATING_NUMBER",
+ "BOOL", "K_COMMA", "K_PLUS", "K_MINUS", "K_STAR", "K_DIV", "K_DOT", "K_LIKE",
+ "K_AND", "K_OR", "K_LPAREN", "K_LBRACKET", "K_RPAREN", "K_RBRACKET",
+ "K_LT", "K_LTE", "K_EQ", "K_NEQ", "K_GT", "K_GTE", "K_FROM", "K_WHERE",
+ "K_ORDERBY", "K_GROUPBY", "K_LIMIT", "K_SELECT", "K_MAX", "K_MIN", "K_SUM",
+ "K_COUNT", "K_OFFSET", "K_AS", "K_ISA", "K_IS", "K_HAS", "K_ASC", "K_DESC",
"K_TRUE", "K_FALSE", "K_HASTERM", "KEYWORD", "ID", "STRING"
};
}
@@ -917,11 +917,14 @@
public ArithEContext arithE() {
return getRuleContext(ArithEContext.class,0);
}
+ public TerminalNode K_ISA() { return getToken(AtlasDSLParser.K_ISA, 0); }
+ public TerminalNode K_IS() { return getToken(AtlasDSLParser.K_IS, 0); }
public IdentifierContext identifier() {
return getRuleContext(IdentifierContext.class,0);
}
- public TerminalNode K_ISA() { return getToken(AtlasDSLParser.K_ISA, 0); }
- public TerminalNode K_IS() { return getToken(AtlasDSLParser.K_IS, 0); }
+ public ExprContext expr() {
+ return getRuleContext(ExprContext.class,0);
+ }
public IsClauseContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@@ -960,8 +963,22 @@
_errHandler.reportMatch(this);
consume();
}
- setState(146);
- identifier();
+ setState(148);
+ _errHandler.sync(this);
+ switch ( getInterpreter().adaptivePredict(_input,7,_ctx) ) {
+ case 1:
+ {
+ setState(146);
+ identifier();
+ }
+ break;
+ case 2:
+ {
+ setState(147);
+ expr();
+ }
+ break;
+ }
}
}
catch (RecognitionException re) {
@@ -1011,22 +1028,22 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(148);
+ setState(150);
arithE();
- setState(149);
+ setState(151);
match(K_HASTERM);
- setState(152);
+ setState(154);
_errHandler.sync(this);
- switch ( getInterpreter().adaptivePredict(_input,7,_ctx) ) {
+ switch ( getInterpreter().adaptivePredict(_input,8,_ctx) ) {
case 1:
{
- setState(150);
+ setState(152);
identifier();
}
break;
case 2:
{
- setState(151);
+ setState(153);
expr();
}
break;
@@ -1077,11 +1094,11 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(154);
- arithE();
- setState(155);
- match(K_HAS);
setState(156);
+ arithE();
+ setState(157);
+ match(K_HAS);
+ setState(158);
identifier();
}
}
@@ -1125,11 +1142,11 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(158);
- match(K_COUNT);
- setState(159);
- match(K_LPAREN);
setState(160);
+ match(K_COUNT);
+ setState(161);
+ match(K_LPAREN);
+ setState(162);
match(K_RPAREN);
}
}
@@ -1176,13 +1193,13 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(162);
- match(K_MAX);
- setState(163);
- match(K_LPAREN);
setState(164);
- expr();
+ match(K_MAX);
setState(165);
+ match(K_LPAREN);
+ setState(166);
+ expr();
+ setState(167);
match(K_RPAREN);
}
}
@@ -1229,13 +1246,13 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(167);
- match(K_MIN);
- setState(168);
- match(K_LPAREN);
setState(169);
- expr();
+ match(K_MIN);
setState(170);
+ match(K_LPAREN);
+ setState(171);
+ expr();
+ setState(172);
match(K_RPAREN);
}
}
@@ -1282,13 +1299,13 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(172);
- match(K_SUM);
- setState(173);
- match(K_LPAREN);
setState(174);
- expr();
+ match(K_SUM);
setState(175);
+ match(K_LPAREN);
+ setState(176);
+ expr();
+ setState(177);
match(K_RPAREN);
}
}
@@ -1335,7 +1352,7 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(177);
+ setState(179);
_la = _input.LA(1);
if ( !(_la==K_AND || _la==K_OR) ) {
_errHandler.recoverInline(this);
@@ -1345,7 +1362,7 @@
_errHandler.reportMatch(this);
consume();
}
- setState(178);
+ setState(180);
compE();
}
}
@@ -1411,69 +1428,69 @@
CompEContext _localctx = new CompEContext(_ctx, getState());
enterRule(_localctx, 42, RULE_compE);
try {
- setState(189);
+ setState(191);
_errHandler.sync(this);
- switch ( getInterpreter().adaptivePredict(_input,8,_ctx) ) {
+ switch ( getInterpreter().adaptivePredict(_input,9,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
- setState(180);
+ setState(182);
comparisonClause();
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
- setState(181);
+ setState(183);
isClause();
}
break;
case 3:
enterOuterAlt(_localctx, 3);
{
- setState(182);
+ setState(184);
hasClause();
}
break;
case 4:
enterOuterAlt(_localctx, 4);
{
- setState(183);
+ setState(185);
arithE();
}
break;
case 5:
enterOuterAlt(_localctx, 5);
{
- setState(184);
+ setState(186);
countClause();
}
break;
case 6:
enterOuterAlt(_localctx, 6);
{
- setState(185);
+ setState(187);
maxClause();
}
break;
case 7:
enterOuterAlt(_localctx, 7);
{
- setState(186);
+ setState(188);
minClause();
}
break;
case 8:
enterOuterAlt(_localctx, 8);
{
- setState(187);
+ setState(189);
sumClause();
}
break;
case 9:
enterOuterAlt(_localctx, 9);
{
- setState(188);
+ setState(190);
hasTermClause();
}
break;
@@ -1526,23 +1543,23 @@
int _alt;
enterOuterAlt(_localctx, 1);
{
- setState(191);
+ setState(193);
compE();
- setState(195);
+ setState(197);
_errHandler.sync(this);
- _alt = getInterpreter().adaptivePredict(_input,9,_ctx);
+ _alt = getInterpreter().adaptivePredict(_input,10,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
- setState(192);
+ setState(194);
exprRight();
}
- }
+ }
}
- setState(197);
+ setState(199);
_errHandler.sync(this);
- _alt = getInterpreter().adaptivePredict(_input,9,_ctx);
+ _alt = getInterpreter().adaptivePredict(_input,10,_ctx);
}
}
}
@@ -1590,14 +1607,14 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(198);
- limitClause();
setState(200);
+ limitClause();
+ setState(202);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==K_OFFSET) {
{
- setState(199);
+ setState(201);
offsetClause();
}
}
@@ -1649,16 +1666,16 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(202);
+ setState(204);
expr();
- setState(205);
+ setState(207);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==K_AS) {
{
- setState(203);
+ setState(205);
match(K_AS);
- setState(204);
+ setState(206);
identifier();
}
}
@@ -1713,21 +1730,21 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(207);
+ setState(209);
selectExpression();
- setState(212);
+ setState(214);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==K_COMMA) {
{
{
- setState(208);
+ setState(210);
match(K_COMMA);
- setState(209);
+ setState(211);
selectExpression();
}
}
- setState(214);
+ setState(216);
_errHandler.sync(this);
_la = _input.LA(1);
}
@@ -1780,25 +1797,25 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(217);
+ setState(219);
_errHandler.sync(this);
- switch ( getInterpreter().adaptivePredict(_input,13,_ctx) ) {
+ switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) {
case 1:
{
- setState(215);
+ setState(217);
identifier();
}
break;
case 2:
{
- setState(216);
+ setState(218);
literal();
}
break;
}
- setState(219);
+ setState(221);
match(K_AS);
- setState(220);
+ setState(222);
identifier();
}
}
@@ -1847,16 +1864,16 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(222);
+ setState(224);
match(K_ORDERBY);
- setState(223);
- expr();
setState(225);
+ expr();
+ setState(227);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==K_ASC || _la==K_DESC) {
{
- setState(224);
+ setState(226);
sortOrder();
}
}
@@ -1907,31 +1924,31 @@
FromSrcContext _localctx = new FromSrcContext(_ctx, getState());
enterRule(_localctx, 56, RULE_fromSrc);
try {
- setState(232);
+ setState(234);
_errHandler.sync(this);
- switch ( getInterpreter().adaptivePredict(_input,16,_ctx) ) {
+ switch ( getInterpreter().adaptivePredict(_input,17,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
- setState(227);
+ setState(229);
aliasExpr();
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
- setState(230);
+ setState(232);
_errHandler.sync(this);
- switch ( getInterpreter().adaptivePredict(_input,15,_ctx) ) {
+ switch ( getInterpreter().adaptivePredict(_input,16,_ctx) ) {
case 1:
{
- setState(228);
+ setState(230);
identifier();
}
break;
case 2:
{
- setState(229);
+ setState(231);
literal();
}
break;
@@ -1981,9 +1998,9 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(234);
+ setState(236);
match(K_WHERE);
- setState(235);
+ setState(237);
expr();
}
}
@@ -2030,14 +2047,14 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(237);
- fromSrc();
setState(239);
+ fromSrc();
+ setState(241);
_errHandler.sync(this);
- switch ( getInterpreter().adaptivePredict(_input,17,_ctx) ) {
+ switch ( getInterpreter().adaptivePredict(_input,18,_ctx) ) {
case 1:
{
- setState(238);
+ setState(240);
whereClause();
}
break;
@@ -2085,9 +2102,9 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(241);
+ setState(243);
match(K_FROM);
- setState(242);
+ setState(244);
fromExpression();
}
}
@@ -2132,9 +2149,9 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(244);
+ setState(246);
match(K_SELECT);
- setState(245);
+ setState(247);
selectExpr();
}
}
@@ -2185,34 +2202,34 @@
SingleQrySrcContext _localctx = new SingleQrySrcContext(_ctx, getState());
enterRule(_localctx, 66, RULE_singleQrySrc);
try {
- setState(251);
+ setState(253);
_errHandler.sync(this);
- switch ( getInterpreter().adaptivePredict(_input,18,_ctx) ) {
+ switch ( getInterpreter().adaptivePredict(_input,19,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
- setState(247);
+ setState(249);
fromClause();
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
- setState(248);
+ setState(250);
whereClause();
}
break;
case 3:
enterOuterAlt(_localctx, 3);
{
- setState(249);
+ setState(251);
fromExpression();
}
break;
case 4:
enterOuterAlt(_localctx, 4);
{
- setState(250);
+ setState(252);
expr();
}
break;
@@ -2261,13 +2278,13 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(253);
- match(K_GROUPBY);
- setState(254);
- match(K_LPAREN);
setState(255);
- selectExpr();
+ match(K_GROUPBY);
setState(256);
+ match(K_LPAREN);
+ setState(257);
+ selectExpr();
+ setState(258);
match(K_RPAREN);
}
}
@@ -2319,21 +2336,21 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(258);
+ setState(260);
singleQrySrc();
- setState(263);
+ setState(265);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==K_COMMA) {
{
{
- setState(259);
+ setState(261);
match(K_COMMA);
- setState(260);
+ setState(262);
singleQrySrc();
}
}
- setState(265);
+ setState(267);
_errHandler.sync(this);
_la = _input.LA(1);
}
@@ -2383,19 +2400,19 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(266);
+ setState(268);
singleQrySrc();
- setState(270);
+ setState(272);
_errHandler.sync(this);
_la = _input.LA(1);
while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NUMBER) | (1L << FLOATING_NUMBER) | (1L << BOOL) | (1L << K_LPAREN) | (1L << K_LBRACKET) | (1L << K_FROM) | (1L << K_WHERE) | (1L << K_MAX) | (1L << K_MIN) | (1L << K_SUM) | (1L << K_COUNT) | (1L << ID))) != 0)) {
{
{
- setState(267);
+ setState(269);
singleQrySrc();
}
}
- setState(272);
+ setState(274);
_errHandler.sync(this);
_la = _input.LA(1);
}
@@ -2442,20 +2459,20 @@
QuerySrcContext _localctx = new QuerySrcContext(_ctx, getState());
enterRule(_localctx, 74, RULE_querySrc);
try {
- setState(275);
+ setState(277);
_errHandler.sync(this);
- switch ( getInterpreter().adaptivePredict(_input,21,_ctx) ) {
+ switch ( getInterpreter().adaptivePredict(_input,22,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
- setState(273);
+ setState(275);
commaDelimitedQueries();
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
- setState(274);
+ setState(276);
spaceDelimitedQueries();
}
break;
@@ -2515,49 +2532,49 @@
try {
enterOuterAlt(_localctx, 1);
{
- setState(277);
- querySrc();
setState(279);
+ querySrc();
+ setState(281);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==K_GROUPBY) {
{
- setState(278);
+ setState(280);
groupByExpression();
}
}
- setState(282);
+ setState(284);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==K_SELECT) {
{
- setState(281);
+ setState(283);
selectClause();
}
}
- setState(285);
+ setState(287);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==K_ORDERBY) {
{
- setState(284);
+ setState(286);
orderByExpr();
}
}
- setState(288);
+ setState(290);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==K_LIMIT) {
{
- setState(287);
+ setState(289);
limitOffset();
}
}
- setState(290);
+ setState(292);
match(EOF);
}
}
@@ -2573,7 +2590,7 @@
}
public static final String _serializedATN =
- "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\62\u0127\4\2\t\2"+
+ "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\62\u0129\4\2\t\2"+
"\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+
"\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+
"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+
@@ -2583,92 +2600,93 @@
"\6\5\6g\n\6\5\6i\n\6\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\5\ts\n\t\3\t\3\t"+
"\3\t\3\t\5\ty\n\t\3\n\3\n\3\n\3\13\3\13\7\13\u0080\n\13\f\13\16\13\u0083"+
"\13\13\3\f\3\f\3\f\3\r\3\r\7\r\u008a\n\r\f\r\16\r\u008d\13\r\3\16\3\16"+
- "\3\16\3\16\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20\5\20\u009b\n\20\3\21"+
- "\3\21\3\21\3\21\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\24\3\24"+
- "\3\24\3\24\3\24\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3\26\3\27\3\27\3\27"+
- "\3\27\3\27\3\27\3\27\3\27\3\27\5\27\u00c0\n\27\3\30\3\30\7\30\u00c4\n"+
- "\30\f\30\16\30\u00c7\13\30\3\31\3\31\5\31\u00cb\n\31\3\32\3\32\3\32\5"+
- "\32\u00d0\n\32\3\33\3\33\3\33\7\33\u00d5\n\33\f\33\16\33\u00d8\13\33\3"+
- "\34\3\34\5\34\u00dc\n\34\3\34\3\34\3\34\3\35\3\35\3\35\5\35\u00e4\n\35"+
- "\3\36\3\36\3\36\5\36\u00e9\n\36\5\36\u00eb\n\36\3\37\3\37\3\37\3 \3 \5"+
- " \u00f2\n \3!\3!\3!\3\"\3\"\3\"\3#\3#\3#\3#\5#\u00fe\n#\3$\3$\3$\3$\3"+
- "$\3%\3%\3%\7%\u0108\n%\f%\16%\u010b\13%\3&\3&\7&\u010f\n&\f&\16&\u0112"+
- "\13&\3\'\3\'\5\'\u0116\n\'\3(\3(\5(\u011a\n(\3(\5(\u011d\n(\3(\5(\u0120"+
- "\n(\3(\5(\u0123\n(\3(\3(\3(\2\2)\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36"+
- " \"$&(*,.\60\62\64\668:<>@BDFHJLN\2\b\4\2\17\17\26\33\3\2+,\3\2\f\r\3"+
- "\2\n\13\3\2()\3\2\20\21\2\u0124\2P\3\2\2\2\4R\3\2\2\2\6T\3\2\2\2\bV\3"+
- "\2\2\2\nh\3\2\2\2\fj\3\2\2\2\16m\3\2\2\2\20x\3\2\2\2\22z\3\2\2\2\24}\3"+
- "\2\2\2\26\u0084\3\2\2\2\30\u0087\3\2\2\2\32\u008e\3\2\2\2\34\u0092\3\2"+
- "\2\2\36\u0096\3\2\2\2 \u009c\3\2\2\2\"\u00a0\3\2\2\2$\u00a4\3\2\2\2&\u00a9"+
- "\3\2\2\2(\u00ae\3\2\2\2*\u00b3\3\2\2\2,\u00bf\3\2\2\2.\u00c1\3\2\2\2\60"+
- "\u00c8\3\2\2\2\62\u00cc\3\2\2\2\64\u00d1\3\2\2\2\66\u00db\3\2\2\28\u00e0"+
- "\3\2\2\2:\u00ea\3\2\2\2<\u00ec\3\2\2\2>\u00ef\3\2\2\2@\u00f3\3\2\2\2B"+
- "\u00f6\3\2\2\2D\u00fd\3\2\2\2F\u00ff\3\2\2\2H\u0104\3\2\2\2J\u010c\3\2"+
- "\2\2L\u0115\3\2\2\2N\u0117\3\2\2\2PQ\7\61\2\2Q\3\3\2\2\2RS\t\2\2\2S\5"+
- "\3\2\2\2TU\t\3\2\2U\7\3\2\2\2VW\7\23\2\2W\\\7\61\2\2XY\7\t\2\2Y[\7\61"+
- "\2\2ZX\3\2\2\2[^\3\2\2\2\\Z\3\2\2\2\\]\3\2\2\2]_\3\2\2\2^\\\3\2\2\2_`"+
- "\7\25\2\2`\t\3\2\2\2ai\7\b\2\2bi\7\6\2\2ci\7\7\2\2dg\7\61\2\2eg\5\b\5"+
- "\2fd\3\2\2\2fe\3\2\2\2gi\3\2\2\2ha\3\2\2\2hb\3\2\2\2hc\3\2\2\2hf\3\2\2"+
- "\2i\13\3\2\2\2jk\7 \2\2kl\7\6\2\2l\r\3\2\2\2mn\7&\2\2no\7\6\2\2o\17\3"+
- "\2\2\2ps\5\2\2\2qs\5\n\6\2rp\3\2\2\2rq\3\2\2\2sy\3\2\2\2tu\7\22\2\2uv"+
- "\5.\30\2vw\7\24\2\2wy\3\2\2\2xr\3\2\2\2xt\3\2\2\2y\21\3\2\2\2z{\t\4\2"+
- "\2{|\5\20\t\2|\23\3\2\2\2}\u0081\5\20\t\2~\u0080\5\22\n\2\177~\3\2\2\2"+
- "\u0080\u0083\3\2\2\2\u0081\177\3\2\2\2\u0081\u0082\3\2\2\2\u0082\25\3"+
- "\2\2\2\u0083\u0081\3\2\2\2\u0084\u0085\t\5\2\2\u0085\u0086\5\24\13\2\u0086"+
- "\27\3\2\2\2\u0087\u008b\5\24\13\2\u0088\u008a\5\26\f\2\u0089\u0088\3\2"+
- "\2\2\u008a\u008d\3\2\2\2\u008b\u0089\3\2\2\2\u008b\u008c\3\2\2\2\u008c"+
+ "\3\16\3\16\3\17\3\17\3\17\3\17\5\17\u0097\n\17\3\20\3\20\3\20\3\20\5\20"+
+ "\u009d\n\20\3\21\3\21\3\21\3\21\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23"+
+ "\3\23\3\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3\26"+
+ "\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\5\27\u00c2\n\27\3\30\3\30"+
+ "\7\30\u00c6\n\30\f\30\16\30\u00c9\13\30\3\31\3\31\5\31\u00cd\n\31\3\32"+
+ "\3\32\3\32\5\32\u00d2\n\32\3\33\3\33\3\33\7\33\u00d7\n\33\f\33\16\33\u00da"+
+ "\13\33\3\34\3\34\5\34\u00de\n\34\3\34\3\34\3\34\3\35\3\35\3\35\5\35\u00e6"+
+ "\n\35\3\36\3\36\3\36\5\36\u00eb\n\36\5\36\u00ed\n\36\3\37\3\37\3\37\3"+
+ " \3 \5 \u00f4\n \3!\3!\3!\3\"\3\"\3\"\3#\3#\3#\3#\5#\u0100\n#\3$\3$\3"+
+ "$\3$\3$\3%\3%\3%\7%\u010a\n%\f%\16%\u010d\13%\3&\3&\7&\u0111\n&\f&\16"+
+ "&\u0114\13&\3\'\3\'\5\'\u0118\n\'\3(\3(\5(\u011c\n(\3(\5(\u011f\n(\3("+
+ "\5(\u0122\n(\3(\5(\u0125\n(\3(\3(\3(\2\2)\2\4\6\b\n\f\16\20\22\24\26\30"+
+ "\32\34\36 \"$&(*,.\60\62\64\668:<>@BDFHJLN\2\b\4\2\17\17\26\33\3\2+,\3"+
+ "\2\f\r\3\2\n\13\3\2()\3\2\20\21\2\u0127\2P\3\2\2\2\4R\3\2\2\2\6T\3\2\2"+
+ "\2\bV\3\2\2\2\nh\3\2\2\2\fj\3\2\2\2\16m\3\2\2\2\20x\3\2\2\2\22z\3\2\2"+
+ "\2\24}\3\2\2\2\26\u0084\3\2\2\2\30\u0087\3\2\2\2\32\u008e\3\2\2\2\34\u0092"+
+ "\3\2\2\2\36\u0098\3\2\2\2 \u009e\3\2\2\2\"\u00a2\3\2\2\2$\u00a6\3\2\2"+
+ "\2&\u00ab\3\2\2\2(\u00b0\3\2\2\2*\u00b5\3\2\2\2,\u00c1\3\2\2\2.\u00c3"+
+ "\3\2\2\2\60\u00ca\3\2\2\2\62\u00ce\3\2\2\2\64\u00d3\3\2\2\2\66\u00dd\3"+
+ "\2\2\28\u00e2\3\2\2\2:\u00ec\3\2\2\2<\u00ee\3\2\2\2>\u00f1\3\2\2\2@\u00f5"+
+ "\3\2\2\2B\u00f8\3\2\2\2D\u00ff\3\2\2\2F\u0101\3\2\2\2H\u0106\3\2\2\2J"+
+ "\u010e\3\2\2\2L\u0117\3\2\2\2N\u0119\3\2\2\2PQ\7\61\2\2Q\3\3\2\2\2RS\t"+
+ "\2\2\2S\5\3\2\2\2TU\t\3\2\2U\7\3\2\2\2VW\7\23\2\2W\\\7\61\2\2XY\7\t\2"+
+ "\2Y[\7\61\2\2ZX\3\2\2\2[^\3\2\2\2\\Z\3\2\2\2\\]\3\2\2\2]_\3\2\2\2^\\\3"+
+ "\2\2\2_`\7\25\2\2`\t\3\2\2\2ai\7\b\2\2bi\7\6\2\2ci\7\7\2\2dg\7\61\2\2"+
+ "eg\5\b\5\2fd\3\2\2\2fe\3\2\2\2gi\3\2\2\2ha\3\2\2\2hb\3\2\2\2hc\3\2\2\2"+
+ "hf\3\2\2\2i\13\3\2\2\2jk\7 \2\2kl\7\6\2\2l\r\3\2\2\2mn\7&\2\2no\7\6\2"+
+ "\2o\17\3\2\2\2ps\5\2\2\2qs\5\n\6\2rp\3\2\2\2rq\3\2\2\2sy\3\2\2\2tu\7\22"+
+ "\2\2uv\5.\30\2vw\7\24\2\2wy\3\2\2\2xr\3\2\2\2xt\3\2\2\2y\21\3\2\2\2z{"+
+ "\t\4\2\2{|\5\20\t\2|\23\3\2\2\2}\u0081\5\20\t\2~\u0080\5\22\n\2\177~\3"+
+ "\2\2\2\u0080\u0083\3\2\2\2\u0081\177\3\2\2\2\u0081\u0082\3\2\2\2\u0082"+
+ "\25\3\2\2\2\u0083\u0081\3\2\2\2\u0084\u0085\t\5\2\2\u0085\u0086\5\24\13"+
+ "\2\u0086\27\3\2\2\2\u0087\u008b\5\24\13\2\u0088\u008a\5\26\f\2\u0089\u0088"+
+ "\3\2\2\2\u008a\u008d\3\2\2\2\u008b\u0089\3\2\2\2\u008b\u008c\3\2\2\2\u008c"+
"\31\3\2\2\2\u008d\u008b\3\2\2\2\u008e\u008f\5\30\r\2\u008f\u0090\5\4\3"+
- "\2\u0090\u0091\5\30\r\2\u0091\33\3\2\2\2\u0092\u0093\5\30\r\2\u0093\u0094"+
- "\t\6\2\2\u0094\u0095\5\2\2\2\u0095\35\3\2\2\2\u0096\u0097\5\30\r\2\u0097"+
- "\u009a\7/\2\2\u0098\u009b\5\2\2\2\u0099\u009b\5.\30\2\u009a\u0098\3\2"+
- "\2\2\u009a\u0099\3\2\2\2\u009b\37\3\2\2\2\u009c\u009d\5\30\r\2\u009d\u009e"+
- "\7*\2\2\u009e\u009f\5\2\2\2\u009f!\3\2\2\2\u00a0\u00a1\7%\2\2\u00a1\u00a2"+
- "\7\22\2\2\u00a2\u00a3\7\24\2\2\u00a3#\3\2\2\2\u00a4\u00a5\7\"\2\2\u00a5"+
- "\u00a6\7\22\2\2\u00a6\u00a7\5.\30\2\u00a7\u00a8\7\24\2\2\u00a8%\3\2\2"+
- "\2\u00a9\u00aa\7#\2\2\u00aa\u00ab\7\22\2\2\u00ab\u00ac\5.\30\2\u00ac\u00ad"+
- "\7\24\2\2\u00ad\'\3\2\2\2\u00ae\u00af\7$\2\2\u00af\u00b0\7\22\2\2\u00b0"+
- "\u00b1\5.\30\2\u00b1\u00b2\7\24\2\2\u00b2)\3\2\2\2\u00b3\u00b4\t\7\2\2"+
- "\u00b4\u00b5\5,\27\2\u00b5+\3\2\2\2\u00b6\u00c0\5\32\16\2\u00b7\u00c0"+
- "\5\34\17\2\u00b8\u00c0\5 \21\2\u00b9\u00c0\5\30\r\2\u00ba\u00c0\5\"\22"+
- "\2\u00bb\u00c0\5$\23\2\u00bc\u00c0\5&\24\2\u00bd\u00c0\5(\25\2\u00be\u00c0"+
- "\5\36\20\2\u00bf\u00b6\3\2\2\2\u00bf\u00b7\3\2\2\2\u00bf\u00b8\3\2\2\2"+
- "\u00bf\u00b9\3\2\2\2\u00bf\u00ba\3\2\2\2\u00bf\u00bb\3\2\2\2\u00bf\u00bc"+
- "\3\2\2\2\u00bf\u00bd\3\2\2\2\u00bf\u00be\3\2\2\2\u00c0-\3\2\2\2\u00c1"+
- "\u00c5\5,\27\2\u00c2\u00c4\5*\26\2\u00c3\u00c2\3\2\2\2\u00c4\u00c7\3\2"+
- "\2\2\u00c5\u00c3\3\2\2\2\u00c5\u00c6\3\2\2\2\u00c6/\3\2\2\2\u00c7\u00c5"+
- "\3\2\2\2\u00c8\u00ca\5\f\7\2\u00c9\u00cb\5\16\b\2\u00ca\u00c9\3\2\2\2"+
- "\u00ca\u00cb\3\2\2\2\u00cb\61\3\2\2\2\u00cc\u00cf\5.\30\2\u00cd\u00ce"+
- "\7\'\2\2\u00ce\u00d0\5\2\2\2\u00cf\u00cd\3\2\2\2\u00cf\u00d0\3\2\2\2\u00d0"+
- "\63\3\2\2\2\u00d1\u00d6\5\62\32\2\u00d2\u00d3\7\t\2\2\u00d3\u00d5\5\62"+
- "\32\2\u00d4\u00d2\3\2\2\2\u00d5\u00d8\3\2\2\2\u00d6\u00d4\3\2\2\2\u00d6"+
- "\u00d7\3\2\2\2\u00d7\65\3\2\2\2\u00d8\u00d6\3\2\2\2\u00d9\u00dc\5\2\2"+
- "\2\u00da\u00dc\5\n\6\2\u00db\u00d9\3\2\2\2\u00db\u00da\3\2\2\2\u00dc\u00dd"+
- "\3\2\2\2\u00dd\u00de\7\'\2\2\u00de\u00df\5\2\2\2\u00df\67\3\2\2\2\u00e0"+
- "\u00e1\7\36\2\2\u00e1\u00e3\5.\30\2\u00e2\u00e4\5\6\4\2\u00e3\u00e2\3"+
- "\2\2\2\u00e3\u00e4\3\2\2\2\u00e49\3\2\2\2\u00e5\u00eb\5\66\34\2\u00e6"+
- "\u00e9\5\2\2\2\u00e7\u00e9\5\n\6\2\u00e8\u00e6\3\2\2\2\u00e8\u00e7\3\2"+
- "\2\2\u00e9\u00eb\3\2\2\2\u00ea\u00e5\3\2\2\2\u00ea\u00e8\3\2\2\2\u00eb"+
- ";\3\2\2\2\u00ec\u00ed\7\35\2\2\u00ed\u00ee\5.\30\2\u00ee=\3\2\2\2\u00ef"+
- "\u00f1\5:\36\2\u00f0\u00f2\5<\37\2\u00f1\u00f0\3\2\2\2\u00f1\u00f2\3\2"+
- "\2\2\u00f2?\3\2\2\2\u00f3\u00f4\7\34\2\2\u00f4\u00f5\5> \2\u00f5A\3\2"+
- "\2\2\u00f6\u00f7\7!\2\2\u00f7\u00f8\5\64\33\2\u00f8C\3\2\2\2\u00f9\u00fe"+
- "\5@!\2\u00fa\u00fe\5<\37\2\u00fb\u00fe\5> \2\u00fc\u00fe\5.\30\2\u00fd"+
- "\u00f9\3\2\2\2\u00fd\u00fa\3\2\2\2\u00fd\u00fb\3\2\2\2\u00fd\u00fc\3\2"+
- "\2\2\u00feE\3\2\2\2\u00ff\u0100\7\37\2\2\u0100\u0101\7\22\2\2\u0101\u0102"+
- "\5\64\33\2\u0102\u0103\7\24\2\2\u0103G\3\2\2\2\u0104\u0109\5D#\2\u0105"+
- "\u0106\7\t\2\2\u0106\u0108\5D#\2\u0107\u0105\3\2\2\2\u0108\u010b\3\2\2"+
- "\2\u0109\u0107\3\2\2\2\u0109\u010a\3\2\2\2\u010aI\3\2\2\2\u010b\u0109"+
- "\3\2\2\2\u010c\u0110\5D#\2\u010d\u010f\5D#\2\u010e\u010d\3\2\2\2\u010f"+
- "\u0112\3\2\2\2\u0110\u010e\3\2\2\2\u0110\u0111\3\2\2\2\u0111K\3\2\2\2"+
- "\u0112\u0110\3\2\2\2\u0113\u0116\5H%\2\u0114\u0116\5J&\2\u0115\u0113\3"+
- "\2\2\2\u0115\u0114\3\2\2\2\u0116M\3\2\2\2\u0117\u0119\5L\'\2\u0118\u011a"+
- "\5F$\2\u0119\u0118\3\2\2\2\u0119\u011a\3\2\2\2\u011a\u011c\3\2\2\2\u011b"+
- "\u011d\5B\"\2\u011c\u011b\3\2\2\2\u011c\u011d\3\2\2\2\u011d\u011f\3\2"+
- "\2\2\u011e\u0120\58\35\2\u011f\u011e\3\2\2\2\u011f\u0120\3\2\2\2\u0120"+
- "\u0122\3\2\2\2\u0121\u0123\5\60\31\2\u0122\u0121\3\2\2\2\u0122\u0123\3"+
- "\2\2\2\u0123\u0124\3\2\2\2\u0124\u0125\7\2\2\3\u0125O\3\2\2\2\34\\fhr"+
- "x\u0081\u008b\u009a\u00bf\u00c5\u00ca\u00cf\u00d6\u00db\u00e3\u00e8\u00ea"+
- "\u00f1\u00fd\u0109\u0110\u0115\u0119\u011c\u011f\u0122";
+ "\2\u0090\u0091\5\30\r\2\u0091\33\3\2\2\2\u0092\u0093\5\30\r\2\u0093\u0096"+
+ "\t\6\2\2\u0094\u0097\5\2\2\2\u0095\u0097\5.\30\2\u0096\u0094\3\2\2\2\u0096"+
+ "\u0095\3\2\2\2\u0097\35\3\2\2\2\u0098\u0099\5\30\r\2\u0099\u009c\7/\2"+
+ "\2\u009a\u009d\5\2\2\2\u009b\u009d\5.\30\2\u009c\u009a\3\2\2\2\u009c\u009b"+
+ "\3\2\2\2\u009d\37\3\2\2\2\u009e\u009f\5\30\r\2\u009f\u00a0\7*\2\2\u00a0"+
+ "\u00a1\5\2\2\2\u00a1!\3\2\2\2\u00a2\u00a3\7%\2\2\u00a3\u00a4\7\22\2\2"+
+ "\u00a4\u00a5\7\24\2\2\u00a5#\3\2\2\2\u00a6\u00a7\7\"\2\2\u00a7\u00a8\7"+
+ "\22\2\2\u00a8\u00a9\5.\30\2\u00a9\u00aa\7\24\2\2\u00aa%\3\2\2\2\u00ab"+
+ "\u00ac\7#\2\2\u00ac\u00ad\7\22\2\2\u00ad\u00ae\5.\30\2\u00ae\u00af\7\24"+
+ "\2\2\u00af\'\3\2\2\2\u00b0\u00b1\7$\2\2\u00b1\u00b2\7\22\2\2\u00b2\u00b3"+
+ "\5.\30\2\u00b3\u00b4\7\24\2\2\u00b4)\3\2\2\2\u00b5\u00b6\t\7\2\2\u00b6"+
+ "\u00b7\5,\27\2\u00b7+\3\2\2\2\u00b8\u00c2\5\32\16\2\u00b9\u00c2\5\34\17"+
+ "\2\u00ba\u00c2\5 \21\2\u00bb\u00c2\5\30\r\2\u00bc\u00c2\5\"\22\2\u00bd"+
+ "\u00c2\5$\23\2\u00be\u00c2\5&\24\2\u00bf\u00c2\5(\25\2\u00c0\u00c2\5\36"+
+ "\20\2\u00c1\u00b8\3\2\2\2\u00c1\u00b9\3\2\2\2\u00c1\u00ba\3\2\2\2\u00c1"+
+ "\u00bb\3\2\2\2\u00c1\u00bc\3\2\2\2\u00c1\u00bd\3\2\2\2\u00c1\u00be\3\2"+
+ "\2\2\u00c1\u00bf\3\2\2\2\u00c1\u00c0\3\2\2\2\u00c2-\3\2\2\2\u00c3\u00c7"+
+ "\5,\27\2\u00c4\u00c6\5*\26\2\u00c5\u00c4\3\2\2\2\u00c6\u00c9\3\2\2\2\u00c7"+
+ "\u00c5\3\2\2\2\u00c7\u00c8\3\2\2\2\u00c8/\3\2\2\2\u00c9\u00c7\3\2\2\2"+
+ "\u00ca\u00cc\5\f\7\2\u00cb\u00cd\5\16\b\2\u00cc\u00cb\3\2\2\2\u00cc\u00cd"+
+ "\3\2\2\2\u00cd\61\3\2\2\2\u00ce\u00d1\5.\30\2\u00cf\u00d0\7\'\2\2\u00d0"+
+ "\u00d2\5\2\2\2\u00d1\u00cf\3\2\2\2\u00d1\u00d2\3\2\2\2\u00d2\63\3\2\2"+
+ "\2\u00d3\u00d8\5\62\32\2\u00d4\u00d5\7\t\2\2\u00d5\u00d7\5\62\32\2\u00d6"+
+ "\u00d4\3\2\2\2\u00d7\u00da\3\2\2\2\u00d8\u00d6\3\2\2\2\u00d8\u00d9\3\2"+
+ "\2\2\u00d9\65\3\2\2\2\u00da\u00d8\3\2\2\2\u00db\u00de\5\2\2\2\u00dc\u00de"+
+ "\5\n\6\2\u00dd\u00db\3\2\2\2\u00dd\u00dc\3\2\2\2\u00de\u00df\3\2\2\2\u00df"+
+ "\u00e0\7\'\2\2\u00e0\u00e1\5\2\2\2\u00e1\67\3\2\2\2\u00e2\u00e3\7\36\2"+
+ "\2\u00e3\u00e5\5.\30\2\u00e4\u00e6\5\6\4\2\u00e5\u00e4\3\2\2\2\u00e5\u00e6"+
+ "\3\2\2\2\u00e69\3\2\2\2\u00e7\u00ed\5\66\34\2\u00e8\u00eb\5\2\2\2\u00e9"+
+ "\u00eb\5\n\6\2\u00ea\u00e8\3\2\2\2\u00ea\u00e9\3\2\2\2\u00eb\u00ed\3\2"+
+ "\2\2\u00ec\u00e7\3\2\2\2\u00ec\u00ea\3\2\2\2\u00ed;\3\2\2\2\u00ee\u00ef"+
+ "\7\35\2\2\u00ef\u00f0\5.\30\2\u00f0=\3\2\2\2\u00f1\u00f3\5:\36\2\u00f2"+
+ "\u00f4\5<\37\2\u00f3\u00f2\3\2\2\2\u00f3\u00f4\3\2\2\2\u00f4?\3\2\2\2"+
+ "\u00f5\u00f6\7\34\2\2\u00f6\u00f7\5> \2\u00f7A\3\2\2\2\u00f8\u00f9\7!"+
+ "\2\2\u00f9\u00fa\5\64\33\2\u00faC\3\2\2\2\u00fb\u0100\5@!\2\u00fc\u0100"+
+ "\5<\37\2\u00fd\u0100\5> \2\u00fe\u0100\5.\30\2\u00ff\u00fb\3\2\2\2\u00ff"+
+ "\u00fc\3\2\2\2\u00ff\u00fd\3\2\2\2\u00ff\u00fe\3\2\2\2\u0100E\3\2\2\2"+
+ "\u0101\u0102\7\37\2\2\u0102\u0103\7\22\2\2\u0103\u0104\5\64\33\2\u0104"+
+ "\u0105\7\24\2\2\u0105G\3\2\2\2\u0106\u010b\5D#\2\u0107\u0108\7\t\2\2\u0108"+
+ "\u010a\5D#\2\u0109\u0107\3\2\2\2\u010a\u010d\3\2\2\2\u010b\u0109\3\2\2"+
+ "\2\u010b\u010c\3\2\2\2\u010cI\3\2\2\2\u010d\u010b\3\2\2\2\u010e\u0112"+
+ "\5D#\2\u010f\u0111\5D#\2\u0110\u010f\3\2\2\2\u0111\u0114\3\2\2\2\u0112"+
+ "\u0110\3\2\2\2\u0112\u0113\3\2\2\2\u0113K\3\2\2\2\u0114\u0112\3\2\2\2"+
+ "\u0115\u0118\5H%\2\u0116\u0118\5J&\2\u0117\u0115\3\2\2\2\u0117\u0116\3"+
+ "\2\2\2\u0118M\3\2\2\2\u0119\u011b\5L\'\2\u011a\u011c\5F$\2\u011b\u011a"+
+ "\3\2\2\2\u011b\u011c\3\2\2\2\u011c\u011e\3\2\2\2\u011d\u011f\5B\"\2\u011e"+
+ "\u011d\3\2\2\2\u011e\u011f\3\2\2\2\u011f\u0121\3\2\2\2\u0120\u0122\58"+
+ "\35\2\u0121\u0120\3\2\2\2\u0121\u0122\3\2\2\2\u0122\u0124\3\2\2\2\u0123"+
+ "\u0125\5\60\31\2\u0124\u0123\3\2\2\2\u0124\u0125\3\2\2\2\u0125\u0126\3"+
+ "\2\2\2\u0126\u0127\7\2\2\3\u0127O\3\2\2\2\35\\fhrx\u0081\u008b\u0096\u009c"+
+ "\u00c1\u00c7\u00cc\u00d1\u00d8\u00dd\u00e5\u00ea\u00ec\u00f3\u00ff\u010b"+
+ "\u0112\u0117\u011b\u011e\u0121\u0124";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {
diff --git a/repository/src/test/java/org/apache/atlas/BasicTestSetup.java b/repository/src/test/java/org/apache/atlas/BasicTestSetup.java
index a821b25..a1d7b62 100644
--- a/repository/src/test/java/org/apache/atlas/BasicTestSetup.java
+++ b/repository/src/test/java/org/apache/atlas/BasicTestSetup.java
@@ -305,7 +305,8 @@
}
protected void createClassificationTypes() {
- List<AtlasClassificationDef> cds = Arrays.asList(new AtlasClassificationDef(DIMENSION_CLASSIFICATION, "Dimension Classification", "1.0"),
+ List<AtlasClassificationDef> cds = Arrays.asList(new AtlasClassificationDef(DIMENSION_CLASSIFICATION, "Dimension Classification", "1.0",
+ Arrays.asList(new AtlasStructDef.AtlasAttributeDef("timeAttr","string"), new AtlasStructDef.AtlasAttributeDef("productAttr","string"))),
new AtlasClassificationDef(FACT_CLASSIFICATION, "Fact Classification", "1.0"),
new AtlasClassificationDef(PII_CLASSIFICATION, "PII Classification", "1.0"),
new AtlasClassificationDef(METRIC_CLASSIFICATION, "Metric Classification", "1.0"),
@@ -389,7 +390,15 @@
table.setAttribute("sd", getAtlasObjectId(sd));
table.setAttribute("columns", getAtlasObjectIds(columns));
- table.setClassifications(Stream.of(traitNames).map(AtlasClassification::new).collect(Collectors.toList()));
+ if (name.equals("time_dim")) {
+ AtlasClassification classification = new AtlasClassification(traitNames[0], new HashMap<String, Object>() {{ put("timeAttr", "timeValue"); }});
+ table.setClassifications(Collections.singletonList(classification));
+ } else if (name.equals("product_dim")) {
+ AtlasClassification classification = new AtlasClassification(traitNames[0], new HashMap<String, Object>() {{ put("productAttr", "productValue"); }});
+ table.setClassifications(Collections.singletonList(classification));
+ } else {
+ table.setClassifications(Stream.of(traitNames).map(AtlasClassification::new).collect(Collectors.toList()));
+ }
sd.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, dbName + "." + name + "@" + clusterName + "_storage");
diff --git a/repository/src/test/java/org/apache/atlas/query/DSLQueriesTest.java b/repository/src/test/java/org/apache/atlas/query/DSLQueriesTest.java
index 3404dc6..83d273f 100644
--- a/repository/src/test/java/org/apache/atlas/query/DSLQueriesTest.java
+++ b/repository/src/test/java/org/apache/atlas/query/DSLQueriesTest.java
@@ -231,6 +231,33 @@
};
}
+ @DataProvider(name = "classificationQueries")
+ private Object[][] classificationQueries() {
+ return new Object[][] {
+ {"hive_table isA Dimension", 5, new ListValidator("product_dim", "time_dim", "customer_dim", "sales_fact_monthly_mv", "sales_fact_daily_mv")},
+ {"hive_table where hive_table isA Dimension", 5, new ListValidator("product_dim", "time_dim", "customer_dim", "sales_fact_monthly_mv", "sales_fact_daily_mv")},
+ {"hive_table where name = 'time_dim' and hive_table isA Dimension", 1, new ListValidator("time_dim")},
+ {"Dimension where Dimension.timeAttr = 'timeValue'", 5, new ListValidator("loadSalesMonthly", "loadSalesDaily", "time_dim", "sales_fact_monthly_mv", "sales_fact_daily_mv")},
+ {"Dimension as d where d.productAttr = 'productValue'", 2, new ListValidator("product_dim", "product_dim_view")},
+ {"hive_table where hive_table isA Dimension and Dimension.timeAttr = 'timeValue'", 3, new ListValidator("time_dim", "sales_fact_monthly_mv", "sales_fact_daily_mv")},
+ {"hive_table where Dimension.timeAttr = 'timeValue'", 3, new ListValidator("time_dim", "sales_fact_monthly_mv", "sales_fact_daily_mv")},
+ {"hive_table where (Dimension.timeAttr = 'timeValue')", 3, new ListValidator("time_dim", "sales_fact_monthly_mv", "sales_fact_daily_mv")},
+ {"hive_table where (name = 'time_dim' and Dimension.timeAttr = 'timeValue')", 1, new ListValidator("time_dim")},
+ {"hive_table hasTerm \"modernTrade@salesGlossary\" and Dimension.timeAttr = 'timeValue' and db.name = 'Sales'", 1, new ListValidator("time_dim")},
+ };
+ }
+
+ @Test(dataProvider = "classificationQueries")
+ public void classificationQueries(String query, int expected, ListValidator lvExpected) throws AtlasBaseException {
+ AtlasSearchResult result = queryAssert(query, expected, DEFAULT_LIMIT, 0);
+
+ if (lvExpected == null) {
+ return;
+ }
+
+ ListValidator.assertLv(ListValidator.from(result), lvExpected);
+ }
+
@Test(dataProvider = "glossaryTermQueries")
public void glossaryTerm(String query, int expected, ListValidator lvExpected) throws AtlasBaseException {
AtlasSearchResult result = queryAssert(query, expected, DEFAULT_LIMIT, 0);
@@ -703,6 +730,8 @@
{"hive_table select owner, db.name"}, // Same as above
{"hive_order"}, // From src should be an Entity or Classification
{"hive_table hasTerm modernTrade@salesGlossary"},//should be encoded with double quotes
+ {"Dimension where tagAttr1 = 'tagValue'"}, // prefix for classification attributes is must
+ {"Dimension where Dimension.tagAttr1 = 'tagValue' and name = 'time_dim'"},
};
}
diff --git a/repository/src/test/java/org/apache/atlas/query/GremlinQueryComposerTest.java b/repository/src/test/java/org/apache/atlas/query/GremlinQueryComposerTest.java
index 6220c23..7885712 100644
--- a/repository/src/test/java/org/apache/atlas/query/GremlinQueryComposerTest.java
+++ b/repository/src/test/java/org/apache/atlas/query/GremlinQueryComposerTest.java
@@ -22,6 +22,7 @@
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.query.antlr4.AtlasDSLParser;
+import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasStructType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection;
@@ -62,6 +63,19 @@
verify("Table where Table is Dimension", expected);
}
+ @Test()
+ public void classificationAttributes() {
+ String expected1 = "g.V().outE('classifiedAs').has('__name', within('Dimension')).outV().and(__.out('classifiedAs').has('Dimension.timeAttr', eq('value')).dedup().in('classifiedAs')).dedup().limit(25).toList()";
+ String expected2 = "g.V().outE('classifiedAs').has('__name', within('Dimension')).outV().as('d').and(__.out('classifiedAs').has('Dimension.timeAttr', eq('value')).dedup().in('classifiedAs')).dedup().limit(25).toList()";
+ String expected3 = "g.V().has('__typeName', 'Table').and(__.has('Table.name', eq('time_dim')),__.out('classifiedAs').has('Dimension.timeAttr', eq('value')).dedup().in('classifiedAs')).dedup().limit(25).toList()";
+ String expected4 = "g.V().has('__typeName', 'Table').and(__.out('classifiedAs').has('Dimension.timeAttr', eq('value')).dedup().in('classifiedAs')).dedup().limit(25).toList()";
+
+ verify("Dimension where Dimension.timeAttr = 'value'", expected1);
+ verify("Dimension as d where d.timeAttr = 'value'",expected2);
+ verify("Table where (name = 'time_dim' and Dimension.timeAttr = 'value')",expected3);
+ verify("Table where Dimension.timeAttr = 'value'", expected4);
+ }
+
@Test
public void fromDB() {
String expected10 = "g.V().has('__typeName', 'DB').dedup().limit(10).toList()";
@@ -447,7 +461,7 @@
}
private String getGremlinQuery(String dsl, AtlasDSLParser.QueryContext queryContext, int expectedNumberOfErrors) {
- AtlasTypeRegistry registry = mock(AtlasTypeRegistry.class);
+ AtlasTypeRegistry registry = mock(AtlasTypeRegistry.class);
org.apache.atlas.query.Lookup lookup = new TestLookup(registry);
GremlinQueryComposer.Context context = new GremlinQueryComposer.Context(lookup);
AtlasDSL.QueryMetadata queryMetadata = new AtlasDSL.QueryMetadata(queryContext);
@@ -473,7 +487,7 @@
public AtlasType getType(String typeName) throws AtlasBaseException {
AtlasType type;
if(typeName.equals("PII") || typeName.equals("Dimension")) {
- type = mock(AtlasType.class);
+ type = mock(AtlasClassificationType.class);
when(type.getTypeCategory()).thenReturn(TypeCategory.CLASSIFICATION);
} else {
type = mock(AtlasEntityType.class);
@@ -554,6 +568,14 @@
@Override
public boolean hasAttribute(GremlinQueryComposer.Context context, String attributeName) {
+ if (context.getActiveType() instanceof AtlasClassificationType) {
+ return attributeName.equals("timeAttr");
+ }
+
+ if (context.getActiveEntityType() == null) {
+ return false;
+ }
+
return (context.getActiveTypeName().equals("Table") && attributeName.equals("db")) ||
(context.getActiveTypeName().equals("Table") && attributeName.equals("columns")) ||
(context.getActiveTypeName().equals("Table") && attributeName.equals("createTime")) ||