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
b6f35bf9
Commit
b6f35bf9
authored
5 years ago
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3414: Include metastore catalog name in hive database name and qualifiedName
parent
43a50684
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
7 deletions
+25
-7
HiveMetaStoreBridge.java
...ava/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
+14
-1
AtlasHiveHookContext.java
...java/org/apache/atlas/hive/hook/AtlasHiveHookContext.java
+2
-1
BaseHiveEvent.java
...java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
+7
-4
CreateDatabase.java
...ava/org/apache/atlas/hive/hook/events/CreateDatabase.java
+2
-1
No files found.
addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
View file @
b6f35bf9
...
...
@@ -92,6 +92,7 @@ public class HiveMetaStoreBridge {
public
static
final
String
ATLAS_ENDPOINT
=
"atlas.rest.address"
;
public
static
final
String
SEP
=
":"
.
intern
();
public
static
final
String
HDFS_PATH
=
"hdfs_path"
;
public
static
final
String
DEFAULT_METASTORE_CATALOG
=
"hive"
;
private
static
final
int
EXIT_CODE_SUCCESS
=
0
;
private
static
final
int
EXIT_CODE_FAILED
=
1
;
...
...
@@ -553,7 +554,7 @@ public class HiveMetaStoreBridge {
dbEntity
=
new
AtlasEntity
(
HiveDataTypes
.
HIVE_DB
.
getName
());
}
String
dbName
=
hiveDB
.
getName
().
toLowerCase
(
);
String
dbName
=
getDatabaseName
(
hiveDB
);
dbEntity
.
setAttribute
(
ATTRIBUTE_QUALIFIED_NAME
,
getDBQualifiedName
(
metadataNamespace
,
dbName
));
dbEntity
.
setAttribute
(
ATTRIBUTE_NAME
,
dbName
);
...
...
@@ -570,6 +571,18 @@ public class HiveMetaStoreBridge {
return
dbEntity
;
}
public
static
String
getDatabaseName
(
Database
hiveDB
)
{
String
dbName
=
hiveDB
.
getName
().
toLowerCase
();
String
catalogName
=
hiveDB
.
getCatalogName
()
!=
null
?
hiveDB
.
getCatalogName
().
toLowerCase
()
:
null
;
if
(
StringUtils
.
isNotEmpty
(
catalogName
)
&&
!
StringUtils
.
equals
(
catalogName
,
DEFAULT_METASTORE_CATALOG
))
{
dbName
=
catalogName
+
SEP
+
dbName
;
}
return
dbName
;
}
/**
* Create a new table instance in Atlas
* @param database AtlasEntity for Hive {@link AtlasEntity} to which this table belongs
...
...
This diff is collapsed.
Click to expand it.
addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/AtlasHiveHookContext.java
View file @
b6f35bf9
...
...
@@ -34,6 +34,7 @@ import org.apache.hadoop.hive.ql.session.SessionState;
import
java.util.*
;
import
static
org
.
apache
.
atlas
.
hive
.
bridge
.
HiveMetaStoreBridge
.
getDatabaseName
;
import
static
org
.
apache
.
atlas
.
hive
.
hook
.
events
.
BaseHiveEvent
.
toTable
;
...
...
@@ -192,7 +193,7 @@ public class AtlasHiveHookContext {
}
public
String
getQualifiedName
(
Database
db
)
{
return
(
db
.
getName
()
+
QNAME_SEP_METADATA_NAMESPACE
).
toLowerCase
()
+
getMetadataNamespace
();
return
getDatabaseName
(
db
)
+
QNAME_SEP_METADATA_NAMESPACE
+
getMetadataNamespace
();
}
public
String
getQualifiedName
(
Table
table
)
{
...
...
This diff is collapsed.
Click to expand it.
addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
View file @
b6f35bf9
...
...
@@ -62,6 +62,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
static
org
.
apache
.
atlas
.
hive
.
bridge
.
HiveMetaStoreBridge
.
getDatabaseName
;
import
static
org
.
apache
.
atlas
.
hive
.
hook
.
AtlasHiveHookContext
.
QNAME_SEP_METADATA_NAMESPACE
;
import
static
org
.
apache
.
atlas
.
hive
.
hook
.
AtlasHiveHookContext
.
QNAME_SEP_ENTITY_NAME
;
import
static
org
.
apache
.
atlas
.
hive
.
hook
.
AtlasHiveHookContext
.
QNAME_SEP_PROCESS
;
...
...
@@ -257,8 +258,10 @@ public abstract class BaseHiveEvent {
switch
(
entity
.
getType
())
{
case
DATABASE:
{
if
(!
context
.
getIgnoreDummyDatabaseName
().
contains
(
entity
.
getDatabase
().
getName
()))
{
Database
db
=
getHive
().
getDatabase
(
entity
.
getDatabase
().
getName
());
String
dbName
=
getDatabaseName
(
entity
.
getDatabase
());
if
(!
context
.
getIgnoreDummyDatabaseName
().
contains
(
dbName
))
{
Database
db
=
getHive
().
getDatabase
(
dbName
);
ret
=
toDbEntity
(
db
);
}
...
...
@@ -302,9 +305,9 @@ public abstract class BaseHiveEvent {
}
protected
AtlasEntity
toDbEntity
(
Database
db
)
throws
Exception
{
String
dbName
=
getDatabaseName
(
db
);
String
dbQualifiedName
=
getQualifiedName
(
db
);
boolean
isKnownDatabase
=
context
.
isKnownDatabase
(
dbQualifiedName
);
AtlasEntity
ret
=
context
.
getEntity
(
dbQualifiedName
);
if
(
ret
==
null
)
{
...
...
@@ -318,7 +321,7 @@ public abstract class BaseHiveEvent {
}
ret
.
setAttribute
(
ATTRIBUTE_QUALIFIED_NAME
,
dbQualifiedName
);
ret
.
setAttribute
(
ATTRIBUTE_NAME
,
db
.
getName
().
toLowerCase
()
);
ret
.
setAttribute
(
ATTRIBUTE_NAME
,
db
Name
);
ret
.
setAttribute
(
ATTRIBUTE_DESCRIPTION
,
db
.
getDescription
());
ret
.
setAttribute
(
ATTRIBUTE_OWNER
,
db
.
getOwnerName
());
...
...
This diff is collapsed.
Click to expand it.
addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateDatabase.java
View file @
b6f35bf9
...
...
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
import
java.util.Collections
;
import
java.util.List
;
import
static
org
.
apache
.
atlas
.
hive
.
bridge
.
HiveMetaStoreBridge
.
getDatabaseName
;
import
static
org
.
apache
.
hadoop
.
hive
.
ql
.
hooks
.
Entity
.
Type
.
DATABASE
;
public
class
CreateDatabase
extends
BaseHiveEvent
{
...
...
@@ -80,7 +81,7 @@ public class CreateDatabase extends BaseHiveEvent {
Database
db
=
entity
.
getDatabase
();
if
(
db
!=
null
)
{
db
=
getHive
().
getDatabase
(
db
.
getName
(
));
db
=
getHive
().
getDatabase
(
getDatabaseName
(
db
));
}
if
(
db
!=
null
)
{
...
...
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