Skip to content

Commit 33fb659

Browse files
author
chengluo
committed
feat: add snowflake plugin
1 parent c13d16c commit 33fb659

File tree

22 files changed

+355
-24
lines changed

22 files changed

+355
-24
lines changed

server/api-service/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ IDEA 2021.3.2 (Community Edition):
6262
</tr>
6363
<tr>
6464
<td>VM options </td>
65-
<td>-Dpf4j.mode=development -Dpf4j.pluginsDir=openblocks-plugins -Dspring.profiles.active=openblocks -XX:+AllowRedefinitionToAddDeleteMethods </td>
65+
<td>-Dpf4j.mode=development -Dpf4j.pluginsDir=openblocks-plugins -Dspring.profiles.active=openblocks -XX:+AllowRedefinitionToAddDeleteMethods --add-opens java.base/java.nio=ALL-UNNAMED</td>
6666
</tr>
6767
<tr>
6868
<td>Main class </td>

server/api-service/openblocks-domain/src/main/java/com/openblocks/domain/datasource/service/impl/DatasourceStructureServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private Mono<DatasourceStructure> getLatestStructure(Datasource datasource,
9999
QueryExecutor<? extends DatasourceConnectionConfig, Object, ? extends QueryExecutionContext> queryExecutor) {
100100

101101
return connectionContextService.getOrCreateConnection(datasource)
102-
.flatMap(connectionContext -> queryExecutor.doGetStructure(connectionContext.connection())
102+
.flatMap(connectionContext -> queryExecutor.doGetStructure(connectionContext.connection(), datasource.getDetailConfig())
103103
.timeout(Duration.ofMillis(GET_STRUCTURE_DEFAULT_TIMEOUT_MILLIS))
104104
.doOnError(connectionContext::onQueryError)
105105
.onErrorMap(TimeoutException.class, e -> new BizException(BizError.PLUGIN_EXECUTION_TIMEOUT, "PLUGIN_EXECUTION_TIMEOUT",

server/api-service/openblocks-domain/src/main/java/com/openblocks/domain/plugin/service/impl/DatasourceMetaInfoServiceImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ public class DatasourceMetaInfoServiceImpl implements DatasourceMetaInfoService
117117
.connectionPool(ClientBasedConnectionPool.class)
118118
.build();
119119

120+
121+
private static final DatasourceMetaInfo SNOWFLAKE = DatasourceMetaInfo.builder()
122+
.type("snowflake")
123+
.displayName("Snowflake")
124+
.pluginExecutorKey("snowflake-plugin")
125+
.hasStructureInfo(true)
126+
.connectionPool(ClientBasedConnectionPool.class)
127+
.build();
128+
120129
private static final DatasourceMetaInfo GOOGLE_SHEETS = DatasourceMetaInfo.builder()
121130
.type("googleSheets")
122131
.displayName("Google Sheets")

server/api-service/openblocks-plugins/clickHousePlugin/src/main/java/com/openblocks/plugin/clickhouse/ClickHouseQueryExecutor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public Mono<QueryExecutionResult> executeQuery(HikariDataSource hikariDataSource
108108
}
109109

110110
@Override
111-
public Mono<DatasourceStructure> getStructure(HikariDataSource hikariDataSource) {
111+
public Mono<DatasourceStructure> getStructure(HikariDataSource hikariDataSource,
112+
ClickHouseDatasourceConfig connectionConfig) {
112113

113114
return Mono.fromCallable(() -> {
114115
Connection connection = getConnection(hikariDataSource);

server/api-service/openblocks-plugins/mongoPlugin/src/main/java/com/openblocks/plugin/mongo/MongoPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ public Mono<DatasourceTestResult> testConnection(MongoDatasourceConfig connectio
471471
}
472472

473473
@Override
474-
public Mono<DatasourceStructure> getStructure(MongoConnection mongoClient) {
474+
public Mono<DatasourceStructure> getStructure(MongoConnection mongoClient,
475+
MongoDatasourceConfig connectionConfig) {
475476
final DatasourceStructure structure = new DatasourceStructure();
476477
List<DatasourceStructure.Table> tables = new ArrayList<>();
477478
structure.setTables(tables);

server/api-service/openblocks-plugins/mssqlPlugin/src/main/java/com/openblocks/plugin/mssql/MssqlQueryExecutor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ public Mono<QueryExecutionResult> executeQuery(HikariDataSource hikariDataSource
119119
}
120120

121121
@Override
122-
public Mono<DatasourceStructure> getStructure(HikariDataSource hikariDataSource) {
122+
public Mono<DatasourceStructure> getStructure(HikariDataSource hikariDataSource,
123+
MssqlDatasourceConfig connectionConfig) {
123124
return Mono.fromCallable(() -> {
124125
Connection connection = getConnection(hikariDataSource);
125126

server/api-service/openblocks-plugins/mysqlPlugin/src/main/java/com/openblocks/plugin/mysql/MysqlQueryExecutor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.openblocks.sdk.exception.PluginException;
2323
import com.openblocks.sdk.models.DatasourceStructure;
2424
import com.openblocks.sdk.models.DatasourceStructure.Table;
25+
import com.openblocks.sdk.plugin.common.sql.SqlBasedDatasourceConnectionConfig;
2526
import com.openblocks.sdk.plugin.sqlcommand.GuiSqlCommand;
2627
import com.openblocks.sdk.plugin.sqlcommand.command.mysql.MysqlBulkInsertCommand;
2728
import com.openblocks.sdk.plugin.sqlcommand.command.mysql.MysqlBulkUpdateCommand;
@@ -42,7 +43,8 @@ public MysqlQueryExecutor() {
4243

4344
@Nonnull
4445
@Override
45-
protected DatasourceStructure getDatabaseMetadata(Connection connection) {
46+
protected DatasourceStructure getDatabaseMetadata(Connection connection,
47+
SqlBasedDatasourceConnectionConfig connectionConfig) {
4648
Map<String, Table> tablesByName = new LinkedHashMap<>();
4749
try (Statement statement = connection.createStatement()) {
4850
parseTableAndColumns(tablesByName, statement);

server/api-service/openblocks-plugins/mysqlPlugin/src/main/java/com/openblocks/plugin/mysql/OldMysqlQueryExecutor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ private HikariDataSource getHikariDataSource(HikariPerfWrapper hikariDataSource)
202202

203203
@Nonnull
204204
@Override
205-
public DatasourceStructure blockingGetStructure(HikariPerfWrapper hikariPerfWrapper) {
205+
public DatasourceStructure blockingGetStructure(HikariPerfWrapper hikariPerfWrapper,
206+
MysqlDatasourceConfig connectionConfig) {
206207

207208
Map<String, Table> tablesByName = new LinkedHashMap<>();
208209
try (Connection connection = getConnection(getHikariDataSource(hikariPerfWrapper));

server/api-service/openblocks-plugins/oraclePlugin/src/main/java/com/openblocks/plugin/oracle/OraclePlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ public Mono<Void> destroyConnection(HikariDataSource hikariDataSource) {
119119
}
120120

121121
@Override
122-
public Mono<DatasourceStructure> getStructure(HikariDataSource hikariDataSource) {
122+
public Mono<DatasourceStructure> getStructure(HikariDataSource hikariDataSource,
123+
OracleDatasourceConfig connectionConfig) {
123124
return Mono.fromSupplier(() -> getStructure0(hikariDataSource))
124125
.subscribeOn(querySharedScheduler());
125126
}

server/api-service/openblocks-plugins/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,6 @@
9494
<module>oraclePlugin</module>
9595
<module>graphqlPlugin</module>
9696
<module>sqlBasedPlugin</module>
97+
<module>snowflakePlugin</module>
9798
</modules>
9899
</project>

0 commit comments

Comments
 (0)