Commit c1081a49 by Shwetha GS

ATLAS-1098 Atlas allows creation of tag with name isa which causes exceptions…

ATLAS-1098 Atlas allows creation of tag with name isa which causes exceptions during search (apoorvnaik via shwethags)
parent 7bb2709d
......@@ -1737,7 +1737,7 @@
<exclude>**/users-credentials.properties</exclude>
<exclude>**/public/css/animate.min.css</exclude>
<exclude>**/public/css/bootstrap-sidebar.css</exclude>
<exclude>**/public/js/require-handlebars-plugin/**</exclude>
<exclude>**/public/js/external_lib/**</exclude>
<exclude>**/node_modules/**</exclude>
<!-- All the npm plugins are copied here, so exclude it -->
<exclude>**/public/js/libs/**</exclude>
......
......@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ATLAS-1098 Atlas allows creation of tag with name "isa" which causes exceptions during search (apoorvnaik via shwethags)
ATLAS-1142 Lineage UI Improvement (kevalbhatt via shwethags)
ATLAS-712 Support getTrait() API (svimal2106 via shwethags)
ATLAS-1173 Doc: Minor editorial bug in the example given for property atlas.server.ha.zookeeper.auth (yhemanth via shwethags)
......
......@@ -241,9 +241,6 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
typeDefinition = ParamChecker.notEmpty(typeDefinition, "type definition");
TypesDef typesDef = validateTypeDefinition(typeDefinition);
// Also validate if the types being created are not keywords
validateIfNotKeyword(typesDef);
try {
final TypeSystem.TransientTypeSystem transientTypeSystem = typeSystem.createTransientTypeSystem(typesDef, isUpdate);
final Map<String, IDataType> typesAdded = transientTypeSystem.getTypesAdded();
......@@ -289,55 +286,6 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
}
}
private void validateIfNotKeyword(TypesDef typesDef) throws AtlasException {
List<EnumTypeDefinition> enumDefs = typesDef.enumTypesAsJavaList();
List<StructTypeDefinition> structDefs = typesDef.structTypesAsJavaList();
List<HierarchicalTypeDefinition<ClassType>> classDefs = typesDef.classTypesAsJavaList();
List<HierarchicalTypeDefinition<TraitType>> traitDefs = typesDef.traitTypesAsJavaList();
// QueryParser has it's own set of keywords that should be avoided
Set<String> keywords = QueryParser.keywordCache().keySet();
boolean keywordCacheNotEmpty = null != keywords && !keywords.isEmpty();
if (keywordCacheNotEmpty) {
if (CollectionUtils.isNotEmpty(enumDefs)) {
// Check if any enum name is a keyword
for (EnumTypeDefinition enumDef : enumDefs) {
if (keywords.contains(enumDef.name)) {
throw new AtlasException("Enum definition name \"" + enumDef.name + "\" is a keyword");
}
}
}
if (CollectionUtils.isNotEmpty(classDefs)){
// Check if any class name is a keyword
for (HierarchicalTypeDefinition<ClassType> classDef : classDefs) {
if (keywords.contains(classDef.typeName)) {
throw new AtlasException("Class definition name \"" + classDef.typeName + "\" is a keyword");
}
}
}
if (CollectionUtils.isNotEmpty(structDefs)){
// Check if any struct name is a keyword
for (StructTypeDefinition structDef : structDefs) {
if (keywords.contains(structDef.typeName)) {
throw new AtlasException("StructType definition name \"" + structDef.typeName + "\" is a keyword");
}
}
}
if (CollectionUtils.isNotEmpty(traitDefs)){
// Check if any trait name is a keyword
for (HierarchicalTypeDefinition<TraitType> traitDef : traitDefs) {
if (keywords.contains(traitDef.typeName)) {
throw new AtlasException("TraitType definition name \"" + traitDef.typeName + "\" is a keyword");
}
}
}
}
}
/**
* Return the definition for the given type.
*
......
......@@ -387,6 +387,7 @@ class QueryLexer(val keywords: Seq[String], val delims: Seq[String]) extends Std
| floatConstant ^^ FloatLiteral
| dubConstant ^^ DoubleLiteral
| identifier ^^ processIdent
| quotedIdentifier ^^ Identifier
| string ^^ StringLit
| EofCh ^^^ EOF
| '\'' ~> failure("unclosed string literal")
......@@ -398,10 +399,11 @@ class QueryLexer(val keywords: Seq[String], val delims: Seq[String]) extends Std
override def identChar = letter | elem('_')
def identifier = identChar ~ (identChar | digit).* ^^ { case first ~ rest => (first :: rest).mkString} |
'`' ~> chrExcept('`', '\n', EofCh).* <~ '`' ^^ {
_ mkString ""
}
def identifier = identChar ~ (identChar | digit).* ^^ { case first ~ rest => (first :: rest).mkString}
def quotedIdentifier = '`' ~> chrExcept('`', '\n', EofCh).* <~ '`' ^^ {
_ mkString ""
}
override def whitespace: Parser[Any] =
(whitespaceChar
......@@ -477,4 +479,4 @@ class QueryLexer(val keywords: Seq[String], val delims: Seq[String]) extends Std
allCaseVersions(s.tail, prefix + s.head.toUpper)
}
}
}
\ No newline at end of file
}
......@@ -174,8 +174,11 @@ public class BaseRepositoryTest {
HierarchicalTypeDefinition<TraitType> logTraitDef = TypesUtil.createTraitTypeDef("Log Data", null);
HierarchicalTypeDefinition<TraitType> isaKeywordTraitDef = TypesUtil.createTraitTypeDef("isa", null);
return TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
ImmutableList.of(dimTraitDef, factTraitDef, piiTraitDef, metricTraitDef, etlTraitDef, jdbcTraitDef, logTraitDef),
ImmutableList.of(dimTraitDef, factTraitDef, piiTraitDef, metricTraitDef, etlTraitDef, jdbcTraitDef, logTraitDef,
isaKeywordTraitDef),
ImmutableList.of(dbClsDef, storageDescClsDef, columnClsDef, tblClsDef, loadProcessClsDef, viewClsDef, partClsDef, datasetSubTypeClsDef));
}
......
......@@ -393,6 +393,9 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest {
{"Metric", 9},
{"PII", 8},
{"`Log Data`", 4},
// Not sure what the expected rows should be, but since we didn't assign or do anything with the created
// I assume it'll be zero
{"`isa`", 0},
/* Lineage queries are fired through ClosureQuery and are tested through HiveLineageJerseyResourceIt in webapp module.
Commenting out the below queries since DSL to Gremlin parsing/translation fails with lineage queries when there are array types
......
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