Skip to content

fix: handle change to collectDoubles in convertTileDriftSeriesInfoToTimeSeries #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 31, 2025

Conversation

ken-zlai
Copy link
Contributor

@ken-zlai ken-zlai commented Jan 29, 2025

Summary

Recent changes to collectDoubles in PivotUtils now return null instead of empty lists for invalid data. This broke the /timeseries endpoints which assumed non-null lists.

Updated TimeSeriesHandler to:

  • Safely handle null lists using Option
  • Return empty sequences instead of failing
  • Fix isNumeric checks to handle null percentileDriftSeries

@sean-zlai to test:
You can check that the charts are broken on main, due to /timeseries being broken. If you check out this branch and run everything from scratch (./docker-init/build.sh --all), it should fix the charts.

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

  • Bug Fixes
    • Improved null handling in time series processing
    • Enhanced robustness of data conversion methods
    • Reduced risk of potential runtime exceptions

Copy link

coderabbitai bot commented Jan 29, 2025

Walkthrough

The pull request enhances null handling in the TimeSeriesHandler.scala file, specifically within the convertTileDriftSeriesInfoToTimeSeries method. It employs Scala's Option type to improve code safety and minimize the risk of null pointer exceptions. The modifications provide a more idiomatic approach to managing optional series data, ensuring robust handling of potentially null or empty collections.

Changes

File Change Summary
hub/src/main/scala/ai/chronon/hub/handlers/TimeSeriesHandler.scala Refactored null checks using Option and exists for percentileDriftSeries and nullRatioChangePercentSeries, and updated lhsList handling.

Possibly related PRs

Suggested Reviewers

  • nikhil-zlai
  • tchow-zlai

Poem

Null checks dance with Option's grace,
Scala's magic leaves no trace
Of errors lurking in the code
Robustness now our new abode! 🛡️✨
Safe and clean, the series flows

Warning

Review ran into problems

🔥 Problems

GitHub Actions: Resource not accessible by integration - https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-repository.

Please grant the required permissions to the CodeRabbit GitHub App under the organization or repository settings.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 47ac92e and ab9e068.

📒 Files selected for processing (1)
  • hub/src/main/scala/ai/chronon/hub/handlers/TimeSeriesHandler.scala (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • hub/src/main/scala/ai/chronon/hub/handlers/TimeSeriesHandler.scala
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: enforce_triggered_workflows

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ken-zlai ken-zlai changed the title -fix: handle change to collectDoubles in convertTileDriftSeriesInfoToTimeSeries fix: handle change to collectDoubles in convertTileDriftSeriesInfoToTimeSeries Jan 29, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
hub/src/main/scala/ai/chronon/hub/handlers/TimeSeriesHandler.scala (1)

126-132: LGTM! Safe handling of null lists.

The changes correctly handle null cases by returning empty sequences.

Minor formatting suggestion:

    val lhsList = if (metric == NullMetric) {
      Option(tileDriftSeries.nullRatioChangePercentSeries).map(_.asScala).getOrElse(Seq.empty)
    } else {
-      if (isNumeric) 
-        Option(tileDriftSeries.percentileDriftSeries).map(_.asScala).getOrElse(Seq.empty)
-      else 
-        Option(tileDriftSeries.histogramDriftSeries).map(_.asScala).getOrElse(Seq.empty)
+      if (isNumeric) Option(tileDriftSeries.percentileDriftSeries).map(_.asScala).getOrElse(Seq.empty)
+      else Option(tileDriftSeries.histogramDriftSeries).map(_.asScala).getOrElse(Seq.empty)
    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 38ea292 and 47ac92e.

📒 Files selected for processing (1)
  • hub/src/main/scala/ai/chronon/hub/handlers/TimeSeriesHandler.scala (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: enforce_triggered_workflows
🔇 Additional comments (1)
hub/src/main/scala/ai/chronon/hub/handlers/TimeSeriesHandler.scala (1)

122-124: LGTM! Safer null handling with Option.

@sean-zlai
Copy link
Contributor

Interestingly, I pulled main and re-ran docker-init/build.sh --all and docker-init/demo/load_summaries.sh and while I see the error...

Error fetching join drift: Cannot invoke "scala.collection.mutable.Buffer.zip(scala.collection.GenIterable, scala.collection.generic.CanBuildFrom)"because "lhsList"is null

image

the charts rendered without an issue (as the second timeseries request succeeds)

image

image

Checking out your PR now and restarted the docker environment, but wanted to toss that out there (and in case I'm looking at it wrong)

@ken-zlai
Copy link
Contributor Author

I'm absolutely dumbfounded here - I rebuilt everything from main this morning and our charts work as expected.

I'll close this PR since things seem to be working. I really don't know why I've seen inconsistent behavior - maybe a rouge sbt clean made the difference?

@ken-zlai ken-zlai closed this Jan 29, 2025
@ken-zlai ken-zlai reopened this Jan 31, 2025
@ken-zlai ken-zlai merged commit aabaf4b into main Jan 31, 2025
5 checks passed
@ken-zlai ken-zlai deleted the ken/collectDoubles-workaround branch January 31, 2025 01:36
nikhil-zlai pushed a commit that referenced this pull request Feb 4, 2025
…imeSeries (#293)

## Summary
[Recent
changes](01a2f70#diff-deee840c61f04e77fc1a50be94e1e153c193fb4b00a7b1389a733e0941c29714)
to `collectDoubles` in PivotUtils now return null instead of empty lists
for invalid data. This broke the /timeseries endpoints which assumed
non-null lists.

Updated TimeSeriesHandler to:
- Safely handle null lists using Option
- Return empty sequences instead of failing
- Fix isNumeric checks to handle null percentileDriftSeries

@sean-zlai to test:
You can check that the charts are broken on main, due to /timeseries
being broken. If you check out this branch and run everything from
scratch (`./docker-init/build.sh --all`), it should fix the charts.

## Checklist
- [ ] Added Unit Tests
- [ ] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
	- Improved null handling in time series processing
	- Enhanced robustness of data conversion methods
	- Reduced risk of potential runtime exceptions

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

2 participants