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
92255194
Unverified
Commit
92255194
authored
Feb 26, 2024
by
Zzm0809
Committed by
GitHub
Feb 26, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fix] fix doris datasource get sql ddl and sql query maybe npe (#3181)
Co-authored-by:
Zzm0809
<
Zzm0809@users.noreply.github.com
>
parent
c754d43c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
26 deletions
+35
-26
SqlGeneration.java
...min/src/main/java/org/dinky/data/model/SqlGeneration.java
+3
-3
DorisDriver.java
.../src/main/java/org/dinky/metadata/driver/DorisDriver.java
+5
-4
index.tsx
...ponents/DataSourceDetail/RightTagsRouter/GenSQL/index.tsx
+12
-8
index.tsx
...nents/DataSourceDetail/RightTagsRouter/SQLQuery/index.tsx
+12
-8
data.d.ts
dinky-web/src/types/RegCenter/data.d.ts
+3
-3
No files found.
dinky-admin/src/main/java/org/dinky/data/model/SqlGeneration.java
View file @
92255194
...
@@ -40,11 +40,11 @@ public class SqlGeneration {
...
@@ -40,11 +40,11 @@ public class SqlGeneration {
value
=
"Flink SQL Create Statement"
,
value
=
"Flink SQL Create Statement"
,
dataType
=
"String"
,
dataType
=
"String"
,
notes
=
"Flink SQL statement for creating a table or view"
)
notes
=
"Flink SQL statement for creating a table or view"
)
private
String
flinkSqlCreate
;
private
String
flinkSqlCreate
=
""
;
@ApiModelProperty
(
value
=
"SQL Select Statement"
,
dataType
=
"String"
,
notes
=
"SQL SELECT statement"
)
@ApiModelProperty
(
value
=
"SQL Select Statement"
,
dataType
=
"String"
,
notes
=
"SQL SELECT statement"
)
private
String
sqlSelect
;
private
String
sqlSelect
=
""
;
@ApiModelProperty
(
value
=
"SQL Create Statement"
,
dataType
=
"String"
,
notes
=
"SQL statement for creating a table"
)
@ApiModelProperty
(
value
=
"SQL Create Statement"
,
dataType
=
"String"
,
notes
=
"SQL statement for creating a table"
)
private
String
sqlCreate
;
private
String
sqlCreate
=
""
;
}
}
dinky-metadata/dinky-metadata-doris/src/main/java/org/dinky/metadata/driver/DorisDriver.java
View file @
92255194
...
@@ -147,9 +147,7 @@ public class DorisDriver extends AbstractJdbcDriver {
...
@@ -147,9 +147,7 @@ public class DorisDriver extends AbstractJdbcDriver {
private
String
genTable
(
Table
table
)
{
private
String
genTable
(
Table
table
)
{
String
columnStrs
=
table
.
getColumns
().
stream
()
String
columnStrs
=
table
.
getColumns
().
stream
()
.
map
(
column
->
{
.
map
(
column
->
generateColumnSql
(
column
,
table
.
getDriverType
()))
return
generateColumnSql
(
column
,
table
.
getDriverType
());
})
.
collect
(
Collectors
.
joining
(
",\n"
));
.
collect
(
Collectors
.
joining
(
",\n"
));
List
<
String
>
columnKeys
=
table
.
getColumns
().
stream
()
List
<
String
>
columnKeys
=
table
.
getColumns
().
stream
()
...
@@ -193,6 +191,9 @@ public class DorisDriver extends AbstractJdbcDriver {
...
@@ -193,6 +191,9 @@ public class DorisDriver extends AbstractJdbcDriver {
case
MYSQL:
case
MYSQL:
columnType
=
MysqlType
.
toDorisType
(
column
.
getType
(),
length
,
scale
);
columnType
=
MysqlType
.
toDorisType
(
column
.
getType
(),
length
,
scale
);
break
;
break
;
case
DORIS:
columnType
=
new
DorisTypeConvert
().
convertToDB
(
column
);
break
;
case
ORACLE:
case
ORACLE:
columnType
=
OracleType
.
toDorisType
(
column
.
getType
(),
length
,
scale
);
columnType
=
OracleType
.
toDorisType
(
column
.
getType
(),
length
,
scale
);
break
;
break
;
...
@@ -203,7 +204,7 @@ public class DorisDriver extends AbstractJdbcDriver {
...
@@ -203,7 +204,7 @@ public class DorisDriver extends AbstractJdbcDriver {
columnType
=
SqlServerType
.
toDorisType
(
column
.
getType
(),
length
,
scale
);
columnType
=
SqlServerType
.
toDorisType
(
column
.
getType
(),
length
,
scale
);
break
;
break
;
default
:
default
:
String
errMsg
=
"Not support "
+
driverType
+
"
schema change
."
;
String
errMsg
=
"Not support "
+
driverType
+
"
to Doris column type conversion
."
;
throw
new
UnsupportedOperationException
(
errMsg
);
throw
new
UnsupportedOperationException
(
errMsg
);
}
}
...
...
dinky-web/src/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/GenSQL/index.tsx
View file @
92255194
...
@@ -48,7 +48,11 @@ const CodeShowProps = {
...
@@ -48,7 +48,11 @@ const CodeShowProps = {
const
GenSQL
:
React
.
FC
<
GenSQLProps
>
=
(
props
)
=>
{
const
GenSQL
:
React
.
FC
<
GenSQLProps
>
=
(
props
)
=>
{
const
{
queryParams
,
tagDisabled
}
=
props
;
const
{
queryParams
,
tagDisabled
}
=
props
;
const
[
genSQL
,
setGenSQL
]
=
useState
<
Partial
<
DataSources
.
SqlGeneration
>>
({});
const
[
genSQL
,
setGenSQL
]
=
useState
<
DataSources
.
SqlGeneration
>
({
flinkSqlCreate
:
''
,
sqlSelect
:
''
,
sqlCreate
:
''
});
const
[
activeKey
,
setActiveKey
]
=
React
.
useState
<
string
>
(
'flinkddl'
);
const
[
activeKey
,
setActiveKey
]
=
React
.
useState
<
string
>
(
'flinkddl'
);
const
queryDDL
=
useCallback
(
async
()
=>
{
const
queryDDL
=
useCallback
(
async
()
=>
{
...
@@ -92,21 +96,21 @@ const GenSQL: React.FC<GenSQLProps> = (props) => {
...
@@ -92,21 +96,21 @@ const GenSQL: React.FC<GenSQLProps> = (props) => {
const
tabList
=
[
const
tabList
=
[
{
{
key
:
'flinkddl'
,
key
:
'flinkddl'
,
label
:
renderLabel
(
genSQL
.
flinkSqlCreate
||
''
,
'Flink DDL'
),
label
:
renderLabel
(
genSQL
?.
flinkSqlCreate
??
''
,
'Flink DDL'
),
disabled
:
tagDisabled
,
disabled
:
tagDisabled
,
children
:
renderContent
(
genSQL
.
flinkSqlCreate
)
children
:
renderContent
(
genSQL
?.
flinkSqlCreate
??
''
)
},
},
{
{
key
:
'select'
,
key
:
'select'
,
label
:
renderLabel
(
genSQL
.
sqlSelect
||
''
,
'Select'
),
label
:
renderLabel
(
genSQL
?.
sqlSelect
??
''
,
'Select'
),
disabled
:
tagDisabled
,
disabled
:
tagDisabled
,
children
:
renderContent
(
genSQL
.
sqlSelect
)
children
:
renderContent
(
genSQL
?.
sqlSelect
??
''
)
},
},
{
{
key
:
'sqlddl'
,
key
:
'sqlddl'
,
label
:
renderLabel
(
genSQL
.
sqlCreate
||
''
,
'SQL DDL'
),
label
:
renderLabel
(
genSQL
?.
sqlCreate
??
''
,
'SQL DDL'
),
disabled
:
tagDisabled
,
disabled
:
tagDisabled
,
children
:
renderContent
(
genSQL
.
sqlCreate
)
children
:
renderContent
(
genSQL
?.
sqlCreate
??
''
)
}
}
];
];
...
@@ -124,7 +128,7 @@ const GenSQL: React.FC<GenSQLProps> = (props) => {
...
@@ -124,7 +128,7 @@ const GenSQL: React.FC<GenSQLProps> = (props) => {
*/
*/
return
(
return
(
<>
<>
{
genSQL
.
flinkSqlCreate
||
genSQL
.
sqlSelect
||
genSQL
.
sqlCreate
?
(
{
genSQL
?.
flinkSqlCreate
||
genSQL
?.
sqlSelect
||
genSQL
?
.
sqlCreate
?
(
<
ProCard
tabs=
{
{
...
restTabProps
}
}
/>
<
ProCard
tabs=
{
{
...
restTabProps
}
}
/>
)
:
(
)
:
(
<
Empty
className=
{
'code-content-empty'
}
description=
{
l
(
'rc.ds.detail.tips'
)
}
/>
<
Empty
className=
{
'code-content-empty'
}
description=
{
l
(
'rc.ds.detail.tips'
)
}
/>
...
...
dinky-web/src/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLQuery/index.tsx
View file @
92255194
...
@@ -43,7 +43,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
...
@@ -43,7 +43,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
const
[
tableData
,
setTableData
]
=
useState
({
columns
:
[{}],
rowData
:
[{}]
});
const
[
tableData
,
setTableData
]
=
useState
({
columns
:
[{}],
rowData
:
[{}]
});
const
[
autoCompleteColumns
,
setAutoCompleteColumns
]
=
useState
<
DefaultOptionType
[]
>
([]);
const
[
autoCompleteColumns
,
setAutoCompleteColumns
]
=
useState
<
DefaultOptionType
[]
>
([]);
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
);
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
);
const
[
errMsg
,
setErr
Msg
]
=
useState
<
{
isErr
:
boolean
;
msg
:
string
}
>
({
const
[
responseMsg
,
setResponse
Msg
]
=
useState
<
{
isErr
:
boolean
;
msg
:
string
}
>
({
isErr
:
false
,
isErr
:
false
,
msg
:
''
msg
:
''
});
});
...
@@ -69,11 +69,15 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
...
@@ -69,11 +69,15 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
const
{
const
{
code
,
code
,
data
:
{
columns
,
rowData
}
data
:
{
columns
,
rowData
}
}
=
result
;
// 获取到的数据
}
=
result
??
{
if
(
code
===
1
)
{
code
:
-
1
,
setErrMsg
({
isErr
:
true
,
msg
:
result
.
data
.
error
});
data
:
{
columns
:
[],
rowData
:
[]
}
};
// 获取到的数据
if
(
code
&&
code
===
1
)
{
setResponseMsg
({
isErr
:
true
,
msg
:
result
.
data
.
error
});
}
else
{
}
else
{
set
Err
Msg
({
isErr
:
false
,
msg
:
''
});
set
Response
Msg
({
isErr
:
false
,
msg
:
''
});
}
}
// render columns list
// render columns list
const
tableColumns
=
columns
?.
map
((
item
:
string
|
number
)
=>
({
const
tableColumns
=
columns
?.
map
((
item
:
string
|
number
)
=>
({
...
@@ -94,7 +98,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
...
@@ -94,7 +98,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
*/
*/
const
clearState
=
()
=>
{
const
clearState
=
()
=>
{
setTableData
({
columns
:
[],
rowData
:
[]
});
setTableData
({
columns
:
[],
rowData
:
[]
});
set
Err
Msg
({
isErr
:
false
,
msg
:
''
});
set
Response
Msg
({
isErr
:
false
,
msg
:
''
});
setLoading
(
false
);
setLoading
(
false
);
form
.
resetFields
();
form
.
resetFields
();
};
};
...
@@ -114,8 +118,8 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
...
@@ -114,8 +118,8 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
const
renderAlert
=
()
=>
{
const
renderAlert
=
()
=>
{
return
(
return
(
<>
<>
{
err
Msg
.
isErr
?
(
{
response
Msg
.
isErr
?
(
<
Alert
message=
'Error'
description=
{
err
Msg
.
msg
}
type=
'error'
showIcon
/>
<
Alert
message=
'Error'
description=
{
response
Msg
.
msg
}
type=
'error'
showIcon
/>
)
:
(
)
:
(
<></>
<></>
)
}
)
}
...
...
dinky-web/src/types/RegCenter/data.d.ts
View file @
92255194
...
@@ -267,9 +267,9 @@ declare namespace DataSources {
...
@@ -267,9 +267,9 @@ declare namespace DataSources {
* table columns info
* table columns info
*/
*/
export
type
SqlGeneration
=
{
export
type
SqlGeneration
=
{
flinkSqlCreate
:
string
;
flinkSqlCreate
:
string
|
''
;
sqlSelect
:
string
;
sqlSelect
:
string
|
''
;
sqlCreate
:
string
;
sqlCreate
:
string
|
''
;
};
};
}
}
...
...
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