Open oaHeZgnoS opened 8 hours ago
@oaHeZgnoS postgres 比较特殊,它的 full table qualifier 为 db_name.schema_name.table_name
,为了能够访问到,可以采用如下做法:
schema_name.table_name
的形式duplicate with https://github.com/secretflow/scql/issues/301
一句惊醒梦中人。engine里会配数据源的地址,核对了下,只有mysql,没有postgresql:
{ "datasources": [ { "id": "ds001", "name": "u1000", "kind": "MYSQL", "connection_str": "db=secure_net_temporary_db;user=root;password=fatE168dev;host=192.168.1.242;auto-reconnect=true" } ], "rules": [ { "db": "*", "table": "*", "datasource_id": "ds001" } ] }
如果postgresql连接是192.168.2.195:5432,用户名postgres,密码123456,那么,所以是不是要改成:
{ "datasources": [ { "id": "ds001", "name": "mysql db", "kind": "MYSQL", "connection_str": "db=secure_net_temporary_db;user=root;password=fatE168dev;host=192.168.1.242;auto-reconnect=true" },{ "id": "ds002", "name": "postgres db", "kind": "POSTGRESQL", "connection_str": "db=postgres;user=postgres;password=123456;host=192.168.2.195;auto-reconnect=true" } ], "rules": [ { "db": "*", "table": "*", "datasource_id": "ds001" },{ "db": "*", "table": "*", "datasource_id": "ds002" } ] }
官网配置文档里有说明,请阅读对应的文档哈。上面关联的 issue 里也有
--embed_router_conf={"datasources":[{"id":"ds001","name":"u1000","kind":"MYSQL","connection_str":"db=secure_net_temporary_db;user=root;password=fatE168dev;host=192.168.1.241;auto-reconnect=true"},{"id":"ds002","name":"u1000_2","kind":"POSTGRESQL","connection_str":"db=postgres;user=postgres;password=123456;host=192.168.2.195;auto-reconnect=true"}],"rules":[{"db":"","table":"","datasource_id":"ds001"},{"db":"","table":"","datasource_id":"ds002"}]}
这样改配置以后,重启engine报错: 2024-10-14 09:29:22.949 [info] [main.cc:main:346] [scqlengine] Adding MuxReceiverService into brpc server 2024-10-14 09:29:22.951 [info] [main.cc:BuildRouter:177] [scqlengine] Building EmbedRouter from json conf 2024-10-14 09:29:22.989 [error] [main.cc:main:364] [scqlengine] Fail to build engine service, msg=[engine/datasource/embed_router.cc:125] Fail to set default route rule: exists already. 2024-10-14 09:29:23.400 [info] [main.cc:main:346] [scqlengine] Adding MuxReceiverService into brpc server 2024-10-14 09:29:23.403 [info] [main.cc:BuildRouter:177] [scqlengine] Building EmbedRouter from json conf 2024-10-14 09:29:23.440 [error] [main.cc:main:364] [scqlengine] Fail to build engine service, msg=[engine/datasource/embed_router.cc:125] Fail to set default route rule: exists already. 2024-10-14 09:29:23.972 [info] [main.cc:main:346] [scqlengine] Adding MuxReceiverService into brpc server 2024-10-14 09:29:23.975 [info] [main.cc:BuildRouter:177] [scqlengine] Building EmbedRouter from json conf 2024-10-14 09:29:24.015 [error] [main.cc:main:364] [scqlengine] Fail to build engine service, msg=[engine/datasource/embed_router.cc:125] Fail to set default route rule: exists already. 2024-10-14 09:29:24.732 [info] [main.cc:main:346] [scqlengine] Adding MuxReceiverService into brpc server 2024-10-14 09:29:24.733 [info] [main.cc:BuildRouter:177] [scqlengine] Building EmbedRouter from json conf 2024-10-14 09:29:24.771 [error] [main.cc:main:364] [scqlengine] Fail to build engine service, msg=[engine/datasource/embed_router.cc:125] Fail to set default route rule: exists already. 2024-10-14 09:29:25.891 [info] [main.cc:main:346] [scqlengine] Adding MuxReceiverService into brpc server 2024-10-14 09:29:25.894 [info] [main.cc:BuildRouter:177] [scqlengine] Building EmbedRouter from json conf 2024-10-14 09:29:25.933 [error] [main.cc:main:364] [scqlengine] Fail to build engine service, msg=[engine/datasource/embed_router.cc:125] Fail to set default route rule: exists already. 2024-10-14 09:29:27.851 [info] [main.cc:main:346] [scqlengine] Adding MuxReceiverService into brpc server 2024-10-14 09:29:27.853 [info] [main.cc:BuildRouter:177] [scqlengine] Building EmbedRouter from json conf 2024-10-14 09:29:27.890 [error] [main.cc:main:364] [scqlengine] Fail to build engine service, msg=[engine/datasource/embed_router.cc:125] Fail to set default route rule: exists already. 2024-10-14 09:29:31.423 [info] [main.cc:main:346] [scqlengine] Adding MuxReceiverService into brpc server 2024-10-14 09:29:31.426 [info] [main.cc:BuildRouter:177] [scqlengine] Building EmbedRouter from json conf 2024-10-14 09:29:31.468 [error] [main.cc:main:364] [scqlengine] Fail to build engine service, msg=[engine/datasource/embed_router.cc:125] Fail to set default route rule: exists already.
请问可能还是哪里不太对呢,是否可能因为只能有一份rule?
试过了 只配置postgresql的是可以成功查询(空格分隔)。设置mysql和postgresql就失败: --embed_router_conf={"datasources":[{"id":"ds001","name":"u1000","kind":"MYSQL","connection_str":"db=secure_net_temporary_db;user=root;password=fatE168dev;host=192.168.1.242;auto-reconnect=true"},{"id":"ds002","name":"u1000_2","kind":"POSTGRESQL","connection_str":"dbname=postgres user=postgres password=123456 host=192.168.2.195 port=5432"}],"rules":[{"db":"","table":"","datasource_id":"ds001"},{"db":"","table":"","datasource_id":"ds002"}]}
推测是不支持双数据源?
Issue Type
Running
Have you searched for existing issues?
No
OS Platform and Distribution
Linux fatenode2 6.8.7-1.el7.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 17 15:04:09 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux
SCQL Version
0.5.0b2
What happend and What you expected to happen.
Configuration used to run SCQL.
SCQL log output.