SEMANTIC VIEW

Config path: /<database>/<schema>/semantic_view/<name>.yaml

Example:

tables:
  - table_alias: tb1
    table_name: sv001_tb1
    primary_key: [author_id, book_id]
    with_synonyms: [aaa, bbb]
    comment: "Link between authors and books"

  - table_alias: tb2
    table_name: sv001_tb2
    primary_key: [author_id]
    with_synonyms: [ccc, ddd]
    comment: "List of authors"

  - table_alias: tb3
    table_name: sv001_tb3
    primary_key: [book_id]
    unique:
      - [book_isbn]
    comment: "List of books"

relationships:
  - table_alias: tb1
    columns: [author_id]
    ref_table_alias: tb2
    ref_columns: [author_id]

  - table_alias: tb1
    columns: [book_id]
    ref_table_alias: tb3
    ref_columns: [book_id]

facts:
  - table_alias: tb1
    name: unique_id
    sql: CONCAT(author_id, '-', book_id)
    with_synonyms: [aaa, bbb]
    comment: "Unique ID for link between authors and books"

  - table_alias: tb3
    name: number_of_pages
    sql: number_of_pages
    comment: "Number of pages in a book"

dimensions:
  - table_alias: tb1
    name: author_book_link_create_dt
    sql: CAST(create_ts AS DATE)
    comment: "Date when link between author and book was established"

  - table_alias: tb2
    name: author_name
    sql: author_name
    comment: "Name of author"

  - table_alias: tb3
    name: book_name
    sql: book_name
    comment: "Name of book"

metrics:
  - table_alias: tb1
    name: count_distinct_author
    sql: count(distinct author_id)
    comment: "Number of unique authors"

  - table_alias: tb1
    name: count_distinct_book
    sql: count(distinct book_id)
    comment: "Number of unique books"

comment: abc

Schema

  • tables (list)

    • {items} (dict)

      • table_alias (ident) - optional alias for logical table

      • table_name (ident)

      • primary_key (list) - columns defining primary key

        • {items} (ident) - column name

      • unique (list) - columns defining unique keys

        • {items} (list)

          • {items} (ident) - column name

      • with_synonyms (list) - synonyms for logical table

        • {items} (str)

      • comment (str)

  • relationships (list)

    • {items} (dict)

      • relationship_identifier (str) - optional alias for relationship

      • table_alias (ident) - first logical table

      • columns (list) - columns of first logical table

        • {items} (ident)

      • ref_table_alias (ident) - second logical table

      • ref_columns (list) - columns of second logical table

        • {items} (ident)

  • facts (list)

    • {items} (dict)

      • table_alias (ident) - name or alias for logical table

      • name (ident) - name of fact

      • sql (str) - SQL expression defining fact

      • with_synonyms (list) - synonyms for fact

        • {items} (str)

      • comment (str)

  • dimensions (list)

    • {items} (dict)

      • table_alias (ident) - name or alias for logical table

      • name (ident) - name of dimension

      • sql (str) - SQL expression defining dimension

      • with_synonyms (list) - synonyms for dimension

        • {items} (str)

      • comment (str)

  • metrics (list)

    • {items} (dict)

      • table_alias (ident) - name or alias for logical table

      • name (ident) - name of metric

      • sql (str) - SQL expression defining metric

      • with_synonyms (list) - synonyms for metric

        • {items} (str)

      • comment (str)

  • comment (str)

Last updated