Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/en/docs/lakehouse/multi-catalog/jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Once connected, Doris will ingest metadata of databases and tables from the exte
"driver_class" = "org.postgresql.Driver"
);
```
> Doris obtains all schemas that PG user can access through the SQL statement: `select nspname from pg_namespace where has_schema_privilege('<UserName>', nspname, 'USAGE');` and map these schemas to doris database.

As for data mapping from PostgreSQL to Doris, one Database in Doris corresponds to one schema in the specified database in PostgreSQL (for example, "demo" in `jdbc_url` above), and one Table in that Database corresponds to one table in that schema. To make it more intuitive, the mapping relations are as follows:

Expand Down
2 changes: 2 additions & 0 deletions docs/zh-CN/docs/lakehouse/multi-catalog/jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ CREATE CATALOG jdbc_postgresql PROPERTIES (
| Database | Schema |
| Table | Table |

> Doris通过sql语句`select nspname from pg_namespace where has_schema_privilege('<UserName>', nspname, 'USAGE');` 来获得PG user能够访问的所有schema并将其映射为Doris的database

3. Oracle

<version since="1.2.2"></version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.doris.catalog.Type;
import org.apache.doris.common.Config;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.util.Util;

import com.alibaba.druid.pool.DruidDataSource;
import com.google.common.collect.Lists;
Expand Down Expand Up @@ -180,8 +181,8 @@ public List<String> getDatabaseNameList() {
rs = stmt.executeQuery("SHOW DATABASES");
break;
case JdbcResource.POSTGRESQL:
rs = stmt.executeQuery("SELECT schema_name FROM information_schema.schemata "
+ "where schema_owner='" + jdbcUser + "';");
rs = stmt.executeQuery("SELECT nspname FROM pg_namespace WHERE has_schema_privilege("
+ "'" + jdbcUser + "', nspname, 'USAGE');");
break;
case JdbcResource.ORACLE:
rs = stmt.executeQuery("SELECT DISTINCT OWNER FROM all_tables");
Expand Down Expand Up @@ -376,7 +377,8 @@ public List<JdbcFieldSchema> getJdbcColumnsInfo(String dbName, String tableName)
tableSchema.add(field);
}
} catch (SQLException e) {
throw new JdbcClientException("failed to get table name list from jdbc for table %s", e, tableName);
throw new JdbcClientException("failed to get table name list from jdbc for table %s:%s", e, tableName,
Util.getRootCauseMessage(e));
} finally {
close(rs, conn);
}
Expand Down