Skip to content

Commit b927aac

Browse files
ken-zlainikhil-zlai
authored andcommitted
fix: handle change to collectDoubles in convertTileDriftSeriesInfoToTimeSeries (#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 -->
1 parent fdfa2c4 commit b927aac

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

hub/src/main/scala/ai/chronon/hub/handlers/TimeSeriesHandler.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,17 @@ class TimeSeriesHandler(driftStore: DriftStore) {
119119
// check if we have a numeric / categorical feature. If the percentile drift series has non-null doubles
120120
// then we have a numeric feature at hand
121121
val isNumeric =
122-
tileDriftSeries.percentileDriftSeries.asScala != null && tileDriftSeries.percentileDriftSeries.asScala
123-
.exists(_ != null)
122+
Option(tileDriftSeries.percentileDriftSeries).exists(series => series.asScala.exists(_ != null))
123+
124124
val lhsList = if (metric == NullMetric) {
125-
tileDriftSeries.nullRatioChangePercentSeries.asScala
125+
Option(tileDriftSeries.nullRatioChangePercentSeries).map(_.asScala).getOrElse(Seq.empty)
126126
} else {
127-
if (isNumeric) tileDriftSeries.percentileDriftSeries.asScala
128-
else tileDriftSeries.histogramDriftSeries.asScala
127+
if (isNumeric)
128+
Option(tileDriftSeries.percentileDriftSeries).map(_.asScala).getOrElse(Seq.empty)
129+
else
130+
Option(tileDriftSeries.histogramDriftSeries).map(_.asScala).getOrElse(Seq.empty)
129131
}
132+
130133
val points = lhsList.zip(tileDriftSeries.timestamps.asScala).map {
131134
case (v, ts) => TimeSeriesPoint(v, ts)
132135
}

0 commit comments

Comments
 (0)