Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
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
wangpeng
dinky
Commits
753b229a
Unverified
Commit
753b229a
authored
Feb 23, 2023
by
mymmyy
Committed by
GitHub
Feb 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[1636][feature] Add webUI console error output when getting lineage exception (#1675)
parent
ff45f6dc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
3 deletions
+25
-3
StudioController.java
.../src/main/java/org/dinky/controller/StudioController.java
+5
-1
StudioServiceImpl.java
...c/main/java/org/dinky/service/impl/StudioServiceImpl.java
+5
-0
LineageBuilder.java
...n/java/org/dinky/explainer/sqllineage/LineageBuilder.java
+14
-2
ProcessType.java
...ss/src/main/java/org/dinky/process/model/ProcessType.java
+1
-0
No files found.
dinky-admin/src/main/java/org/dinky/controller/StudioController.java
View file @
753b229a
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
package
org
.
dinky
.
controller
;
package
org
.
dinky
.
controller
;
import
org.dinky.assertion.Asserts
;
import
org.dinky.common.result.Result
;
import
org.dinky.common.result.Result
;
import
org.dinky.dto.SessionDTO
;
import
org.dinky.dto.SessionDTO
;
import
org.dinky.dto.StudioCADTO
;
import
org.dinky.dto.StudioCADTO
;
...
@@ -115,7 +116,10 @@ public class StudioController {
...
@@ -115,7 +116,10 @@ public class StudioController {
/** 获取单任务实例的血缘分析 */
/** 获取单任务实例的血缘分析 */
@PostMapping
(
"/getLineage"
)
@PostMapping
(
"/getLineage"
)
public
Result
<
LineageResult
>
getLineage
(
@RequestBody
StudioCADTO
studioCADTO
)
{
public
Result
<
LineageResult
>
getLineage
(
@RequestBody
StudioCADTO
studioCADTO
)
{
return
Result
.
succeed
(
studioService
.
getLineage
(
studioCADTO
),
"刷新成功"
);
LineageResult
lineage
=
studioService
.
getLineage
(
studioCADTO
);
return
Asserts
.
isNull
(
lineage
)
?
Result
.
failed
(
"血缘分析异常"
)
:
Result
.
succeed
(
lineage
,
"血缘分析成功"
);
}
}
/** 创建session */
/** 创建session */
...
...
dinky-admin/src/main/java/org/dinky/service/impl/StudioServiceImpl.java
View file @
753b229a
...
@@ -372,13 +372,18 @@ public class StudioServiceImpl implements StudioService {
...
@@ -372,13 +372,18 @@ public class StudioServiceImpl implements StudioService {
@Override
@Override
public
LineageResult
getLineage
(
StudioCADTO
studioCADTO
)
{
public
LineageResult
getLineage
(
StudioCADTO
studioCADTO
)
{
ProcessEntity
process
=
ProcessContextHolder
.
registerProcess
(
ProcessEntity
.
init
(
ProcessType
.
LINEAGE
,
StpUtil
.
getLoginIdAsInt
()));
if
(
Asserts
.
isNotNullString
(
studioCADTO
.
getDialect
())
if
(
Asserts
.
isNotNullString
(
studioCADTO
.
getDialect
())
&&
!
Dialect
.
FLINK_SQL
.
equalsVal
(
studioCADTO
.
getDialect
()))
{
&&
!
Dialect
.
FLINK_SQL
.
equalsVal
(
studioCADTO
.
getDialect
()))
{
if
(
Asserts
.
isNull
(
studioCADTO
.
getDatabaseId
()))
{
if
(
Asserts
.
isNull
(
studioCADTO
.
getDatabaseId
()))
{
process
.
error
(
"Job's data source not selected!"
);
return
null
;
return
null
;
}
}
DataBase
dataBase
=
dataBaseService
.
getById
(
studioCADTO
.
getDatabaseId
());
DataBase
dataBase
=
dataBaseService
.
getById
(
studioCADTO
.
getDatabaseId
());
if
(
Asserts
.
isNull
(
dataBase
))
{
if
(
Asserts
.
isNull
(
dataBase
))
{
process
.
error
(
"Job's data source does not exist!"
);
return
null
;
return
null
;
}
}
if
(
Dialect
.
DORIS
.
equalsVal
(
studioCADTO
.
getDialect
()))
{
if
(
Dialect
.
DORIS
.
equalsVal
(
studioCADTO
.
getDialect
()))
{
...
...
dinky-core/src/main/java/org/dinky/explainer/sqllineage/LineageBuilder.java
View file @
753b229a
...
@@ -26,6 +26,8 @@ import org.dinky.explainer.lineage.LineageTable;
...
@@ -26,6 +26,8 @@ import org.dinky.explainer.lineage.LineageTable;
import
org.dinky.metadata.driver.Driver
;
import
org.dinky.metadata.driver.Driver
;
import
org.dinky.metadata.driver.DriverConfig
;
import
org.dinky.metadata.driver.DriverConfig
;
import
org.dinky.model.Column
;
import
org.dinky.model.Column
;
import
org.dinky.process.context.ProcessContextHolder
;
import
org.dinky.process.model.ProcessEntity
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -50,6 +52,7 @@ public class LineageBuilder {
...
@@ -50,6 +52,7 @@ public class LineageBuilder {
protected
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LineageBuilder
.
class
);
protected
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LineageBuilder
.
class
);
public
static
LineageResult
getSqlLineageByOne
(
String
statement
,
String
type
)
{
public
static
LineageResult
getSqlLineageByOne
(
String
statement
,
String
type
)
{
ProcessEntity
process
=
ProcessContextHolder
.
getProcess
();
List
<
LineageTable
>
tables
=
new
ArrayList
<>();
List
<
LineageTable
>
tables
=
new
ArrayList
<>();
List
<
LineageRelation
>
relations
=
new
ArrayList
<>();
List
<
LineageRelation
>
relations
=
new
ArrayList
<>();
try
{
try
{
...
@@ -147,7 +150,8 @@ public class LineageBuilder {
...
@@ -147,7 +150,8 @@ public class LineageBuilder {
int
tSize
=
tgtList
.
size
();
int
tSize
=
tgtList
.
size
();
int
sSize
=
srcLists
.
size
();
int
sSize
=
srcLists
.
size
();
if
(
tSize
!=
sSize
&&
tSize
*
2
!=
sSize
)
{
if
(
tSize
!=
sSize
&&
tSize
*
2
!=
sSize
)
{
logger
.
info
(
"出现字段位数不相等错误"
);
logger
.
error
(
"Target table fields do not match!"
);
process
.
error
(
"Target table fields do not match!"
);
return
null
;
return
null
;
}
}
for
(
int
i
=
0
;
i
<
tSize
;
i
++)
{
for
(
int
i
=
0
;
i
<
tSize
;
i
++)
{
...
@@ -177,10 +181,12 @@ public class LineageBuilder {
...
@@ -177,10 +181,12 @@ public class LineageBuilder {
}
}
}
}
}
else
{
}
else
{
process
.
info
(
"Does not contain an insert statement, cannot analyze the lineage."
);
return
null
;
return
null
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
process
.
error
(
"Unexpected exceptions occur! "
+
e
.
getMessage
());
return
null
;
return
null
;
}
}
return
LineageResult
.
build
(
tables
,
relations
);
return
LineageResult
.
build
(
tables
,
relations
);
...
@@ -188,6 +194,7 @@ public class LineageBuilder {
...
@@ -188,6 +194,7 @@ public class LineageBuilder {
public
static
LineageResult
getSqlLineage
(
public
static
LineageResult
getSqlLineage
(
String
statement
,
String
type
,
DriverConfig
driverConfig
)
{
String
statement
,
String
type
,
DriverConfig
driverConfig
)
{
ProcessEntity
process
=
ProcessContextHolder
.
getProcess
();
List
<
LineageTable
>
tables
=
new
ArrayList
<>();
List
<
LineageTable
>
tables
=
new
ArrayList
<>();
List
<
LineageRelation
>
relations
=
new
ArrayList
<>();
List
<
LineageRelation
>
relations
=
new
ArrayList
<>();
Map
<
Integer
,
List
<
List
<
TableStat
.
Column
>>>
srcMap
=
new
HashMap
<>();
Map
<
Integer
,
List
<
List
<
TableStat
.
Column
>>>
srcMap
=
new
HashMap
<>();
...
@@ -214,6 +221,7 @@ public class LineageBuilder {
...
@@ -214,6 +221,7 @@ public class LineageBuilder {
if
(
columns
.
size
()
<=
0
||
sqls
[
n
].
contains
(
"*"
))
{
if
(
columns
.
size
()
<=
0
||
sqls
[
n
].
contains
(
"*"
))
{
Driver
driver
=
Driver
.
build
(
driverConfig
);
Driver
driver
=
Driver
.
build
(
driverConfig
);
if
(!
targetTable
.
contains
(
"."
))
{
if
(!
targetTable
.
contains
(
"."
))
{
process
.
error
(
"Target table not specified database!"
);
return
null
;
return
null
;
}
}
List
<
Column
>
columns1
=
List
<
Column
>
columns1
=
...
@@ -270,6 +278,8 @@ public class LineageBuilder {
...
@@ -270,6 +278,8 @@ public class LineageBuilder {
srcMap
.
put
(
n
,
srcLists
);
srcMap
.
put
(
n
,
srcLists
);
tgtMap
.
put
(
n
,
tgtList
);
tgtMap
.
put
(
n
,
tgtList
);
}
else
{
}
else
{
process
.
info
(
"Does not contain an insert statement, cannot analyze the lineage."
);
return
null
;
return
null
;
}
}
}
}
...
@@ -320,7 +330,8 @@ public class LineageBuilder {
...
@@ -320,7 +330,8 @@ public class LineageBuilder {
int
tSize
=
tgtList
.
size
();
int
tSize
=
tgtList
.
size
();
int
sSize
=
srcLists
.
size
();
int
sSize
=
srcLists
.
size
();
if
(
tSize
!=
sSize
&&
tSize
*
2
!=
sSize
)
{
if
(
tSize
!=
sSize
&&
tSize
*
2
!=
sSize
)
{
logger
.
info
(
"出现字段位数不相等错误"
);
logger
.
error
(
"Target table fields do not match!"
);
process
.
error
(
"Target table fields do not match!"
);
return
null
;
return
null
;
}
}
for
(
int
i
=
0
;
i
<
tSize
;
i
++)
{
for
(
int
i
=
0
;
i
<
tSize
;
i
++)
{
...
@@ -352,6 +363,7 @@ public class LineageBuilder {
...
@@ -352,6 +363,7 @@ public class LineageBuilder {
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
process
.
error
(
"Unexpected exceptions occur! "
+
e
.
getMessage
());
return
null
;
return
null
;
}
}
return
LineageResult
.
build
(
tables
,
relations
);
return
LineageResult
.
build
(
tables
,
relations
);
...
...
dinky-process/src/main/java/org/dinky/process/model/ProcessType.java
View file @
753b229a
...
@@ -34,6 +34,7 @@ public enum ProcessType {
...
@@ -34,6 +34,7 @@ public enum ProcessType {
SQL_EXPLAIN
(
"SQLExplain"
),
SQL_EXPLAIN
(
"SQLExplain"
),
SQL_EXECUTE
(
"SQLExecute"
),
SQL_EXECUTE
(
"SQLExecute"
),
SQL_SUBMIT
(
"SQLSubmit"
),
SQL_SUBMIT
(
"SQLSubmit"
),
LINEAGE
(
"Lineage"
),
UNKNOWN
(
"Unknown"
);
UNKNOWN
(
"Unknown"
);
private
String
value
;
private
String
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