Skip to content

Commit 3da4dde

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 9091b90 commit 3da4dde

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
@@ -803,7 +803,7 @@ def _dask_filter_arrow_by_timestamp(
803803
def _dask_compute_numeric_metrics(
804804
column: pyarrow.ChunkedArray, histogram_bins: int
805805
) -> Dict[str, Any]:
806-
total = column.length
806+
total = len(column)
807807
null_count = column.null_count
808808
result: Dict[str, Any] = {
809809
"feature_type": "numeric",
@@ -856,7 +856,7 @@ def _dask_compute_numeric_metrics(
856856
def _dask_compute_categorical_metrics(
857857
column: pyarrow.ChunkedArray, top_n: int
858858
) -> Dict[str, Any]:
859-
total = column.length
859+
total = len(column)
860860
null_count = column.null_count
861861
result: Dict[str, Any] = {
862862
"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)