Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dlink
Project
Project
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
zhaowei
dlink
Commits
05f9932f
Commit
05f9932f
authored
Jun 22, 2022
by
wenmo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fix-629] [core] Fix lineage of the same field name cannot be correctly resolved
parent
5a2df799
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
16 deletions
+94
-16
LineageColumnGenerator.java
...a/com/dlink/explainer/lineage/LineageColumnGenerator.java
+94
-15
index.tsx
...eb/src/components/Studio/StudioConsole/StudioCA/index.tsx
+0
-1
No files found.
dlink-core/src/main/java/com/dlink/explainer/lineage/LineageColumnGenerator.java
View file @
05f9932f
package
com
.
dlink
.
explainer
.
lineage
;
package
com
.
dlink
.
explainer
.
lineage
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.explainer.ca.ColumnCA
;
import
com.dlink.explainer.ca.ColumnCA
;
import
com.dlink.explainer.ca.NodeRel
;
import
com.dlink.explainer.ca.NodeRel
;
import
com.dlink.explainer.ca.TableCA
;
import
com.dlink.explainer.ca.TableCA
;
import
com.dlink.explainer.trans.Field
;
import
com.dlink.explainer.trans.Field
;
import
com.dlink.explainer.trans.OperatorTrans
;
import
com.dlink.explainer.trans.OperatorTrans
;
import
com.dlink.explainer.trans.Predecessor
;
import
com.dlink.explainer.trans.SinkTrans
;
import
com.dlink.explainer.trans.SinkTrans
;
import
com.dlink.explainer.trans.Trans
;
import
com.dlink.explainer.trans.Trans
;
import
com.dlink.utils.MapParseUtils
;
import
com.dlink.utils.MapParseUtils
;
import
java.util.*
;
/**
/**
* LineageColumnGenerator
* LineageColumnGenerator
*
*
...
@@ -47,11 +53,11 @@ public class LineageColumnGenerator {
...
@@ -47,11 +53,11 @@ public class LineageColumnGenerator {
ColumnCA
columnCA
=
new
ColumnCA
(
id
,
fieldName
,
fieldName
,
fieldName
,
fieldName
,
fieldName
,
tableCA
);
ColumnCA
columnCA
=
new
ColumnCA
(
id
,
fieldName
,
fieldName
,
fieldName
,
fieldName
,
fieldName
,
tableCA
);
columnCASMaps
.
put
(
id
,
columnCA
);
columnCASMaps
.
put
(
id
,
columnCA
);
columnCAS
.
add
(
columnCA
);
columnCAS
.
add
(
columnCA
);
buildColumnCAFields
(
tableCA
,
tableCA
.
getParentId
(),
columnCA
);
buildColumnCAFields
(
tableCA
,
tableCA
.
getParentId
(),
tableCA
.
getId
(),
columnCA
,
new
ArrayList
<>()
);
}
}
/*for (ColumnCA columnCA : columnCAS) {
/*for (ColumnCA columnCA : columnCAS) {
if (columnCA.getTableCA().getId() == tableCA.getId()) {
if (columnCA.getTableCA().getId() == tableCA.getId()) {
buildColumnCAFields(tableCA, tableCA.getParentId(),
columnCA
);
buildColumnCAFields(tableCA, tableCA.getParentId(),
tableCA.getId() columnCA, new ArrayList<>()
);
}
}
}*/
}*/
}
}
...
@@ -82,35 +88,108 @@ public class LineageColumnGenerator {
...
@@ -82,35 +88,108 @@ public class LineageColumnGenerator {
}
}
}
}
private
void
buildColumnCAFields
(
TableCA
tableCA
,
Integer
id
,
ColumnCA
columnCA
)
{
private
void
buildColumnCAFields
(
TableCA
tableCA
,
Integer
id
,
Integer
preId
,
ColumnCA
columnCA
,
List
<
Field
>
ignoreSelects
)
{
if
(
transMaps
.
get
(
id
)
instanceof
OperatorTrans
)
{
if
(
transMaps
.
get
(
id
)
instanceof
OperatorTrans
)
{
if
(
tableCA
.
getId
().
equals
(
id
))
{
if
(
tableCA
.
getId
().
equals
(
id
))
{
return
;
return
;
}
}
OperatorTrans
trans
=
(
OperatorTrans
)
transMaps
.
get
(
id
);
OperatorTrans
trans
=
(
OperatorTrans
)
transMaps
.
get
(
id
);
List
<
Field
>
selects
=
trans
.
getSelect
();
List
<
Field
>
selects
=
trans
.
getSelect
();
if
(
Asserts
.
isNotNull
(
selects
))
{
List
<
Field
>
targetSelects
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
selects
.
size
();
i
++)
{
if
(
trans
.
getPredecessors
().
size
()
>
1
)
{
String
operation
=
selects
.
get
(
i
).
getFragment
();
int
predecessorsIndex
=
0
;
String
alias
=
selects
.
get
(
i
).
getAlias
();
for
(
Predecessor
predecessor
:
trans
.
getPredecessors
())
{
searchSelect
(
tableCA
,
columnCA
,
trans
,
operation
,
alias
);
if
(!
predecessor
.
getId
().
equals
(
preId
))
{
predecessorsIndex
=
predecessorsIndex
+
1
;
}
else
{
break
;
}
}
if
(
predecessorsIndex
==
0
)
{
for
(
int
i
=
0
;
i
<
selects
.
size
();
i
++)
{
if
(
tableCA
.
getUseFields
().
contains
(
selects
.
get
(
i
).
getAlias
()))
{
if
(
targetSelects
.
size
()
==
0
)
{
targetSelects
.
add
(
selects
.
get
(
i
));
}
else
if
(
tableCA
.
getUseFields
().
indexOf
(
targetSelects
.
get
(
targetSelects
.
size
()
-
1
).
getAlias
())
<
tableCA
.
getUseFields
().
indexOf
(
selects
.
get
(
i
).
getAlias
()))
{
targetSelects
.
add
(
selects
.
get
(
i
));
}
else
{
break
;
}
}
else
{
break
;
}
}
}
else
{
for
(
int
i
=
selects
.
size
()
-
1
;
i
>=
0
;
i
--)
{
if
(
tableCA
.
getUseFields
().
contains
(
selects
.
get
(
i
).
getAlias
()))
{
if
(
targetSelects
.
size
()
==
0
)
{
targetSelects
.
add
(
selects
.
get
(
i
));
}
else
if
(
tableCA
.
getUseFields
().
indexOf
(
targetSelects
.
get
(
targetSelects
.
size
()
-
1
).
getAlias
())
>
tableCA
.
getUseFields
().
indexOf
(
selects
.
get
(
i
).
getAlias
()))
{
targetSelects
.
add
(
selects
.
get
(
i
));
}
else
{
break
;
}
}
else
{
break
;
}
}
}
}
else
{
if
(
Asserts
.
isNotNullCollection
(
trans
.
getTable
()))
{
for
(
int
i
=
0
;
i
<
selects
.
size
();
i
++)
{
if
(
tableCA
.
getUseFields
().
contains
(
selects
.
get
(
i
).
getAlias
()))
{
if
(
targetSelects
.
size
()
==
0
)
{
targetSelects
.
add
(
selects
.
get
(
i
));
}
else
if
(
tableCA
.
getUseFields
().
indexOf
(
targetSelects
.
get
(
targetSelects
.
size
()
-
1
).
getAlias
())
<
tableCA
.
getUseFields
().
indexOf
(
selects
.
get
(
i
).
getAlias
()))
{
targetSelects
.
add
(
selects
.
get
(
i
));
}
else
{
break
;
}
}
else
{
break
;
}
}
}
else
{
targetSelects
=
selects
;
}
}
if
(
Asserts
.
isNotNull
(
targetSelects
))
{
if
(
selects
.
size
()
!=
targetSelects
.
size
())
{
for
(
int
i
=
0
;
i
<
selects
.
size
();
i
++)
{
if
(!
targetSelects
.
contains
(
selects
.
get
(
i
)))
{
ignoreSelects
.
add
(
selects
.
get
(
i
));
}
}
}
for
(
int
i
=
0
;
i
<
targetSelects
.
size
();
i
++)
{
String
operation
=
targetSelects
.
get
(
i
).
getFragment
();
String
alias
=
targetSelects
.
get
(
i
).
getAlias
();
searchSelect
(
tableCA
,
columnCA
,
trans
,
operation
,
alias
,
ignoreSelects
);
}
}
}
}
List
<
String
>
fields
=
trans
.
getFields
();
List
<
String
>
fields
=
trans
.
getFields
();
if
(
Asserts
.
isNotNull
(
fields
))
{
if
(
Asserts
.
isNotNull
(
fields
))
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
String
field
=
fields
.
get
(
i
);
String
field
=
fields
.
get
(
i
);
searchSelect
(
tableCA
,
columnCA
,
trans
,
field
,
field
);
searchSelect
(
tableCA
,
columnCA
,
trans
,
field
,
field
,
ignoreSelects
);
}
}
}
}
if
(
trans
.
getParentId
()
!=
null
)
{
if
(
trans
.
getParentId
()
!=
null
)
{
buildColumnCAFields
(
tableCA
,
trans
.
getParentId
(),
columnCA
);
buildColumnCAFields
(
tableCA
,
trans
.
getParentId
(),
trans
.
getId
(),
columnCA
,
ignoreSelects
);
}
}
}
}
}
}
private
void
searchSelect
(
TableCA
tableCA
,
ColumnCA
columnCA
,
OperatorTrans
trans
,
String
operation
,
String
alias
)
{
private
void
searchSelect
(
TableCA
tableCA
,
ColumnCA
columnCA
,
OperatorTrans
trans
,
String
operation
,
String
alias
,
List
<
Field
>
ignoreSelects
)
{
if
(
MapParseUtils
.
hasField
(
operation
,
columnCA
.
getAlias
()))
{
if
(
MapParseUtils
.
hasField
(
operation
,
columnCA
.
getAlias
()))
{
for
(
Field
field
:
ignoreSelects
)
{
if
(
field
.
getAlias
().
equals
(
columnCA
.
getAlias
()))
{
return
;
}
}
boolean
isHad
=
false
;
boolean
isHad
=
false
;
Integer
cid
=
null
;
Integer
cid
=
null
;
for
(
Map
.
Entry
<
Integer
,
ColumnCA
>
item
:
columnCASMaps
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
ColumnCA
>
item
:
columnCASMaps
.
entrySet
())
{
...
@@ -128,7 +207,7 @@ public class LineageColumnGenerator {
...
@@ -128,7 +207,7 @@ public class LineageColumnGenerator {
cid
=
index
++;
cid
=
index
++;
ColumnCA
columnCA2
=
new
ColumnCA
(
cid
,
alias
,
alias
,
alias
,
alias
,
operation
,
tableCA
);
ColumnCA
columnCA2
=
new
ColumnCA
(
cid
,
alias
,
alias
,
alias
,
alias
,
operation
,
tableCA
);
columnCASMaps
.
put
(
cid
,
columnCA2
);
columnCASMaps
.
put
(
cid
,
columnCA2
);
buildColumnCAFields
(
tableCA
,
trans
.
getParentId
(),
columnCA2
);
buildColumnCAFields
(
tableCA
,
trans
.
getParentId
(),
trans
.
getId
(),
columnCA2
,
ignoreSelects
);
}
}
columnCASRel
.
add
(
new
NodeRel
(
columnCA
.
getId
(),
cid
));
columnCASRel
.
add
(
new
NodeRel
(
columnCA
.
getId
(),
cid
));
}
}
...
@@ -180,7 +259,7 @@ public class LineageColumnGenerator {
...
@@ -180,7 +259,7 @@ public class LineageColumnGenerator {
private
void
buildSinkSuf
(
Integer
preId
,
Integer
sourcePreId
)
{
private
void
buildSinkSuf
(
Integer
preId
,
Integer
sourcePreId
)
{
for
(
NodeRel
nodeRel
:
columnCASRel
)
{
for
(
NodeRel
nodeRel
:
columnCASRel
)
{
if
(
nodeRel
.
getPreId
().
equals
(
preId
)
)
{
if
(
nodeRel
.
getPreId
().
equals
(
preId
))
{
Integer
nextSufId
=
nodeRel
.
getSufId
();
Integer
nextSufId
=
nodeRel
.
getSufId
();
if
(
sinkColumns
.
contains
(
nextSufId
))
{
if
(
sinkColumns
.
contains
(
nextSufId
))
{
columnCASRelChain
.
add
(
new
NodeRel
(
sourcePreId
,
nextSufId
));
columnCASRelChain
.
add
(
new
NodeRel
(
sourcePreId
,
nextSufId
));
...
...
dlink-web/src/components/Studio/StudioConsole/StudioCA/index.tsx
View file @
05f9932f
...
@@ -15,7 +15,6 @@ const StudioCA = (props: any) => {
...
@@ -15,7 +15,6 @@ const StudioCA = (props: any) => {
const
{
current
}
=
props
;
const
{
current
}
=
props
;
const
[
data
,
setData
]
=
useState
(
getInit
());
const
[
data
,
setData
]
=
useState
(
getInit
());
debugger
;
const
handleLineage
=
()
=>
{
const
handleLineage
=
()
=>
{
const
res
=
getLineage
({
const
res
=
getLineage
({
statement
:
current
.
value
,
statement
:
current
.
value
,
...
...
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