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
6bc7f5c7
Commit
6bc7f5c7
authored
May 30, 2015
by
Shwetha GS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hive hook using DSL to get table reference
parent
1da516d2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
16 deletions
+24
-16
HiveMetaStoreBridge.java
...ache/hadoop/metadata/hive/bridge/HiveMetaStoreBridge.java
+16
-13
HiveHookIT.java
...java/org/apache/hadoop/metadata/hive/hook/HiveHookIT.java
+8
-3
No files found.
addons/hive-bridge/src/main/java/org/apache/hadoop/metadata/hive/bridge/HiveMetaStoreBridge.java
View file @
6bc7f5c7
...
...
@@ -168,7 +168,13 @@ public class HiveMetaStoreBridge {
if
(
results
.
length
()
==
0
)
{
return
null
;
}
else
{
String
guid
=
getGuidFromDSLResponse
(
results
.
getJSONObject
(
0
));
String
guid
;
JSONObject
row
=
results
.
getJSONObject
(
0
);
if
(
row
.
has
(
"$id$"
))
{
guid
=
row
.
getJSONObject
(
"$id$"
).
getString
(
"id"
);
}
else
{
guid
=
row
.
getJSONObject
(
"_col_0"
).
getString
(
"id"
);
}
return
new
Referenceable
(
guid
,
typeName
,
null
);
}
}
...
...
@@ -186,15 +192,16 @@ public class HiveMetaStoreBridge {
String
typeName
=
HiveDataTypes
.
HIVE_TABLE
.
getName
();
// String dslQuery = String.format("%s as t where name = '%s' dbName where name = '%s' and "
//
+ "clusterName = '%s' select t",
//
HiveDataTypes.HIVE_TABLE.getName(), tableName, dbName, clusterName);
String
dbType
=
HiveDataTypes
.
HIVE_DB
.
getName
(
);
String
dslQuery
=
String
.
format
(
"%s as t where name = '%s', dbName where name = '%s' and "
+
"clusterName = '%s' select t"
,
HiveDataTypes
.
HIVE_TABLE
.
getName
(),
tableName
,
dbName
,
clusterName
);
return
getEntityReferenceFromDSL
(
typeName
,
dslQuery
);
String
gremlinQuery
=
String
.
format
(
"g.V.has('__typeName', '%s').has('%s.name', '%s').as('t').out"
+
"('__%s.dbName').has('%s.name', '%s').has('%s.clusterName', '%s').back('t').toList()"
,
typeName
,
typeName
,
tableName
,
typeName
,
dbType
,
dbName
,
dbType
,
clusterName
);
return
getEntityReferenceFromGremlin
(
typeName
,
gremlinQuery
);
// String dbType = HiveDataTypes.HIVE_DB.getName();
// String gremlinQuery = String.format("g.V.has('__typeName', '%s').has('%s.name', '%s').as('t').out"
// + "('__%s.dbName').has('%s.name', '%s').has('%s.clusterName', '%s').back('t').toList()",
// typeName, typeName, tableName, typeName, dbType, dbName, dbType, clusterName);
// return getEntityReferenceFromGremlin(typeName, gremlinQuery);
}
private
Referenceable
getEntityReferenceFromGremlin
(
String
typeName
,
String
gremlinQuery
)
throws
MetadataServiceException
,
...
...
@@ -228,10 +235,6 @@ public class HiveMetaStoreBridge {
return
getEntityReferenceFromGremlin
(
typeName
,
gremlinQuery
);
}
private
String
getGuidFromDSLResponse
(
JSONObject
jsonObject
)
throws
JSONException
{
return
jsonObject
.
getJSONObject
(
"$id$"
).
getString
(
"id"
);
}
private
Referenceable
getSDForTable
(
String
dbName
,
String
tableName
)
throws
Exception
{
Referenceable
tableRef
=
getTableReference
(
dbName
,
tableName
);
if
(
tableRef
==
null
)
{
...
...
addons/hive-bridge/src/test/java/org/apache/hadoop/metadata/hive/hook/HiveHookIT.java
View file @
6bc7f5c7
...
...
@@ -215,8 +215,8 @@ public class HiveHookIT {
}
private
void
assertTableIsRegistered
(
String
dbName
,
String
tableName
)
throws
Exception
{
String
query
=
String
.
format
(
"%s
where name = '%s', dbName where name = '%s' and clusterName = '%s'"
,
HiveDataTypes
.
HIVE_TABLE
.
getName
(),
tableName
,
dbName
,
CLUSTER_NAME
);
String
query
=
String
.
format
(
"%s
as t where name = '%s', dbName where name = '%s' and clusterName = '%s'"
+
" select t"
,
HiveDataTypes
.
HIVE_TABLE
.
getName
(),
tableName
,
dbName
,
CLUSTER_NAME
);
assertEntityIsRegistered
(
query
);
}
...
...
@@ -243,6 +243,11 @@ public class HiveHookIT {
private
String
assertEntityIsRegistered
(
String
dslQuery
)
throws
Exception
{
JSONArray
results
=
dgiCLient
.
searchByDSL
(
dslQuery
);
Assert
.
assertEquals
(
results
.
length
(),
1
);
return
results
.
getJSONObject
(
0
).
getJSONObject
(
"$id$"
).
getString
(
"id"
);
JSONObject
row
=
results
.
getJSONObject
(
0
);
if
(
row
.
has
(
"$id$"
))
{
return
row
.
getJSONObject
(
"$id$"
).
getString
(
"id"
);
}
else
{
return
row
.
getJSONObject
(
"_col_0"
).
getString
(
"id"
);
}
}
}
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