Skip to content

Add first-class ThoughtSpot TML Model object support#199

Open
nicosuave wants to merge 17 commits into
mainfrom
update-thoughtspot-adapter
Open

Add first-class ThoughtSpot TML Model object support#199
nicosuave wants to merge 17 commits into
mainfrom
update-thoughtspot-adapter

Conversation

@nicosuave

Copy link
Copy Markdown
Member

What changed

ThoughtSpot deprecated the Worksheet object (disabled by default in 10.4.0.cl, auto-migrated to Models and removed in 10.12.0.cl). The adapter routed the top-level model: key into the worksheet parser, which only understands worksheet-shaped keys. As a result, current TML Model files (export_schema_version v2) imported as empty or incorrect models.

This adds a dedicated _parse_model path for the TML Model object while keeping the legacy worksheet path intact.

Upstream features now supported

  • model_tables: for table definitions (vs worksheet tables:), including name/id/fqn/alias.
  • Model-level columns: for fields (vs worksheet_columns:), resolving column_id: <table>::<column> to table.column, including formula-backed columns via formula_id/formulas:.
  • Joins nested inside each model_tables entry under joins:, using with:/on:/type:/cardinality:. The bare on: key (parsed by PyYAML as boolean True) is handled.
  • Join cardinality mapping: MANY_TO_ONE/ONE_TO_ONE/ONE_TO_MANY/MANY_TO_MANY to sidemantic relationship types, instead of the worksheet is_one_to_one flag.
  • Alias resolution for role-playing dimensions: a model_tables entry alias used in column_id paths and join with refs resolves back to the underlying table.
  • Loader auto-detection: a model + model_tables + columns .tml/.yaml/.yml file is now recognized as ThoughtSpot.

Backward compatibility

Legacy Worksheet/Table TML is unchanged. Worksheet content nested under model: (without model_tables/columns) still routes to _parse_worksheet. Existing fixtures and tests stay green.

Known limitations

  • SQL view / formula columns that reference other formulas are flattened the same way worksheet formulas are; deeply chained formula graphs follow existing worksheet behavior.
  • Export still emits Worksheet/Table TML; Model export is not added in this change.

ThoughtSpot deprecated the Worksheet object (auto-migrated to Models and
removed in 10.12.0.cl). The adapter routed the top-level model: key into
the worksheet parser, which only reads worksheet keys, so current TML
Model files (export_schema_version v2) imported as empty/incorrect models.

- Add _parse_model for the TML Model object: reads model_tables: for
  tables, model-level columns: for fields, and joins nested inside each
  model_tables entry via with:/on:/type:/cardinality:.
- Map join cardinality (MANY_TO_ONE/ONE_TO_ONE/ONE_TO_MANY/MANY_TO_MANY)
  to sidemantic relationship types; resolve model_tables aliases used by
  role-playing dimensions.
- Keep _parse_worksheet for legacy worksheet content nested under model:.
- Extend loader auto-detection so a model + model_tables + columns
  .tml/.yaml/.yml file is recognized as ThoughtSpot.
- Add sales.model.tml and model_alias.model.tml fixtures plus parsing,
  alias-resolution, loader auto-detect, and legacy-fallback tests.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ad8bbcb83

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py
Comment thread sidemantic/adapters/thoughtspot.py Outdated
Model column_id paths reference a table by its name even when the table
also has an id (e.g. column_id: orders::amount for a table with
id: orders_tbl). _table_name_lookup only mapped id -> name, so those
refs missed the lookup and the qualifier was dropped, emitting bare
columns like amount/id that are ambiguous in joined model SQL.

Map name -> name in addition to id -> name (id mappings take
precedence) so column_id qualifiers resolve to table.column.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ede3e1858b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py
…ing aliases

Joined Model TMLs are exported as derived SQL (FROM (<sql>) AS t) but their
dimension/metric SQL kept inner table qualifiers like sales.gross_revenue,
which are out of scope in the wrapping subquery and made joined models
unqueryable. Rewrite the inner SELECT * into an explicit projection that
aliases each table.column to a stable unqualified output name, expose the
primary key, and rewrite column SQL to those aliases.

Also preserve with: aliases as role identifiers instead of resolving them to
the backing table, so role-playing joins (ship_country/bill_country both
backed by countries) stay distinct via JOIN countries AS <alias> rather than
collapsing into a single ambiguous countries relation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 924af09420

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py
Comment thread sidemantic/adapters/thoughtspot.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f9777cd1f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py Outdated
Comment thread sidemantic/adapters/thoughtspot.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14a9a58219

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py Outdated
Comment thread sidemantic/adapters/thoughtspot.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1679a77ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py
Comment thread sidemantic/adapters/thoughtspot.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ae95a8f56f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py
Comment thread sidemantic/adapters/thoughtspot.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8829f2f224

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py Outdated
Comment thread sidemantic/adapters/thoughtspot.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c270e69c11

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py
Comment thread sidemantic/adapters/thoughtspot.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f33276de3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py Outdated
Comment thread sidemantic/adapters/thoughtspot.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a590f767b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4aaadecf4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 608e374788

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4e34cd41b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py Outdated
Comment thread sidemantic/adapters/thoughtspot.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 280e05bf8c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py
Comment thread sidemantic/adapters/thoughtspot.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a23d0d55f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/adapters/thoughtspot.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant