Skip to content

Commit 27c4f51

Browse files
committed
[ClickHouse] Support PostgreSQL database engine
1 parent fc08f3d commit 27c4f51

5 files changed

Lines changed: 47 additions & 2 deletions

File tree

src/renderer/assets/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@
226226
"lazy": "Keeps tables in RAM only expiration_time_in_seconds seconds after last access. Can be used only with *Log tables.",
227227
"mysql": "Allows to connect to databases on a remote MySQL server and perform INSERT and SELECT queries to exchange data between ClickHouse and MySQL.",
228228
"materialized_mysql": "Creates ClickHouse database with all the tables existing in MySQL, and all the data in those tables. ClickHouse server works as MySQL replica. It reads binlog and performs DDL and DML queries.",
229-
"materialized_postgresql": "Creates a ClickHouse database with tables from PostgreSQL database. Firstly, database with engine MaterializedPostgreSQL creates a snapshot of PostgreSQL database and loads required tables. Required tables can include any subset of tables from any subset of schemas from specified database. Along with the snapshot database engine acquires LSN and once initial dump of tables is performed - it starts pulling updates from WAL. After database is created, newly added tables to PostgreSQL database are not automatically added to replication. They have to be added manually with ATTACH TABLE db.table query."
229+
"materialized_postgresql": "Creates a ClickHouse database with tables from PostgreSQL database. Firstly, database with engine MaterializedPostgreSQL creates a snapshot of PostgreSQL database and loads required tables. Required tables can include any subset of tables from any subset of schemas from specified database. Along with the snapshot database engine acquires LSN and once initial dump of tables is performed - it starts pulling updates from WAL. After database is created, newly added tables to PostgreSQL database are not automatically added to replication. They have to be added manually with ATTACH TABLE db.table query.",
230+
"postgresql": "Allows to connect to databases on a remote PostgreSQL server. Supports read and write operations (SELECT and INSERT queries) to exchange data between ClickHouse and PostgreSQL."
230231
},
231232
"table": {
232233
"log": "Lightweight engines with minimum functionality. They’re the most effective when you need to quickly write many small tables (up to approximately 1 million rows) and read them later as a whole.",

src/renderer/assets/i18n/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@
227227
"lazy": "Keeps tables in RAM only expiration_time_in_seconds seconds after last access. Can be used only with *Log tables.",
228228
"mysql": "Allows to connect to databases on a remote MySQL server and perform INSERT and SELECT queries to exchange data between ClickHouse and MySQL.",
229229
"materialized_mysql": "Creates ClickHouse database with all the tables existing in MySQL, and all the data in those tables. ClickHouse server works as MySQL replica. It reads binlog and performs DDL and DML queries.",
230-
"materialized_postgresql": "Creates a ClickHouse database with tables from PostgreSQL database. Firstly, database with engine MaterializedPostgreSQL creates a snapshot of PostgreSQL database and loads required tables. Required tables can include any subset of tables from any subset of schemas from specified database. Along with the snapshot database engine acquires LSN and once initial dump of tables is performed - it starts pulling updates from WAL. After database is created, newly added tables to PostgreSQL database are not automatically added to replication. They have to be added manually with ATTACH TABLE db.table query."
230+
"materialized_postgresql": "Creates a ClickHouse database with tables from PostgreSQL database. Firstly, database with engine MaterializedPostgreSQL creates a snapshot of PostgreSQL database and loads required tables. Required tables can include any subset of tables from any subset of schemas from specified database. Along with the snapshot database engine acquires LSN and once initial dump of tables is performed - it starts pulling updates from WAL. After database is created, newly added tables to PostgreSQL database are not automatically added to replication. They have to be added manually with ATTACH TABLE db.table query.",
231+
"postgresql": "Allows to connect to databases on a remote PostgreSQL server. Supports read and write operations (SELECT and INSERT queries) to exchange data between ClickHouse and PostgreSQL."
231232
},
232233
"table": {
233234
"log": "轻量级引擎。当您需要快速地构建多个小表(最多100万行),然后将它们作为一个整体读取时,它们是最有效的。",

src/renderer/config/database.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { StringUtils } from '@renderer/utils/string.utils';
55
import { TranslateUtils } from '@renderer/utils/translate.utils';
66
import { PropertyModel } from '@renderer/model/property.model';
77
import { DefaultEngine } from "@renderer/config/engine/database/mysql/engine.database.mysql.default.config";
8+
import { PostgreSQLDatabaseEngine } from "@renderer/config/engine/database/engine.database.postgresql";
89

910
@Injectable()
1011
export class DatabaseConfig {
@@ -36,6 +37,7 @@ export class DatabaseConfig {
3637
TranslateUtils.getValue('tooltip.database.lazy'),
3738
DatabaseEnum.lazy,
3839
null));
40+
3941
// mysql
4042
const properties = new Array();
4143
properties.push(PropertyModel.builder('host',
@@ -62,6 +64,10 @@ export class DatabaseConfig {
6264
TranslateUtils.getValue('tooltip.database.mysql'),
6365
DatabaseEnum.mysql,
6466
properties));
67+
68+
// PostgreSQL
69+
defaultEngines.push(PostgreSQLDatabaseEngine);
70+
6571
basicDatabase.engines = defaultEngines;
6672
databaseEngines.push(basicDatabase);
6773
/**
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { DatabaseModel } from "@renderer/model/database.model";
2+
import { TranslateUtils } from "@renderer/utils/translate.utils";
3+
import { DatabaseEnum } from "@renderer/enum/database.enum";
4+
import { PropertyModel } from "@renderer/model/property.model";
5+
6+
const properties = new Array();
7+
properties.push(PropertyModel.builder('host',
8+
TranslateUtils.getValue('common.host'),
9+
TranslateUtils.getValue('placeholder.host'),
10+
TranslateUtils.getValue('tooltip.property.host')));
11+
properties.push(PropertyModel.builder('port',
12+
TranslateUtils.getValue('common.port'),
13+
TranslateUtils.getValue('placeholder.port'),
14+
TranslateUtils.getValue('tooltip.property.port')));
15+
properties.push(PropertyModel.builder('database',
16+
TranslateUtils.getValue('common.database'),
17+
TranslateUtils.getValue('placeholder.database'),
18+
TranslateUtils.getValue('tooltip.property.database')));
19+
properties.push(PropertyModel.builder('username',
20+
TranslateUtils.getValue('common.username'),
21+
TranslateUtils.getValue('placeholder.username'),
22+
TranslateUtils.getValue('tooltip.property.username')));
23+
properties.push(PropertyModel.builder('password',
24+
TranslateUtils.getValue('common.password'),
25+
TranslateUtils.getValue('placeholder.password'),
26+
TranslateUtils.getValue('tooltip.property.password')));
27+
28+
const PostgreSQLDatabaseEngine = DatabaseModel.builder(TranslateUtils.getValue('common.postgresql'),
29+
TranslateUtils.getValue('tooltip.database.postgresql'),
30+
DatabaseEnum.postgresql,
31+
properties);
32+
PostgreSQLDatabaseEngine.supportedSource = [DatabaseEnum.clickhosue];
33+
34+
export {
35+
PostgreSQLDatabaseEngine
36+
}

src/renderer/services/management/metadata.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export class MetadataService extends ForwardService implements BaseService {
112112
case DatabaseEnum.mysql:
113113
case DatabaseEnum.materialized_mysql:
114114
case DatabaseEnum.materialized_postgresql:
115+
case DatabaseEnum.postgresql:
115116
suffix = this.builderDatabaseMySQL(database);
116117
break;
117118
}

0 commit comments

Comments
 (0)