Skip to content

SQL primary key detenction and composite key management #1105

@yalexbadan

Description

@yalexbadan

Bug description
Trying the product using the compose defined in docker-compose.yaml, I noticed that primary keys was not detected for PostgreSQL connections.
Investigating on postgres.py I noticed that primary keys are not manged (same for Oracle), while the implementations for MySql and MsSql consider only the last detected column in composite primary key:

def get_table_list(self) -> list[Table]:
  ...      
  for row in response:
    ...   
    # if column is primary key
    if row["column_key"] == "PRI":
      unique_tables[schema_table].primaryKey = row["column_name"]

The if at the end of for loops takes only the last detected column.
I don't know Trino nor Snowflakes to determine if both implementations are affected from the same problem.

How to Reproduce
Run the ibis-server, and try to invoke the /v2/connector/{dbms}/metadata/tables endpoints for all the connectors.

Expected behavior
In my proposal, the primaryKey field of class Table (dto.py) should be a list of strings, with all fields belonging to the key.

Desktop (please complete the following information):
Test were perfomed using only docker images

Wren AI Information

  • Versions:
    • WREN_PRODUCT_VERSION=0.17.0
    • WREN_ENGINE_VERSION=0.14.8
    • WREN_AI_SERVICE_VERSION=0.17.1
    • IBIS_SERVER_VERSION=0.14.8
    • WREN_UI_VERSION=0.22.1
    • WREN_BOOTSTRAP_VERSION=0.1.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions