Skip to content

Commit 0344087

Browse files
committed
test: Validate the query logic to validate metrics calculation
Signed-off-by: Jitendra Yejare <11752425+jyejare@users.noreply.github.com>
1 parent 5f7cd6a commit 0344087

3 files changed

Lines changed: 1834 additions & 4 deletions

File tree

sdk/python/feast/infra/offline_stores/dask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ def _dask_filter_arrow_by_timestamp(
810810
def _dask_compute_numeric_metrics(
811811
column: pyarrow.ChunkedArray, histogram_bins: int
812812
) -> Dict[str, Any]:
813-
total = column.length
813+
total = len(column)
814814
null_count = column.null_count
815815
result: Dict[str, Any] = {
816816
"feature_type": "numeric",
@@ -863,7 +863,7 @@ def _dask_compute_numeric_metrics(
863863
def _dask_compute_categorical_metrics(
864864
column: pyarrow.ChunkedArray, top_n: int
865865
) -> Dict[str, Any]:
866-
total = column.length
866+
total = len(column)
867867
null_count = column.null_count
868868
result: Dict[str, Any] = {
869869
"feature_type": "categorical",

sdk/python/feast/infra/offline_stores/duckdb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,10 @@ def _duckdb_numeric_histogram(
262262
).fetchone()[0]
263263
return {"bins": [min_val, max_val], "counts": [cnt], "bin_width": 0.0}
264264

265-
upper = max_val + (max_val - min_val) * 1e-10
266265
bin_width = (max_val - min_val) / bins
267266

268267
query = (
269-
f"SELECT width_bucket(CAST({q_col} AS DOUBLE), {min_val}, {upper}, {bins}) AS bucket, "
268+
f"SELECT LEAST(FLOOR((CAST({q_col} AS DOUBLE) - {min_val}) / {bin_width}) + 1, {bins}) AS bucket, "
270269
f"COUNT(*) AS cnt "
271270
f"FROM {from_expr} AS _src "
272271
f"WHERE {q_col} IS NOT NULL AND {tw} "

0 commit comments

Comments
 (0)