Skip to content

Default LookML view table to the view name when unspecified#244

Open
nicosuave wants to merge 1 commit into
fix/lookml-export-aggregationsfrom
fix/lookml-default-view-table
Open

Default LookML view table to the view name when unspecified#244
nicosuave wants to merge 1 commit into
fix/lookml-export-aggregationsfrom
fix/lookml-default-view-table

Conversation

@nicosuave

Copy link
Copy Markdown
Member

Summary

Part of the LookML adapter correctness series. Stacked on #243 (base = fix/lookml-export-aggregations).

In Looker, a view with no sql_table_name and no derived_table implicitly queries a table named after the view. The adapter left table unset, so importing such a (perfectly valid) view crashed with ModelValidationError: Model must have a table.

Changes

  • Default table to the view name when there is no sql_table_name, no derived_table, no extends, it is not a refinement (+view), and not extension: required.
  • Regression test (parse + compile).

These exclusions preserve correct behavior for abstract/extended/refinement views, which legitimately have no table of their own.

@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: 84410ae8a8

ℹ️ 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".

# via extends or are abstract (extension: required).
if (
table is None
and sql is None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require no derived_table before applying the default table

For views that do have a derived_table block but not a sql or explore_source variant the adapter understands (for example derived_table: { sql_create: ... } or create_process), sql stays None, so this fallback now assigns table = name. That imports a derived table as a physical table named after the view and generated queries target the wrong relation instead of preserving or flagging the unsupported derived table; the fallback should also require derived_table is None.

Useful? React with 👍 / 👎.

@nicosuave nicosuave force-pushed the fix/lookml-default-view-table branch from 84410ae to 92c08af Compare June 26, 2026 18:16
@nicosuave nicosuave force-pushed the fix/lookml-export-aggregations branch from adf80bc to e4e46ef Compare June 26, 2026 19:43
@nicosuave nicosuave force-pushed the fix/lookml-default-view-table branch from 92c08af to d2cb276 Compare June 26, 2026 19:45

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

ℹ️ 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".

table is None
and sql is None
and not view_def.get("derived_table")
and not extends

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve child defaults when extending tableless views

When a view extends a parent that also omitted sql_table_name, this guard prevents the child from ever getting its own default while the parent has already been assigned table = name; for view: base { ... } plus view: child { extends: [base] ... }, Sidemantic now compiles child against base instead of child. Looker applies defaults only after the merged view is interpreted, so an extended view with no explicit sql_table_name assumes the extending view name (see https://docs.cloud.google.com/looker/docs/reusing-code-with-extends#implementation_details_for_extends); this needs to distinguish explicit parent tables from synthetic defaults or apply the default after inheritance.

Useful? React with 👍 / 👎.

@nicosuave nicosuave force-pushed the fix/lookml-export-aggregations branch from e4e46ef to 5efe508 Compare June 26, 2026 20:02
@nicosuave nicosuave closed this Jun 26, 2026
@nicosuave nicosuave force-pushed the fix/lookml-default-view-table branch from d2cb276 to 5efe508 Compare June 26, 2026 20:02
A LookML view with no sql_table_name and no derived_table implicitly uses a
table named after the view (Looker's default behavior), but the adapter left
table unset, so importing such a view crashed layer validation with
"Model must have a table". Default table to the view name in that case,
while leaving refinements, extends-based views, and abstract
(extension: required) views untouched.
@nicosuave nicosuave reopened this Jun 26, 2026

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

ℹ️ 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 on lines +597 to +599
and not name.startswith("+")
and view_def.get("extension") != "required"
and (dimensions or measures)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply default tables after merging refinements

When the base view is fieldless and a +view refinement supplies the dimensions/measures, neither parsed model gets the implicit table: the base fails the (dimensions or measures) guard while the refinement is excluded by name.startswith("+"). After merge_model the final view has queryable fields but still no table, so adding or compiling that valid LookML pattern (view: orders {} plus view: +orders { dimension: id ... }) still fails validation even though Looker would default it to orders; the default needs to run on the merged view or otherwise account for fields added by refinements.

Useful? React with 👍 / 👎.

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