Enabling vector support for the AI Context Hub

When you open a remote system of type SAP in the Remote Systems Cockpit app, you may see the following warning notification:

AI Context Hub not ready.

Your database supports vectors, but the AI Context Hub columns were created differently before vector support was available. They have to be re-created before the AI Context Hub can be used. Please search the documentation for 'Enabling Vector Support'.

This page describes how to re-create those columns so that the AI Context Hub can be used for the system.

Why this happens

You see this notification when vector support was added to the database after those migrations had already run - for example, when the pgvector extension was installed in PostgreSQL later on. The server now reports that the database supports vectors, but the four columns are still text, so the AI Context Hub cannot be used.

Nothing in the platform converts these columns automatically, and the migrations are already recorded as applied. Restarting the server or re-running the migrations therefore does not fix it. The columns have to be re-created manually, with the script below.

Applies to

  • PostgreSQL, with the pgvector extension installed.

  • Microsoft SQL Server, in a version that supports the native VECTOR type.

SQLite has no vector support at all. On SQLite, the AI Context Hub is unavailable, and you see a different, informational notification (No vector support.) instead. Do not run the script on SQLite.

Affected columns

The following embedding columns are affected. The vector dimension is fixed at 1536.

Table Column

sap_service

vector

sap_operation

vector

sap_plan_intent

intentVector

sap_plan_query

queryVector

Procedure

  1. Open the Script Editor and create a server script. See Create a script.

  2. Copy the listing for your database into the script. Run only the listing that matches the database you use.

    PostgreSQL
    const DIM = 1536;
    const schema = entityManager.connection.options.schema;
    
    const columns = [
        ["sap_service", "vector"],
        ["sap_operation", "vector"],
        ["sap_plan_intent", "intentVector"],
        ["sap_plan_query", "queryVector"],
    ];
    
    for (const [table, column] of columns) {
        const rows = await entityManager.query(
            `SELECT udt_name FROM information_schema.columns
             WHERE table_schema = $1 AND table_name = $2 AND column_name = $3`,
            [schema, table, column]
        );
    
        if (!rows.length) {
            console.log(`SKIP ${table}.${column} - column not found`);
            continue;
        }
        if (rows[0].udt_name === "vector") {
            console.log(`OK   ${table}.${column} - already vector`);
            continue;
        }
    
        await entityManager.query(
            `ALTER TABLE "${schema}"."${table}" DROP COLUMN "${column}"`
        );
        await entityManager.query(
            `ALTER TABLE "${schema}"."${table}" ADD COLUMN "${column}" vector(${DIM})`
        );
        console.log(`FIX  ${table}.${column} - was ${rows[0].udt_name}, now vector(${DIM})`);
    }
    Microsoft SQL Server
    const DIM = 1536;
    const schema = entityManager.connection.options.schema;
    
    const columns = [
        ["sap_service", "vector"],
        ["sap_operation", "vector"],
        ["sap_plan_intent", "intentVector"],
        ["sap_plan_query", "queryVector"],
    ];
    
    for (const [table, column] of columns) {
        const rows = await entityManager.query(
            `SELECT TYPE_NAME(c.user_type_id) AS typeName
             FROM sys.columns c
             WHERE c.object_id = OBJECT_ID(@0) AND c.name = @1`,
            [`${schema}.${table}`, column]
        );
    
        if (!rows.length) {
            console.log(`SKIP ${table}.${column} - column not found`);
            continue;
        }
        if (rows[0].typeName === "vector") {
            console.log(`OK   ${table}.${column} - already vector`);
            continue;
        }
    
        await entityManager.query(`ALTER TABLE [${schema}].[${table}] DROP COLUMN [${column}]`);
        await entityManager.query(
            `ALTER TABLE [${schema}].[${table}] ADD [${column}] VECTOR(${DIM})`
        );
        console.log(`FIX  ${table}.${column} - was ${rows[0].typeName}, now VECTOR(${DIM})`);
    }
  3. Run the script. See Run a script.

    Result: The script logs one line per column in the script output pane.

Read the script output

The script checks each column before it changes anything, and logs what it did:

OK

The column is already a vector column. Nothing was changed.

FIX

The column was text and has been re-created as a vector column.

SKIP

The column does not exist. The SAP Engine migrations have not run, so this page does not apply.

The script is safe to re-run. Because it checks each column first, a second run logs OK for every column and changes nothing.

Results

  • The four embedding columns are vector columns.

  • No server restart is required. The warning notification disappears the next time you open the Remote Systems detail page.

Next steps