feat: 支持 aws redshift
This commit is contained in:
parent
dd8044bdea
commit
cb5631e792
@ -467,7 +467,10 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
return "SELECT name FROM system.tables where database='DATABASE';".replace("DATABASE", chConfiguration.getDataBase());
|
||||
case redshift:
|
||||
RedshiftConfigration redshiftConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), RedshiftConfigration.class);
|
||||
return redshiftConfigration.getDataBase();
|
||||
if(StringUtils.isEmpty(redshiftConfigration.getSchema())){
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "SELECT tablename FROM pg_tables WHERE schemaname='SCHEMA' ;".replace("SCHEMA", redshiftConfigration.getSchema());
|
||||
default:
|
||||
return "show tables;";
|
||||
}
|
||||
@ -507,7 +510,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
if(StringUtils.isEmpty(redshiftConfigration.getSchema())){
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg%' AND tablename NOT LIKE 'sql_%' AND schemaname='SCHEMA' ;".replace("SCHEMA", redshiftConfigration.getSchema());
|
||||
return "SELECT viewname FROM pg_views WHERE schemaname='SCHEMA' ;".replace("SCHEMA", redshiftConfigration.getSchema());
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -83,6 +83,6 @@ public abstract class QueryProvider {
|
||||
}
|
||||
|
||||
public String convertTableToSql(String tableName, Datasource ds){
|
||||
return "select * from tableName";
|
||||
return "select * from TABLE_NAME".replace("TABLE_NAME", tableName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
return null;
|
||||
return createQuerySQL(table, fields, isGroup, ds) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -661,6 +661,13 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
return createRawQuerySQL(" (" + sqlFix(sql) + ") AS tmp ", fields, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds){
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
schema = String.format( RedshiftConstants.KEYWORD_TABLE, schema);
|
||||
return createSQLPreview("SELECT * FROM " + schema + "." + String.format(RedshiftConstants.KEYWORD_TABLE, tableName), null);
|
||||
}
|
||||
|
||||
public String transMysqlFilterTerm(String term) {
|
||||
switch (term) {
|
||||
case "eq":
|
||||
@ -831,19 +838,19 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
|
||||
switch (dateStyle) {
|
||||
case "y":
|
||||
return "'YYYY'";
|
||||
return "'YYYY";
|
||||
case "y_M":
|
||||
return "'YYYY" + split + "MM'";
|
||||
return "YYYY" + split + "MM";
|
||||
case "y_M_d":
|
||||
return "'YYYY" + split + "MM" + split + "DD'";
|
||||
return "YYYY" + split + "MM" + split + "DD";
|
||||
case "H_m_s":
|
||||
return "'HH24:MI:SS'";
|
||||
return "HH24:MI:SS'";
|
||||
case "y_M_d_H_m":
|
||||
return "'YYYY" + split + "MM" + split + "DD" + " HH24:MI'";
|
||||
return "YYYY" + split + "MM" + split + "DD" + " HH24:MI";
|
||||
case "y_M_d_H_m_s":
|
||||
return "'YYYY" + split + "MM" + split + "DD" + " HH24:MI:SS'";
|
||||
return "YYYY" + split + "MM" + split + "DD" + " HH24:MI:SS";
|
||||
default:
|
||||
return "'YYYY-MM-DD HH24:MI:SS'";
|
||||
return "YYYY-MM-DD HH24:MI:SS";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1105,13 +1105,11 @@ public class ExtractDataService {
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HttpGet getMethod = new HttpGet("http://" + carte + ":" + port);
|
||||
HttpClientManager.HttpClientBuilderFacade clientBuilder = HttpClientManager.getInstance().createBuilder();
|
||||
clientBuilder.setConnectionTimeout(1);
|
||||
clientBuilder.setCredentials(user, passwd);
|
||||
CloseableHttpClient httpClient = clientBuilder.build();
|
||||
try {
|
||||
try (CloseableHttpClient httpClient = clientBuilder.build()){
|
||||
HttpResponse httpResponse = httpClient.execute(getMethod);
|
||||
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
||||
if (statusCode != -1 && statusCode < 400) {
|
||||
|
||||
@ -150,7 +150,6 @@ export default {
|
||||
'configuration.acquireIncrement': [{ required: true, message: this.$t('datasource.please_input_acquire_increment'), trigger: 'change' }],
|
||||
'configuration.connectTimeout': [{ required: true, message: this.$t('datasource.please_input_connect_timeout'), trigger: 'change' }]
|
||||
},
|
||||
<<<<<<< HEAD
|
||||
allTypes: [
|
||||
{ name: 'mysql', label: 'MySQL', type: 'jdbc', extraParams: 'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'},
|
||||
{ name: 'oracle', label: 'Oracle', type: 'jdbc'},
|
||||
@ -160,15 +159,9 @@ export default {
|
||||
{ name: 'mariadb', label: 'MariaDB', type: 'jdbc', extraParams: 'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true' },
|
||||
{ name: 'ds_doris', label: 'Doris', type: 'jdbc', extraParams: 'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true' },
|
||||
{ name: 'ck', label: 'ClickHouse', type: 'jdbc', extraParams: '' },
|
||||
{ name: 'redshift', label: 'AWS Redshift', type: 'jdbc' },
|
||||
{ name: 'mongo', label: 'MongoDB', type: 'jdbc', extraParams: '' }
|
||||
],
|
||||
=======
|
||||
allTypes: [{ name: 'mysql', label: 'MySQL', type: 'jdbc' },
|
||||
{ name: 'oracle', label: 'Oracle', type: 'jdbc' },
|
||||
{ name: 'sqlServer', label: 'SQL Server', type: 'jdbc' },
|
||||
{ name: 'pg', label: 'PostgreSQL', type: 'jdbc' },
|
||||
{ name: 'redshift', label: 'AWS Redshift', type: 'jdbc' }],
|
||||
>>>>>>> 1fd0fa65ec9293502290e8efe942f4b9a60a8eee
|
||||
schemas: [],
|
||||
canEdit: false,
|
||||
originConfiguration: {}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user