Skip to content

Commit

Permalink
[Optimization] Optimized jdbc get data exception throw (#3121)
Browse files Browse the repository at this point in the history
Co-authored-by: gaoyan1998 <[email protected]>
  • Loading branch information
gaoyan1998 and gaoyan1998 authored Feb 1, 2024
1 parent 61897f0 commit 5b18556
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.dinky.assertion.Asserts;
import org.dinky.data.constant.CommonConstant;
import org.dinky.data.enums.TableType;
import org.dinky.data.exception.BusException;
import org.dinky.data.model.Column;
import org.dinky.data.model.QueryData;
import org.dinky.data.model.Schema;
Expand Down Expand Up @@ -207,6 +208,7 @@ public List<Schema> listSchemas() {
}
} catch (Exception e) {
log.error("ListSchemas failed", e);
throw new BusException(e.getMessage());
} finally {
close(preparedStatement, results);
}
Expand Down Expand Up @@ -282,7 +284,8 @@ public List<Table> listTables(String schemaName) {
}
}
} catch (SQLException e) {
log.error("ListTables Failed", e);
log.error("ListTables error:", e);
throw new BusException(e.getMessage());
} finally {
close(preparedStatement, results);
}
Expand Down Expand Up @@ -377,6 +380,7 @@ public List<Column> listColumns(String schemaName, String tableName) {
}
} catch (SQLException e) {
log.error("ListColumns error", e);
throw new BusException(e.getMessage());
} finally {
close(preparedStatement, results);
}
Expand Down Expand Up @@ -455,6 +459,7 @@ public String getCreateTableSql(Table table) {
}
} catch (Exception e) {
log.error("GetCreateTableSql Failed", e);
throw new BusException(e.getMessage());
} finally {
close(preparedStatement, results);
}
Expand Down Expand Up @@ -767,6 +772,7 @@ public List<Map<String, String>> getSplitSchemaList() {
}
} catch (SQLException e) {
log.error("GetSplitSchemaList failed", e);
throw new BusException(e.getMessage());
} finally {
close(preparedStatement, results);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ public interface DorisConstant {
/** 查询所有database */
String QUERY_ALL_DATABASE = " show databases ";
/** 查询所有schema下的所有表 */
String QUERY_TABLE_BY_SCHEMA =
" select TABLE_NAME AS `NAME`,TABLE_SCHEMA AS `SCHEMA`,TABLE_COMMENT AS COMMENT, '' as"
+ " TYPE, '' as CATALOG, '' as ENGINE , '' as OPTIONS , 0 as `ROWS`, null as"
+ " CREATE_TIME, null as UPDATE_TIME from information_schema.tables where"
+ " TABLE_SCHEMA = '%s' ";
String QUERY_TABLE_BY_SCHEMA = "select TABLE_NAME AS `NAME`,\n" + " TABLE_SCHEMA AS `SCHEMA`,\n"
+ " TABLE_COMMENT AS COMMENT,\n"
+ " TABLE_TYPE as TYPE,\n"
+ " TABLE_CATALOG as CATALOG,\n"
+ " ENGINE as ENGINE,\n"
+ " CREATE_OPTIONS as OPTIONS,\n"
+ " TABLE_ROWS as `ROWS`,\n"
+ " CREATE_TIME as CREATE_TIME,\n"
+ " UPDATE_TIME as UPDATE_TIME\n"
+ "from information_schema.tables"
+ " where"
+ " TABLE_SCHEMA = '%s' ";
/** 查询指定schema.table下的所有列信息 */
String QUERY_COLUMNS_BY_TABLE_AND_SCHEMA = " show full columns from `%s`.`%s` ";
}
2 changes: 1 addition & 1 deletion dinky-web/src/pages/DevOps/JobList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const JobList = () => {
}, []);

return (
<ProCard boxShadow={true} style={{ height: 'calc(100vh - 250px)' }}>
<ProCard boxShadow={true}>
<ProTable<Jobs.JobInstance>
{...PROTABLE_OPTIONS_PUBLIC}
search={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

import { DataSourceDetailBackButton } from '@/components/StyledComponents';
import { Authorized, HasAuthority, useAccess } from '@/hooks/useAccess';
import { showDataSourceTable } from '@/pages/DataStudio/LeftContainer/DataSource/service';
import {
clearDataSourceTable,
showDataSourceTable
} from '@/pages/DataStudio/LeftContainer/DataSource/service';
import { StateType, STUDIO_MODEL } from '@/pages/DataStudio/model';
import RightTagsRouter from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter';
import { QueryParams } from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data';
Expand Down Expand Up @@ -148,7 +151,7 @@ const DataSourceDetail = (props: connect) => {
icon={<ReloadOutlined spin={loading} />}
type='primary'
hidden={!HasAuthority(PermissionConstants.REGISTRATION_DATA_SOURCE_DETAIL_REFRESH)}
onClick={() => querySchemaTree()}
onClick={() => clearDataSourceTable(selectDatabaseId).then(() => querySchemaTree())}
>
{l('button.refresh')}
</Button>
Expand Down
4 changes: 2 additions & 2 deletions dinky-web/src/services/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ export const PRO_LIST_CARD_OPTIONS = {
*/
export const PROTABLE_OPTIONS_PUBLIC: any = {
pagination: {
defaultPageSize: 12,
defaultPageSize: 10,
hideOnSinglePage: true,
showQuickJumper: false,
showSizeChanger: false,
showSizeChanger: true,
position: ['bottomCenter']
},
ghost: false,
Expand Down

0 comments on commit 5b18556

Please sign in to comment.