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
Sep 17, 2019
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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
10 deletions
+28
-10
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
+10
-7
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 {
...
@@ -92,6 +92,7 @@ public class HiveMetaStoreBridge {
public
static
final
String
ATLAS_ENDPOINT
=
"atlas.rest.address"
;
public
static
final
String
ATLAS_ENDPOINT
=
"atlas.rest.address"
;
public
static
final
String
SEP
=
":"
.
intern
();
public
static
final
String
SEP
=
":"
.
intern
();
public
static
final
String
HDFS_PATH
=
"hdfs_path"
;
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_SUCCESS
=
0
;
private
static
final
int
EXIT_CODE_FAILED
=
1
;
private
static
final
int
EXIT_CODE_FAILED
=
1
;
...
@@ -553,7 +554,7 @@ public class HiveMetaStoreBridge {
...
@@ -553,7 +554,7 @@ public class HiveMetaStoreBridge {
dbEntity
=
new
AtlasEntity
(
HiveDataTypes
.
HIVE_DB
.
getName
());
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_QUALIFIED_NAME
,
getDBQualifiedName
(
metadataNamespace
,
dbName
));
dbEntity
.
setAttribute
(
ATTRIBUTE_NAME
,
dbName
);
dbEntity
.
setAttribute
(
ATTRIBUTE_NAME
,
dbName
);
...
@@ -570,6 +571,18 @@ public class HiveMetaStoreBridge {
...
@@ -570,6 +571,18 @@ public class HiveMetaStoreBridge {
return
dbEntity
;
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
* Create a new table instance in Atlas
* @param database AtlasEntity for Hive {@link AtlasEntity} to which this table belongs
* @param database AtlasEntity for Hive {@link AtlasEntity} to which this table belongs
...
...
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;
...
@@ -34,6 +34,7 @@ import org.apache.hadoop.hive.ql.session.SessionState;
import
java.util.*
;
import
java.util.*
;
import
static
org
.
apache
.
atlas
.
hive
.
bridge
.
HiveMetaStoreBridge
.
getDatabaseName
;
import
static
org
.
apache
.
atlas
.
hive
.
hook
.
events
.
BaseHiveEvent
.
toTable
;
import
static
org
.
apache
.
atlas
.
hive
.
hook
.
events
.
BaseHiveEvent
.
toTable
;
...
@@ -192,7 +193,7 @@ public class AtlasHiveHookContext {
...
@@ -192,7 +193,7 @@ public class AtlasHiveHookContext {
}
}
public
String
getQualifiedName
(
Database
db
)
{
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
)
{
public
String
getQualifiedName
(
Table
table
)
{
...
...
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;
...
@@ -62,6 +62,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
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_METADATA_NAMESPACE
;
import
static
org
.
apache
.
atlas
.
hive
.
hook
.
AtlasHiveHookContext
.
QNAME_SEP_ENTITY_NAME
;
import
static
org
.
apache
.
atlas
.
hive
.
hook
.
AtlasHiveHookContext
.
QNAME_SEP_ENTITY_NAME
;
import
static
org
.
apache
.
atlas
.
hive
.
hook
.
AtlasHiveHookContext
.
QNAME_SEP_PROCESS
;
import
static
org
.
apache
.
atlas
.
hive
.
hook
.
AtlasHiveHookContext
.
QNAME_SEP_PROCESS
;
...
@@ -257,8 +258,10 @@ public abstract class BaseHiveEvent {
...
@@ -257,8 +258,10 @@ public abstract class BaseHiveEvent {
switch
(
entity
.
getType
())
{
switch
(
entity
.
getType
())
{
case
DATABASE:
{
case
DATABASE:
{
if
(!
context
.
getIgnoreDummyDatabaseName
().
contains
(
entity
.
getDatabase
().
getName
()))
{
String
dbName
=
getDatabaseName
(
entity
.
getDatabase
());
Database
db
=
getHive
().
getDatabase
(
entity
.
getDatabase
().
getName
());
if
(!
context
.
getIgnoreDummyDatabaseName
().
contains
(
dbName
))
{
Database
db
=
getHive
().
getDatabase
(
dbName
);
ret
=
toDbEntity
(
db
);
ret
=
toDbEntity
(
db
);
}
}
...
@@ -302,10 +305,10 @@ public abstract class BaseHiveEvent {
...
@@ -302,10 +305,10 @@ public abstract class BaseHiveEvent {
}
}
protected
AtlasEntity
toDbEntity
(
Database
db
)
throws
Exception
{
protected
AtlasEntity
toDbEntity
(
Database
db
)
throws
Exception
{
String
dbQualifiedName
=
getQualified
Name
(
db
);
String
dbName
=
getDatabase
Name
(
db
);
boolean
isKnownDatabase
=
context
.
isKnownDatabase
(
dbQualifiedName
);
String
dbQualifiedName
=
getQualifiedName
(
db
);
boolean
isKnownDatabase
=
context
.
isKnownDatabase
(
dbQualifiedName
);
AtlasEntity
ret
=
context
.
getEntity
(
dbQualifiedName
);
AtlasEntity
ret
=
context
.
getEntity
(
dbQualifiedName
);
if
(
ret
==
null
)
{
if
(
ret
==
null
)
{
ret
=
new
AtlasEntity
(
HIVE_TYPE_DB
);
ret
=
new
AtlasEntity
(
HIVE_TYPE_DB
);
...
@@ -318,7 +321,7 @@ public abstract class BaseHiveEvent {
...
@@ -318,7 +321,7 @@ public abstract class BaseHiveEvent {
}
}
ret
.
setAttribute
(
ATTRIBUTE_QUALIFIED_NAME
,
dbQualifiedName
);
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_DESCRIPTION
,
db
.
getDescription
());
ret
.
setAttribute
(
ATTRIBUTE_OWNER
,
db
.
getOwnerName
());
ret
.
setAttribute
(
ATTRIBUTE_OWNER
,
db
.
getOwnerName
());
...
...
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;
...
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
static
org
.
apache
.
atlas
.
hive
.
bridge
.
HiveMetaStoreBridge
.
getDatabaseName
;
import
static
org
.
apache
.
hadoop
.
hive
.
ql
.
hooks
.
Entity
.
Type
.
DATABASE
;
import
static
org
.
apache
.
hadoop
.
hive
.
ql
.
hooks
.
Entity
.
Type
.
DATABASE
;
public
class
CreateDatabase
extends
BaseHiveEvent
{
public
class
CreateDatabase
extends
BaseHiveEvent
{
...
@@ -80,7 +81,7 @@ public class CreateDatabase extends BaseHiveEvent {
...
@@ -80,7 +81,7 @@ public class CreateDatabase extends BaseHiveEvent {
Database
db
=
entity
.
getDatabase
();
Database
db
=
entity
.
getDatabase
();
if
(
db
!=
null
)
{
if
(
db
!=
null
)
{
db
=
getHive
().
getDatabase
(
db
.
getName
(
));
db
=
getHive
().
getDatabase
(
getDatabaseName
(
db
));
}
}
if
(
db
!=
null
)
{
if
(
db
!=
null
)
{
...
...
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