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
95675ad4
Commit
95675ad4
authored
Mar 27, 2015
by
Harish Butani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests and minor fixes for Hive Lineage and WhereUsed
parent
cb5ceb13
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
20 deletions
+42
-20
ClosureQuery.scala
...scala/org/apache/hadoop/metadata/query/ClosureQuery.scala
+1
-1
QueryParser.scala
.../scala/org/apache/hadoop/metadata/query/QueryParser.scala
+1
-1
TypeUtils.scala
...in/scala/org/apache/hadoop/metadata/query/TypeUtils.scala
+13
-1
GremlinTest2.scala
...scala/org/apache/hadoop/metadata/query/GremlinTest2.scala
+27
-17
No files found.
repository/src/main/scala/org/apache/hadoop/metadata/query/ClosureQuery.scala
View file @
95675ad4
...
@@ -66,7 +66,7 @@ trait ClosureQuery {
...
@@ -66,7 +66,7 @@ trait ClosureQuery {
def
toExpr
:
Expression
=
this
match
{
def
toExpr
:
Expression
=
this
match
{
case
r
:
Relation
=>
id
(
r
.
attributeName
)
case
r
:
Relation
=>
id
(
r
.
attributeName
)
case
rr
:
ReverseRelation
=>
id
(
rr
.
typeName
)
case
rr
:
ReverseRelation
=>
id
(
s
"${rr.typeName}->${rr.attributeName}"
)
}
}
def
toFieldName
:
String
=
this
match
{
def
toFieldName
:
String
=
this
match
{
...
...
repository/src/main/scala/org/apache/hadoop/metadata/query/QueryParser.scala
View file @
95675ad4
...
@@ -317,7 +317,7 @@ class QueryLexer(val keywords: Seq[String], val delims: Seq[String]) extends Std
...
@@ -317,7 +317,7 @@ class QueryLexer(val keywords: Seq[String], val delims: Seq[String]) extends Std
override
def
identChar
=
letter
|
elem
(
'_')
override
def
identChar
=
letter
|
elem
(
'_')
def
identifier
=
identChar
~
(
identChar
|
digit
).*
^^
{
case
first
~
rest
=>
(
first
::
rest
).
mkString
}
|
def
identifier
=
identChar
~
(
identChar
|
digit
).*
^^
{
case
first
~
rest
=>
(
first
::
rest
).
mkString
}
|
'`'
~>
chrExcept
(
'\n'
,
EofCh
).*
<~
'`'
^^
{
'`'
~>
chrExcept
(
'
`'
,
'
\n'
,
EofCh
).*
<~
'`'
^^
{
_
mkString
""
_
mkString
""
}
}
...
...
repository/src/main/scala/org/apache/hadoop/metadata/query/TypeUtils.scala
View file @
95675ad4
...
@@ -115,6 +115,8 @@ object TypeUtils {
...
@@ -115,6 +115,8 @@ object TypeUtils {
}
}
}
}
val
FIELD_QUALIFIER
=
"(.*?)(->.*)?"
.
r
/**
/**
* Given a ComposedType `t` and a name resolve using the following rules:
* Given a ComposedType `t` and a name resolve using the following rules:
* - if `id` is a field in `t` resolve to the field
* - if `id` is a field in `t` resolve to the field
...
@@ -142,8 +144,18 @@ object TypeUtils {
...
@@ -142,8 +144,18 @@ object TypeUtils {
}
}
try
{
try
{
val
idTyp
=
typSystem
.
getDataType
(
classOf
[
IDataType
[
_
]],
id
)
val
FIELD_QUALIFIER
(
clsNm
,
rest
)
=
id
val
idTyp
=
typSystem
.
getDataType
(
classOf
[
IDataType
[
_
]],
clsNm
)
val
idTypFMap
=
fieldMapping
(
idTyp
)
val
idTypFMap
=
fieldMapping
(
idTyp
)
if
(
rest
!=
null
)
{
val
attrNm
=
rest
.
substring
(
2
)
if
(
idTypFMap
.
get
.
fields
.
containsKey
(
attrNm
))
{
return
Some
(
FieldInfo
(
typ
,
idTypFMap
.
get
.
fields
.
get
(
attrNm
),
idTyp
))
}
}
if
(
idTypFMap
.
isDefined
)
{
if
(
idTypFMap
.
isDefined
)
{
import
scala.collection.JavaConversions._
import
scala.collection.JavaConversions._
val
fields
:
Seq
[
AttributeInfo
]
=
idTypFMap
.
get
.
fields
.
values
().
filter
{
aInfo
=>
val
fields
:
Seq
[
AttributeInfo
]
=
idTypFMap
.
get
.
fields
.
values
().
filter
{
aInfo
=>
...
...
repository/src/test/scala/org/apache/hadoop/metadata/query/GremlinTest2.scala
View file @
95675ad4
...
@@ -86,22 +86,31 @@ class GremlinTest2 extends FunSuite with BeforeAndAfterAll with BaseGremlinTest
...
@@ -86,22 +86,31 @@ class GremlinTest2 extends FunSuite with BeforeAndAfterAll with BaseGremlinTest
validateJson
(
r
)
validateJson
(
r
)
}
}
// test("testLineageAllSelectWithPathFromParser2") {
test
(
"testLineageAllSelectWithPathFromParser2"
)
{
// val p = new QueryParser
val
p
=
new
QueryParser
// val e = p("Table as src loop (LoadProcess inputTables) as dest " +
// "select src.name as srcTable, dest.name as destTable withPath").right.get
val
e
=
p
(
"Table as src loop (`LoadProcess->outputTable` inputTables) as dest "
+
// //Table as src loop (LoadProcess where LoadProcess.outputTable) as dest select src.name as srcTable, dest.name as destTable withPath
"select src.name as srcTable, dest.name as destTable withPath"
).
right
.
get
// val r = QueryProcessor.evaluate(e, g)
val
r
=
QueryProcessor
.
evaluate
(
e
,
g
)
// validateJson(r)
validateJson
(
r
)
// }
}
//
// test("testHighLevelLineage") {
test
(
"testHighLevelLineage"
)
{
// val r = HiveLineageQuery("Table", "sales_daily_mv",
val
r
=
HiveLineageQuery
(
"Table"
,
"sales_fact_monthly_mv"
,
// "LoadProcess",
"LoadProcess"
,
// "inputTables",
"inputTables"
,
// "outputTable",
"outputTable"
,
// None, Some(List("name")), true, GraphPersistenceStrategy1, g).evaluate()
None
,
Some
(
List
(
"name"
)),
true
,
GraphPersistenceStrategy1
,
g
).
evaluate
()
// validateJson(r)
validateJson
(
r
)
// }
}
test
(
"testHighLevelWhereUsed"
)
{
val
r
=
HiveWhereUsedQuery
(
"Table"
,
"sales_fact"
,
"LoadProcess"
,
"inputTables"
,
"outputTable"
,
None
,
Some
(
List
(
"name"
)),
true
,
GraphPersistenceStrategy1
,
g
).
evaluate
()
validateJson
(
r
)
}
}
}
\ No newline at end of file
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