Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
dc89e7f4
Commit
dc89e7f4
authored
8 years ago
by
Sarath Subramanian
Committed by
Madhan Neethiraj
8 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1636: fix incorrect reverseAttribute for hive_column.table
parent
fe86177a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
003-hive_column_update_table_remove_constraint.json
...tches/003-hive_column_update_table_remove_constraint.json
+21
-0
AtlasTypeDefStoreInitializer.java
...ository/store/bootstrap/AtlasTypeDefStoreInitializer.java
+64
-0
No files found.
addons/models/patches/003-hive_column_update_table_remove_constraint.json
0 → 100644
View file @
dc89e7f4
{
"patches"
:
[
{
"action"
:
"UPDATE_ATTRIBUTE"
,
"typeName"
:
"hive_column"
,
"applyToVersion"
:
"1.2"
,
"updateToVersion"
:
"1.3"
,
"params"
:
null
,
"attributeDefs"
:
[
{
"name"
:
"table"
,
"typeName"
:
"hive_table"
,
"cardinality"
:
"SINGLE"
,
"isIndexable"
:
false
,
"isOptional"
:
true
,
"isUnique"
:
false
}
]
}
]
}
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java
View file @
dc89e7f4
...
...
@@ -160,6 +160,7 @@ public class AtlasTypeDefStoreInitializer {
PatchHandler
[]
patchHandlers
=
new
PatchHandler
[]
{
new
AddAttributePatchHandler
(
typeDefStore
,
typeRegistry
),
new
UpdateTypeDefOptionsPatchHandler
(
typeDefStore
,
typeRegistry
),
new
UpdateAttributePatchHandler
(
typeDefStore
,
typeRegistry
)
};
Map
<
String
,
PatchHandler
>
patchHandlerRegistry
=
new
HashMap
<>();
...
...
@@ -381,6 +382,69 @@ public class AtlasTypeDefStoreInitializer {
}
}
class
UpdateAttributePatchHandler
extends
PatchHandler
{
public
UpdateAttributePatchHandler
(
AtlasTypeDefStore
typeDefStore
,
AtlasTypeRegistry
typeRegistry
)
{
super
(
typeDefStore
,
typeRegistry
,
new
String
[]
{
"UPDATE_ATTRIBUTE"
});
}
@Override
public
void
applyPatch
(
TypeDefPatch
patch
)
throws
AtlasBaseException
{
String
typeName
=
patch
.
getTypeName
();
AtlasBaseTypeDef
typeDef
=
typeRegistry
.
getTypeDefByName
(
typeName
);
if
(
typeDef
==
null
)
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
PATCH_FOR_UNKNOWN_TYPE
,
patch
.
getAction
(),
typeName
);
}
if
(
isPatchApplicable
(
patch
,
typeDef
))
{
if
(
typeDef
.
getClass
().
equals
(
AtlasEntityDef
.
class
))
{
AtlasEntityDef
updatedDef
=
new
AtlasEntityDef
((
AtlasEntityDef
)
typeDef
);
addOrUpdateAttributes
(
updatedDef
,
patch
.
getAttributeDefs
());
updatedDef
.
setTypeVersion
(
patch
.
getUpdateToVersion
());
typeDefStore
.
updateEntityDefByName
(
typeName
,
updatedDef
);
}
else
if
(
typeDef
.
getClass
().
equals
(
AtlasClassificationDef
.
class
))
{
AtlasClassificationDef
updatedDef
=
new
AtlasClassificationDef
((
AtlasClassificationDef
)
typeDef
);
addOrUpdateAttributes
(
updatedDef
,
patch
.
getAttributeDefs
());
updatedDef
.
setTypeVersion
(
patch
.
getUpdateToVersion
());
typeDefStore
.
updateClassificationDefByName
(
typeName
,
updatedDef
);
}
else
if
(
typeDef
.
getClass
().
equals
(
AtlasStructDef
.
class
))
{
AtlasStructDef
updatedDef
=
new
AtlasStructDef
((
AtlasStructDef
)
typeDef
);
addOrUpdateAttributes
(
updatedDef
,
patch
.
getAttributeDefs
());
updatedDef
.
setTypeVersion
(
patch
.
getUpdateToVersion
());
typeDefStore
.
updateStructDefByName
(
typeName
,
updatedDef
);
}
else
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
PATCH_NOT_APPLICABLE_FOR_TYPE
,
patch
.
getAction
(),
typeDef
.
getClass
().
getSimpleName
());
}
}
else
{
LOG
.
info
(
"patch skipped: typeName={}; applyToVersion={}; updateToVersion={}"
,
patch
.
getTypeName
(),
patch
.
getApplyToVersion
(),
patch
.
getUpdateToVersion
());
}
}
private
void
addOrUpdateAttributes
(
AtlasStructDef
structDef
,
List
<
AtlasAttributeDef
>
attributesToUpdate
)
{
for
(
AtlasAttributeDef
attributeToUpdate
:
attributesToUpdate
)
{
String
attrName
=
attributeToUpdate
.
getName
();
if
(
structDef
.
hasAttribute
(
attrName
))
{
structDef
.
removeAttribute
(
attrName
);
}
structDef
.
addAttribute
(
attributeToUpdate
);
}
}
}
class
UpdateTypeDefOptionsPatchHandler
extends
PatchHandler
{
public
UpdateTypeDefOptionsPatchHandler
(
AtlasTypeDefStore
typeDefStore
,
AtlasTypeRegistry
typeRegistry
)
{
super
(
typeDefStore
,
typeRegistry
,
new
String
[]
{
"UPDATE_TYPEDEF_OPTIONS"
});
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment