diff --git a/src/modules/connection-test/connection-test.service.ts b/src/modules/connection-test/connection-test.service.ts index fe4930d..76af8a5 100644 --- a/src/modules/connection-test/connection-test.service.ts +++ b/src/modules/connection-test/connection-test.service.ts @@ -187,6 +187,20 @@ export class ConnectionTestService { body: GetTableMetadataReq, user: RequestUser, ): Promise { + // Columns eligible as the incremental reference field are the ones whose + // data type is allowed for this engine (e.g. int/date/timestamp). The + // allowlist is owned by the platform API, keyed by engine === plugin. + const allowedByEngine = await this.platformApiService + .proxy('GET', '/jobs/jdbc/configs/allowed_datatypes', user) + .catch(() => null); + const allowedDataTypes: string[] = + allowedByEngine?.allowed_datatypes?.find( + (datatypes) => datatypes.engine === body.plugin, + )?.allowed_datatypes ?? []; + const allowedSet = new Set( + allowedDataTypes.map((type) => type.toLowerCase()), + ); + const tables_metadata = await Promise.all( body.table_list.map(async (table_name) => { const result = await this.connectionsApiService.proxy( @@ -196,14 +210,18 @@ export class ConnectionTestService { `/tables/${encodeURIComponent(table_name)}/columns`, user, ); + const columns = result.columns.map((column) => ({ + name: column.column_name, + type: column.data_type, + is_primary_key: column.is_primary_key, + })); + const references = columns.filter((column) => + allowedSet.has(String(column.type).toLowerCase()), + ); return { table_name, - columns: result.columns.map((column) => ({ - name: column.column_name, - type: column.data_type, - is_primary_key: column.is_primary_key, - })), - references: [], + columns, + references, }; }), );