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
36a1f612
Commit
36a1f612
authored
May 30, 2015
by
Suma S
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #119 from shwethags/ts
hive hook using DSL to get table reference
parents
455abf46
6bc7f5c7
Show 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 @
36a1f612
...
@@ -168,7 +168,13 @@ public class HiveMetaStoreBridge {
...
@@ -168,7 +168,13 @@ public class HiveMetaStoreBridge {
if
(
results
.
length
()
==
0
)
{
if
(
results
.
length
()
==
0
)
{
return
null
;
return
null
;
}
else
{
}
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
);
return
new
Referenceable
(
guid
,
typeName
,
null
);
}
}
}
}
...
@@ -186,15 +192,16 @@ public class HiveMetaStoreBridge {
...
@@ -186,15 +192,16 @@ public class HiveMetaStoreBridge {
String
typeName
=
HiveDataTypes
.
HIVE_TABLE
.
getName
();
String
typeName
=
HiveDataTypes
.
HIVE_TABLE
.
getName
();
// String dslQuery = String.format("%s as t where name = '%s' dbName where name = '%s' and "
String
dslQuery
=
String
.
format
(
//
+ "clusterName = '%s' select t",
"%s as t where name = '%s', dbName where name = '%s' and "
+
"clusterName = '%s' select t"
,
//
HiveDataTypes.HIVE_TABLE.getName(), tableName, dbName, clusterName);
HiveDataTypes
.
HIVE_TABLE
.
getName
(),
tableName
,
dbName
,
clusterName
);
String
dbType
=
HiveDataTypes
.
HIVE_DB
.
getName
(
);
return
getEntityReferenceFromDSL
(
typeName
,
dslQuery
);
String
gremlinQuery
=
String
.
format
(
"g.V.has('__typeName', '%s').has('%s.name', '%s').as('t').out"
// String dbType = HiveDataTypes.HIVE_DB.getName();
+
"('__%s.dbName').has('%s.name', '%s').has('%s.clusterName', '%s').back('t').toList()"
,
// String gremlinQuery = String.format("g.V.has('__typeName', '%s').has('%s.name', '%s').as('t').out"
typeName
,
typeName
,
tableName
,
typeName
,
dbType
,
dbName
,
dbType
,
clusterName
);
// + "('__%s.dbName').has('%s.name', '%s').has('%s.clusterName', '%s').back('t').toList()",
return
getEntityReferenceFromGremlin
(
typeName
,
gremlinQuery
);
// typeName, typeName, tableName, typeName, dbType, dbName, dbType, clusterName);
// return getEntityReferenceFromGremlin(typeName, gremlinQuery);
}
}
private
Referenceable
getEntityReferenceFromGremlin
(
String
typeName
,
String
gremlinQuery
)
throws
MetadataServiceException
,
private
Referenceable
getEntityReferenceFromGremlin
(
String
typeName
,
String
gremlinQuery
)
throws
MetadataServiceException
,
...
@@ -228,10 +235,6 @@ public class HiveMetaStoreBridge {
...
@@ -228,10 +235,6 @@ public class HiveMetaStoreBridge {
return
getEntityReferenceFromGremlin
(
typeName
,
gremlinQuery
);
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
{
private
Referenceable
getSDForTable
(
String
dbName
,
String
tableName
)
throws
Exception
{
Referenceable
tableRef
=
getTableReference
(
dbName
,
tableName
);
Referenceable
tableRef
=
getTableReference
(
dbName
,
tableName
);
if
(
tableRef
==
null
)
{
if
(
tableRef
==
null
)
{
...
...
addons/hive-bridge/src/test/java/org/apache/hadoop/metadata/hive/hook/HiveHookIT.java
View file @
36a1f612
...
@@ -215,8 +215,8 @@ public class HiveHookIT {
...
@@ -215,8 +215,8 @@ public class HiveHookIT {
}
}
private
void
assertTableIsRegistered
(
String
dbName
,
String
tableName
)
throws
Exception
{
private
void
assertTableIsRegistered
(
String
dbName
,
String
tableName
)
throws
Exception
{
String
query
=
String
.
format
(
"%s
where name = '%s', dbName where name = '%s' and clusterName = '%s'"
,
String
query
=
String
.
format
(
"%s
as t where name = '%s', dbName where name = '%s' and clusterName = '%s'"
HiveDataTypes
.
HIVE_TABLE
.
getName
(),
tableName
,
dbName
,
CLUSTER_NAME
);
+
" select t"
,
HiveDataTypes
.
HIVE_TABLE
.
getName
(),
tableName
,
dbName
,
CLUSTER_NAME
);
assertEntityIsRegistered
(
query
);
assertEntityIsRegistered
(
query
);
}
}
...
@@ -243,6 +243,11 @@ public class HiveHookIT {
...
@@ -243,6 +243,11 @@ public class HiveHookIT {
private
String
assertEntityIsRegistered
(
String
dslQuery
)
throws
Exception
{
private
String
assertEntityIsRegistered
(
String
dslQuery
)
throws
Exception
{
JSONArray
results
=
dgiCLient
.
searchByDSL
(
dslQuery
);
JSONArray
results
=
dgiCLient
.
searchByDSL
(
dslQuery
);
Assert
.
assertEquals
(
results
.
length
(),
1
);
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