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
c33e5acd
Commit
c33e5acd
authored
9 years ago
by
Harish Butani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG-37715: handle multiplicity correctly
parent
0ee43c5e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
2 deletions
+117
-2
QueryTestsUtils.scala
...la/org/apache/hadoop/metadata/query/QueryTestsUtils.scala
+1
-1
DataTypes.java
...rg/apache/hadoop/metadata/typesystem/types/DataTypes.java
+1
-1
TypeSystem.java
...g/apache/hadoop/metadata/typesystem/types/TypeSystem.java
+8
-0
MultiplicityTest.scala
...adoop/metadata/typesystem/builders/MultiplicityTest.scala
+107
-0
No files found.
repository/src/test/scala/org/apache/hadoop/metadata/query/QueryTestsUtils.scala
View file @
c33e5acd
...
@@ -109,7 +109,7 @@ object QueryTestsUtils extends GraphUtils {
...
@@ -109,7 +109,7 @@ object QueryTestsUtils extends GraphUtils {
def
viewClsDef
=
new
HierarchicalTypeDefinition
[
ClassType
](
classOf
[
ClassType
],
"View"
,
null
,
def
viewClsDef
=
new
HierarchicalTypeDefinition
[
ClassType
](
classOf
[
ClassType
],
"View"
,
null
,
Array
(
Array
(
attrDef
(
"name"
,
DataTypes
.
STRING_TYPE
),
attrDef
(
"name"
,
DataTypes
.
STRING_TYPE
),
new
AttributeDefinition
(
"inputTables"
,
"Table"
,
Multiplicity
.
COLLECTION
,
false
,
null
)
new
AttributeDefinition
(
"inputTables"
,
DataTypes
.
arrayTypeName
(
"Table"
)
,
Multiplicity
.
COLLECTION
,
false
,
null
)
))
))
def
dimTraitDef
=
new
HierarchicalTypeDefinition
[
TraitType
](
classOf
[
TraitType
],
"Dimension"
,
null
,
def
dimTraitDef
=
new
HierarchicalTypeDefinition
[
TraitType
](
classOf
[
TraitType
],
"Dimension"
,
null
,
...
...
This diff is collapsed.
Click to expand it.
typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/DataTypes.java
View file @
c33e5acd
...
@@ -508,7 +508,7 @@ public class DataTypes {
...
@@ -508,7 +508,7 @@ public class DataTypes {
TypeSystem
.
getInstance
().
allowNullsInCollections
()
TypeSystem
.
getInstance
().
allowNullsInCollections
()
?
Multiplicity
.
OPTIONAL
:
Multiplicity
.
REQUIRED
));
?
Multiplicity
.
OPTIONAL
:
Multiplicity
.
REQUIRED
));
}
}
return
b
.
build
();
return
m
.
isUnique
?
b
.
build
().
asList
()
:
b
.
build
();
}
else
{
}
else
{
try
{
try
{
return
ImmutableList
.
of
(
elemType
.
convert
(
val
,
return
ImmutableList
.
of
(
elemType
.
convert
(
val
,
...
...
This diff is collapsed.
Click to expand it.
typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/TypeSystem.java
View file @
c33e5acd
...
@@ -462,6 +462,14 @@ public class TypeSystem {
...
@@ -462,6 +462,14 @@ public class TypeSystem {
}
}
}
}
if
(
info
.
multiplicity
.
upper
>
1
&&
!(
info
.
dataType
().
getTypeCategory
()
==
DataTypes
.
TypeCategory
.
MAP
||
info
.
dataType
().
getTypeCategory
()
==
DataTypes
.
TypeCategory
.
ARRAY
))
{
throw
new
MetadataException
(
String
.
format
(
"A multiplicty of more than one requires a collection type for attribute '%s'"
,
info
.
name
));
}
return
info
;
return
info
;
}
}
...
...
This diff is collapsed.
Click to expand it.
typesystem/src/test/scala/org/apache/hadoop/metadata/typesystem/builders/MultiplicityTest.scala
0 → 100644
View file @
c33e5acd
package
org.apache.hadoop.metadata.typesystem.builders
import
org.apache.hadoop.metadata.MetadataException
import
org.apache.hadoop.metadata.typesystem.types.
{
Multiplicity
,
ClassType
,
TypeSystem
}
import
org.scalatest.
{
BeforeAndAfterAll
,
FunSuite
}
class
MultiplicityTest
extends
FunSuite
with
BeforeAndAfterAll
{
override
def
beforeAll
()
=
{
TypeSystem
.
getInstance
().
reset
()
val
b
=
new
TypesBuilder
import
b._
val
tDef
=
types
{
_trait
(
"Dimension"
)
{}
_trait
(
"PII"
)
{}
_trait
(
"Metric"
)
{}
_trait
(
"ETL"
)
{}
_trait
(
"JdbcAccess"
)
{}
_class
(
"DB"
)
{
"name"
~
(
string
,
required
,
indexed
,
unique
)
"owner"
~
(
string
)
"createTime"
~
(
int
)
}
_class
(
"StorageDesc"
)
{
"inputFormat"
~
(
string
,
required
)
"outputFormat"
~
(
string
,
required
)
}
_class
(
"Column"
)
{
"name"
~
(
string
,
required
)
"dataType"
~
(
string
,
required
)
"sd"
~
(
"StorageDesc"
,
required
)
}
_class
(
"Table"
,
List
())
{
"name"
~
(
string
,
required
,
indexed
)
"db"
~
(
"DB"
,
required
)
"sd"
~
(
"StorageDesc"
,
required
)
}
_class
(
"LoadProcess"
)
{
"name"
~
(
string
,
required
)
"inputTables"
~
(
array
(
"Table"
),
collection
)
"outputTable"
~
(
"Table"
,
required
)
}
_class
(
"View"
)
{
"name"
~
(
string
,
required
)
"inputTables"
~
(
array
(
"Table"
),
collection
)
}
_class
(
"AT"
)
{
"name"
~
(
string
,
required
)
"stringSet"
~
(
array
(
"string"
),
multiplicty
(
0
,
Int
.
MaxValue
,
true
))
}
}
TypeSystem
.
getInstance
().
defineTypes
(
tDef
)
}
test
(
"test1"
)
{
val
b
=
new
InstanceBuilder
import
b._
val
instances
=
b
create
{
val
a
=
instance
(
"AT"
)
{
// use instance to create Referenceables. use closure to
// set attributes of instance
'name
~
"A1"
// use '~' to set attributes. Use a Symbol (names starting with ') for
'stringSet
~
Seq
(
"a"
,
"a"
)
}
}
val
ts
=
TypeSystem
.
getInstance
()
import
scala.collection.JavaConversions._
val
typedInstances
=
instances
.
map
{
i
=>
val
iTyp
=
ts
.
getDataType
(
classOf
[
ClassType
],
i
.
getTypeName
)
iTyp
.
convert
(
i
,
Multiplicity
.
REQUIRED
)
}
typedInstances
.
foreach
{
i
=>
println
(
i
)
}
}
test
(
"WrongMultiplicity"
)
{
val
b
=
new
TypesBuilder
import
b._
val
tDef
=
types
{
_class
(
"Wrong"
)
{
"name"
~
(
string
,
required
)
"stringSet"
~
(
string
,
multiplicty
(
0
,
Int
.
MaxValue
,
true
))
}
}
val
me
=
intercept
[
MetadataException
]
{
TypeSystem
.
getInstance
().
defineTypes
(
tDef
)
}
assert
(
"A multiplicty of more than one requires a collection type for attribute 'stringSet'"
==
me
.
getMessage
)
}
}
This diff is collapsed.
Click to expand it.
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