Skip to content

Preserve sub-hour precision for LookML 'time' timeframe#245

Open
nicosuave wants to merge 1 commit into
fix/lookml-default-view-tablefrom
fix/lookml-time-timeframe-precision
Open

Preserve sub-hour precision for LookML 'time' timeframe#245
nicosuave wants to merge 1 commit into
fix/lookml-default-view-tablefrom
fix/lookml-time-timeframe-precision

Conversation

@nicosuave

Copy link
Copy Markdown
Member

Summary

Part of the LookML adapter correctness series. Stacked on #244 (base = fix/lookml-default-view-table).

Looker's time timeframe returns the timestamp to the second, but the adapter mapped it to hour granularity (DATE_TRUNC('hour', ...)), silently collapsing every sub-hour row into one.

Changes

  • Map the time timeframe to second granularity (sidemantic supports it).
  • Add second/minute to the export granularity->timeframe map so they round-trip instead of degrading to date.
  • Update the four existing tests that asserted the old (buggy) hour grain, and add a dedicated test.

Not included (deferred)

minute15/minute30 (no native 15/30-min granularity in sidemantic) and time_of_day (clock-time extraction) remain approximations — documented in the audit.

@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: 360068606c

ℹ️ 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/lookml.py Outdated
Comment on lines 1842 to 1844
"second": "time",
"minute": "minute",
"hour": "time",

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 Use the LookML hour timeframe when exporting hour grains

When this mapping is used for an hour-grain dimension, it still emits the LookML time timeframe even though this commit now imports time as second. Any exported model containing an hour-granularity dimension, including one originally parsed from a LookML hour timeframe, will re-import as a second-grain *_time dimension instead of preserving hourly buckets; export hour as the LookML hour timeframe to avoid silently increasing query granularity.

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-time-timeframe-precision branch from 3600686 to 2e5a5e9 Compare June 26, 2026 18:17

@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: 2e5a5e9068

ℹ️ 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 +1844 to +1845
"second": "time",
"minute": "minute",

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 minute/second suffixes when exporting groups

When these new mappings are used for LookML-generated *_minute or *_second dimensions, they still do not round-trip because the base-name extraction above does not strip those suffixes, and second is always emitted as the time timeframe. For an imported dimension_group: start { timeframes: [minute, second] }, export groups the fields under start_minute/start_second, so re-import exposes start_minute_minute and start_second_time instead of the original fields; add suffix-aware handling or preserve the original timeframe before treating these grains as round-trippable.

Useful? React with 👍 / 👎.

@nicosuave nicosuave force-pushed the fix/lookml-default-view-table branch from 92c08af to d2cb276 Compare June 26, 2026 19:45
@nicosuave nicosuave force-pushed the fix/lookml-time-timeframe-precision branch from 2e5a5e9 to 3160319 Compare June 26, 2026 19:48
@nicosuave nicosuave force-pushed the fix/lookml-default-view-table branch from d2cb276 to 5efe508 Compare June 26, 2026 20:02
@nicosuave nicosuave closed this Jun 26, 2026
@nicosuave nicosuave force-pushed the fix/lookml-time-timeframe-precision branch from 3160319 to 5efe508 Compare June 26, 2026 20:03
Looker's 'time' timeframe keeps full timestamp precision (to the second),
but the adapter mapped it to hour granularity, silently collapsing all
sub-hour rows. Map 'time' to second granularity, and add second/minute to
the export granularity->timeframe map so they round-trip instead of
degrading to 'date'. Update the four tests that asserted the old hour grain.
@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: 9d82713acb

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

# Map granularity to timeframe
granularity_mapping = {
"hour": "time",
"second": "time",

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 LookML second timeframes on export

When a LookML dimension_group contains a second timeframe, it imports as a *_second dimension with granularity == "second", but this export mapping writes every second-grain dimension back as the LookML time timeframe. Fresh evidence in this revision is that *_second is now grouped with the same base name as *_time, so a group with both time and second exports duplicate timeframes: [time, time]; re-importing drops created_second and creates duplicate created_time fields, corrupting round-trip models that use Looker's second timeframe.

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