Skip to content

feat(tableau): support extended relation types, semantic-layer attrs, spatial datatype#208

Merged
nicosuave merged 3 commits into
mainfrom
update-tableau-adapter
Jun 15, 2026
Merged

feat(tableau): support extended relation types, semantic-layer attrs, spatial datatype#208
nicosuave merged 3 commits into
mainfrom
update-tableau-adapter

Conversation

@nicosuave

Copy link
Copy Markdown
Member

What changed

Extends the Tableau adapter (sidemantic/adapters/tableau.py) to handle physical-layer relation types and modeling attributes that previously fell through to no-ops, plus the geospatial datatype.

Physical-layer relation types

Beyond the existing table / join / text / collection handling, the adapter now recognizes:

  • union and batch-union — member relations are stacked vertically and compiled to UNION ALL SQL (Tableau unions keep duplicate rows). A single-member union degrades gracefully to a plain table reference.
  • subquery — wrapped as a derived subquery, mirroring the existing text (custom SQL) path.
  • stored-proc — resolved to the stored procedure's actual name (<actual-name> / stored-proc attribute); stored procedures cannot be joined or unioned in Tableau, so they map to a single table reference.
  • pivot, project, text-transform — column-reshaping wrapper relations that keep a single-table grain; resolved to the wrapped child relation's base table or SQL.

These are wired into both the top-level connection relation dispatch and the recursive _parse_relation_tree, so the new types also compose inside join trees.

Tableau Semantics object-graph attributes

The <object-graph> element's semantic-layer and is-legacy attributes (Tableau Semantics layer) are now read and surfaced as model metadata (tableau_semantic_layer, tableau_is_legacy), tolerant of namespace-prefixed forms. This lets consumers distinguish modern semantic models from legacy object models. Relationship extraction is unchanged.

Spatial datatype

The spatial datatype (Tableau's TABLEAU.TABGEOGRAPHY geospatial columns) is mapped to a categorical dimension, since geospatial columns group/filter rather than aggregate numerically.

Tests / fixtures

Added tests/adapters/tableau/test_relation_types.py and eight .tds fixtures under tests/fixtures/tableau/ (one per relation type plus spatial and the semantic-layer object-graph). All existing Tableau tests remain green; backward compatibility is preserved.

Known limitations

  • Union member SQL is SELECT * per member; Tableau's column-alignment/coercion metadata for mismatched unions is not reconstructed.
  • pivot / text-transform reshaping logic is not replayed — the adapter resolves to the wrapped source table and imports the reshaped output columns from <metadata-records>, rather than synthesizing the transform SQL.
  • stored-proc parameters are not modeled.

@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: 5db4aa72c2

ℹ️ 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/tableau.py Outdated
Comment thread sidemantic/adapters/tableau.py
Comment thread sidemantic/adapters/tableau.py Outdated
…-level subqueries

Single-member union/batch-union relations resolved to a bare
'SELECT * FROM <source>' string stored on model.table, which the SQL
generator emits verbatim, producing the invalid 'FROM SELECT * FROM ...'.
Store the resolved union SQL on model.sql instead so it is wrapped as
'(<sql>) AS t'.

Top-level type='subquery' relations stored '(<select>) AS <alias>' on
model.sql, which the generator re-wrapped as '((<select>) AS <alias>) AS t',
an invalid double-aliased derived table. Strip the outer alias before
storing so the generator supplies the single alias.

Add regression tests asserting both paths compile to DuckDB-valid SQL.

@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: 4d20522e79

ℹ️ 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/tableau.py Outdated
…literals when stripping derived aliases

Top-level type="pivot" relations resolved to the raw wide child table,
so generated queries selected the pivot output columns (Pivot Field
Names / Pivot Field Values) from a table where they do not exist. Emit
DuckDB UNPIVOT derived SQL over the declared wide source columns instead,
storing it on model.sql so the model is queryable. Falls back to the
child table only when source columns are not declared.

_strip_derived_alias scanned parentheses without tracking SQL string
literals, so a subquery body like SELECT ')' AS amount terminated the
scan early and left the outer alias attached, producing an invalid
double-aliased derived table. Skip single- and double-quoted spans
(with doubled-quote escapes) during the scan.

@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: feb09d9e47

ℹ️ 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/tableau.py
Comment thread sidemantic/adapters/tableau.py
@nicosuave nicosuave merged commit 13f3440 into main Jun 15, 2026
20 checks passed
@nicosuave nicosuave deleted the update-tableau-adapter branch June 15, 2026 13:58
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