PandaAI 3.0 is currently in beta. This documentation reflects the latest features and functionality, which may evolve before the final release.

What are views?

Views are a feature of SQL databases that allow you to define logical subsets of data that can be used in queries. In PandaAI, you can define views in your semantic layer schema to organize and structure your data.

View configuration

The following sections detail all available configurations for view options in your schema.yaml file. Similar to views in SQL, you can define multiple tables and the relationships between them.

Example Configuration

name: table_heart
source:
  type: postgres
  connection:
    host: postgres-host
    port: 5432
    database: postgres
    user: postgres
    password: ******
  table: heart
  view: false
columns:
  - name: parents.id
  - name: parents.name
  - name: parents.age
  - name: children.name
  - name: children.age
relations:
  - name: parent_to_children
    description: Relation linking the parent to its children
    from: parents.id
    to: children.id

Constraints

  1. Mutual Exclusivity:

    • A schema cannot define both table and view simultaneously.
    • If source.view is true, then the schema represents a view.
  2. Column Format:

    • For views:
      • All columns must follow the format [table].[column].
      • from and to fields in relations must follow the [table].[column] format.
      • Example: parents.id, children.name.
  3. Relationships for Views:

    • Each table referenced in columns must have at least one relationship defined in relations.
    • Relationships must specify from and to attributes in the [table].[column] format.