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
6dd20ef7
Commit
6dd20ef7
authored
Jun 02, 2015
by
Suma S
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #123 from shwethags/cols
using same column reference across table and store descriptor
parents
7de696cc
9a32f180
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
10 deletions
+28
-10
HiveMetaStoreBridge.java
...ache/hadoop/metadata/hive/bridge/HiveMetaStoreBridge.java
+17
-9
HiveHookIT.java
...java/org/apache/hadoop/metadata/hive/hook/HiveHookIT.java
+11
-1
No files found.
addons/hive-bridge/src/main/java/org/apache/hadoop/metadata/hive/bridge/HiveMetaStoreBridge.java
View file @
6dd20ef7
...
@@ -228,8 +228,8 @@ public class HiveMetaStoreBridge {
...
@@ -228,8 +228,8 @@ public class HiveMetaStoreBridge {
String
dbType
=
HiveDataTypes
.
HIVE_DB
.
getName
();
String
dbType
=
HiveDataTypes
.
HIVE_DB
.
getName
();
String
tableType
=
HiveDataTypes
.
HIVE_TABLE
.
getName
();
String
tableType
=
HiveDataTypes
.
HIVE_TABLE
.
getName
();
String
gremlinQuery
=
String
.
format
(
"g.V.has('__typeName', '%s').has('%s.values', %s).as('p')."
String
gremlinQuery
=
String
.
format
(
"g.V.has('__typeName', '%s').has('%s.values', %s).as('p')."
+
"out('__%s.tableName').has('%s.name', '%s').out('__%s.dbName').has('%s.name', '%s')"
+
"out('__%s.tableName').has('%s.name', '%s').out('__%s.dbName').has('%s.name', '%s')"
+
".has('%s.clusterName', '%s').back('p').toList()"
,
typeName
,
typeName
,
valuesStr
,
typeName
,
+
".has('%s.clusterName', '%s').back('p').toList()"
,
typeName
,
typeName
,
valuesStr
,
typeName
,
tableType
,
tableName
.
toLowerCase
(),
tableType
,
dbType
,
dbName
.
toLowerCase
(),
dbType
,
clusterName
);
tableType
,
tableName
.
toLowerCase
(),
tableType
,
dbType
,
dbName
.
toLowerCase
(),
dbType
,
clusterName
);
return
getEntityReferenceFromGremlin
(
typeName
,
gremlinQuery
);
return
getEntityReferenceFromGremlin
(
typeName
,
gremlinQuery
);
...
@@ -271,9 +271,12 @@ public class HiveMetaStoreBridge {
...
@@ -271,9 +271,12 @@ public class HiveMetaStoreBridge {
// add reference to the database
// add reference to the database
tableRef
.
set
(
"dbName"
,
dbReference
);
tableRef
.
set
(
"dbName"
,
dbReference
);
List
<
Referenceable
>
colList
=
getColumns
(
hiveTable
.
getCols
());
tableRef
.
set
(
"columns"
,
colList
);
// add reference to the StorageDescriptor
// add reference to the StorageDescriptor
StorageDescriptor
storageDesc
=
hiveTable
.
getSd
();
StorageDescriptor
storageDesc
=
hiveTable
.
getSd
();
Referenceable
sdReferenceable
=
fillStorageDescStruct
(
storageDesc
);
Referenceable
sdReferenceable
=
fillStorageDescStruct
(
storageDesc
,
colList
);
tableRef
.
set
(
"sd"
,
sdReferenceable
);
tableRef
.
set
(
"sd"
,
sdReferenceable
);
// add reference to the Partition Keys
// add reference to the Partition Keys
...
@@ -293,8 +296,6 @@ public class HiveMetaStoreBridge {
...
@@ -293,8 +296,6 @@ public class HiveMetaStoreBridge {
tableRef
.
set
(
"tableType"
,
hiveTable
.
getTableType
().
name
());
tableRef
.
set
(
"tableType"
,
hiveTable
.
getTableType
().
name
());
tableRef
.
set
(
"temporary"
,
hiveTable
.
isTemporary
());
tableRef
.
set
(
"temporary"
,
hiveTable
.
isTemporary
());
List
<
Referenceable
>
colList
=
getColumns
(
hiveTable
.
getAllCols
());
tableRef
.
set
(
"columns"
,
colList
);
tableRef
=
createInstance
(
tableRef
);
tableRef
=
createInstance
(
tableRef
);
}
else
{
}
else
{
...
@@ -388,7 +389,7 @@ public class HiveMetaStoreBridge {
...
@@ -388,7 +389,7 @@ public class HiveMetaStoreBridge {
indexRef
.
set
(
"origTableName"
,
index
.
getOrigTableName
());
indexRef
.
set
(
"origTableName"
,
index
.
getOrigTableName
());
indexRef
.
set
(
"indexTableName"
,
index
.
getIndexTableName
());
indexRef
.
set
(
"indexTableName"
,
index
.
getIndexTableName
());
Referenceable
sdReferenceable
=
fillStorageDescStruct
(
index
.
getSd
());
Referenceable
sdReferenceable
=
fillStorageDescStruct
(
index
.
getSd
()
,
null
);
indexRef
.
set
(
"sd"
,
sdReferenceable
);
indexRef
.
set
(
"sd"
,
sdReferenceable
);
indexRef
.
set
(
"parameters"
,
index
.
getParameters
());
indexRef
.
set
(
"parameters"
,
index
.
getParameters
());
...
@@ -398,7 +399,7 @@ public class HiveMetaStoreBridge {
...
@@ -398,7 +399,7 @@ public class HiveMetaStoreBridge {
createInstance
(
indexRef
);
createInstance
(
indexRef
);
}
}
private
Referenceable
fillStorageDescStruct
(
StorageDescriptor
storageDesc
)
throws
Exception
{
private
Referenceable
fillStorageDescStruct
(
StorageDescriptor
storageDesc
,
List
<
Referenceable
>
colList
)
throws
Exception
{
LOG
.
debug
(
"Filling storage descriptor information for "
+
storageDesc
);
LOG
.
debug
(
"Filling storage descriptor information for "
+
storageDesc
);
Referenceable
sdReferenceable
=
new
Referenceable
(
HiveDataTypes
.
HIVE_STORAGEDESC
.
getName
());
Referenceable
sdReferenceable
=
new
Referenceable
(
HiveDataTypes
.
HIVE_STORAGEDESC
.
getName
());
...
@@ -433,8 +434,15 @@ public class HiveMetaStoreBridge {
...
@@ -433,8 +434,15 @@ public class HiveMetaStoreBridge {
}
}
*/
*/
List
<
Referenceable
>
fieldsList
=
getColumns
(
storageDesc
.
getCols
());
//Use the passed column list if not null, ex: use same references for table and SD
sdReferenceable
.
set
(
"cols"
,
fieldsList
);
List
<
FieldSchema
>
columns
=
storageDesc
.
getCols
();
if
(
columns
!=
null
&&
!
columns
.
isEmpty
())
{
if
(
colList
!=
null
)
{
sdReferenceable
.
set
(
"cols"
,
colList
);
}
else
{
sdReferenceable
.
set
(
"cols"
,
getColumns
(
columns
));
}
}
List
<
Struct
>
sortColsStruct
=
new
ArrayList
<>();
List
<
Struct
>
sortColsStruct
=
new
ArrayList
<>();
for
(
Order
sortcol
:
storageDesc
.
getSortCols
())
{
for
(
Order
sortcol
:
storageDesc
.
getSortCols
())
{
...
...
addons/hive-bridge/src/test/java/org/apache/hadoop/metadata/hive/hook/HiveHookIT.java
View file @
6dd20ef7
...
@@ -127,8 +127,11 @@ public class HiveHookIT {
...
@@ -127,8 +127,11 @@ public class HiveHookIT {
public
void
testCreateTable
()
throws
Exception
{
public
void
testCreateTable
()
throws
Exception
{
String
tableName
=
tableName
();
String
tableName
=
tableName
();
String
dbName
=
createDatabase
();
String
dbName
=
createDatabase
();
runCommand
(
"create table "
+
dbName
+
"."
+
tableName
+
"(id int, name string)"
);
String
colName
=
"col"
+
random
();
runCommand
(
"create table "
+
dbName
+
"."
+
tableName
+
"("
+
colName
+
" int, name string)"
);
assertTableIsRegistered
(
dbName
,
tableName
);
assertTableIsRegistered
(
dbName
,
tableName
);
//there is only one instance of column registered
assertColumnIsRegistered
(
colName
);
tableName
=
createTable
();
tableName
=
createTable
();
String
tableId
=
assertTableIsRegistered
(
DEFAULT_DB
,
tableName
);
String
tableId
=
assertTableIsRegistered
(
DEFAULT_DB
,
tableName
);
...
@@ -139,6 +142,13 @@ public class HiveHookIT {
...
@@ -139,6 +142,13 @@ public class HiveHookIT {
assertDatabaseIsRegistered
(
DEFAULT_DB
);
assertDatabaseIsRegistered
(
DEFAULT_DB
);
}
}
private
String
assertColumnIsRegistered
(
String
colName
)
throws
Exception
{
LOG
.
debug
(
"Searching for column {}"
,
colName
);
String
query
=
String
.
format
(
"%s where name = '%s'"
,
HiveDataTypes
.
HIVE_COLUMN
.
getName
(),
colName
.
toLowerCase
());
return
assertEntityIsRegistered
(
query
,
true
);
}
@Test
@Test
public
void
testCTAS
()
throws
Exception
{
public
void
testCTAS
()
throws
Exception
{
String
tableName
=
createTable
();
String
tableName
=
createTable
();
...
...
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