Title: get_historical_features raises TypeError on a zero-row entity_df (Dask/file offline store) · Issue #6817 · feast-dev/feast · GitHub
Open Graph Title: get_historical_features raises TypeError on a zero-row entity_df (Dask/file offline store) · Issue #6817 · feast-dev/feast
X Title: get_historical_features raises TypeError on a zero-row entity_df (Dask/file offline store) · Issue #6817 · feast-dev/feast
Description: Expected Behavior get_historical_features with an entity_df that happens to have zero rows should return an empty result with the right columns. A zero-row entity frame is a normal degenerate case in batch scoring — the upstream query si...
Open Graph Description: Expected Behavior get_historical_features with an entity_df that happens to have zero rows should return an empty result with the right columns. A zero-row entity frame is a normal degenerate case ...
X Description: Expected Behavior get_historical_features with an entity_df that happens to have zero rows should return an empty result with the right columns. A zero-row entity frame is a normal degenerate case ...
Opengraph URL: https://github.com/feast-dev/feast/issues/6817
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"get_historical_features raises TypeError on a zero-row entity_df (Dask/file offline store)","articleBody":"## Expected Behavior\n\n`get_historical_features` with an `entity_df` that happens to have zero rows should\nreturn an empty result with the right columns. A zero-row entity frame is a normal\ndegenerate case in batch scoring — the upstream query simply matched nothing that run.\n\n## Current Behavior\n\nIt raises an opaque pandas error from deep inside the Dask offline store:\n\n```\nTypeError: Invalid comparison between dtype=datetime64[ns] and DatetimeArray\n```\n\nTraceback tail:\n\n```\n File \"sdk/python/feast/infra/offline_stores/offline_store.py\", line 178, in to_arrow\n features_table = self._to_arrow_internal(timeout=timeout)\n File \"sdk/python/feast/infra/offline_stores/dask.py\", line 103, in _to_arrow_internal\n df = self.evaluation_function().compute()\n File \"sdk/python/feast/infra/offline_stores/dask.py\", line 317, in evaluate_historical_retrieval\n df_to_join = _filter_ttl(\n File \"sdk/python/feast/infra/offline_stores/dask.py\", line 1206, in _filter_ttl\n df_to_join = df_to_join.persist()\n```\n\n## Steps to reproduce\n\nIdentical construction, only the row count differs, against a `file` offline store:\n\n```python\ndef mk(n):\n return pd.DataFrame({\n \"driver_id\": [1001] * n,\n \"event_timestamp\": pd.to_datetime([datetime(2026, 2, 1)] * n, utc=True),\n })\n\nfs.get_historical_features(entity_df=mk(1), features=[\"driver_stats:conv_rate\"]).to_df()\n# OK, shape=(1, 3)\n\nfs.get_historical_features(entity_df=mk(0), features=[\"driver_stats:conv_rate\"]).to_df()\n# TypeError: Invalid comparison between dtype=datetime64[ns] and DatetimeArray\n```\n\n### Specifications\n\n- Version: `master` @ `5ad5592390febfca60c9d88edf7daccbdd156fd6`\n- Platform: Linux x86_64, Python 3.11.15, dask 2026.8.0\n- Subsystem: offline store (Dask / file)\n\n## Possible Solution\n\n`_normalize_timestamp` (`sdk/python/feast/infra/offline_stores/dask.py:1139`) makes\ntimestamp columns tz-aware with a row-wise `apply`:\n\n```python\ndf_to_join[timestamp_field] = df_to_join[timestamp_field].apply(\n lambda x: x if x.tzinfo else x.replace(tzinfo=timezone.utc),\n meta=(timestamp_field, \"datetime64[ns, UTC]\"),\n)\n```\n\n`meta` *declares* a tz-aware result, but with zero rows the lambda never runs, so the\ncomputed partition stays `datetime64[ns]`. Declared and actual dtypes then diverge, and\nthe tz-naive vs tz-aware comparison in `_filter_ttl`\n(`sdk/python/feast/infra/offline_stores/dask.py:1183`) raises.\n\nReplacing the row-wise `apply` with a vectorized, empty-safe conversion fixes it and is\nfaster on non-empty frames too: pick `dt.tz_localize(\"UTC\")` for a tz-naive column and\n`dt.tz_convert(\"UTC\")` otherwise, based on the column's declared dtype. That yields the\ncorrect dtype even when the partition is empty.\n\nA regression test covering a zero-row `entity_df` through\n`get_historical_features(...).to_df()` on the Dask store would pin this down; the\ncurrent suite only exercises non-empty entity frames, which is why CI stays green.\n\nHappy to send a PR for this.\n","author":{"url":"https://github.com/Daksha1611","@type":"Person","name":"Daksha1611"},"datePublished":"2026-09-06T18:32:57Z","url":"https://github.com/feast-dev/feast/issues/6817"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:71502405-9f7b-70cd-0440-f0ff9479a513 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8F8C:E40BB:E68AB4:13ADE40:6AFE9526 |
| html-safe-nonce | 65c78633d6655c69f85ac43b0fe9ae4d25fe6905af42afe841eb1b275782ef37 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjhDOkU0MEJCOkU2OEFCNDoxM0FERTQwOjZBRkU5NTI2IiwidmlzaXRvcl9pZCI6Ijg2Njk4NzAzNDc1NTk4MDIxNTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bb6ba2572a257383c9a14f03d20f27bfd7fb3b0e53b21973857eaa3aa1f8a3da |
| hovercard-subject-tag | issue:5366866001 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/feast-dev/feast/6817/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5b18c661e8a40f17f7ce12c9424b9ec08a517fad60dc254aafd9080382cb2e81/feast-dev/feast/issues/6817 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5b18c661e8a40f17f7ce12c9424b9ec08a517fad60dc254aafd9080382cb2e81/feast-dev/feast/issues/6817 |
| og:image:alt | Expected Behavior get_historical_features with an entity_df that happens to have zero rows should return an empty result with the right columns. A zero-row entity frame is a normal degenerate case ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Daksha1611 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86 |
| turbo-cache-control | no-preview |
| go-import | github.com/feast-dev/feast git https://github.com/feast-dev/feast.git |
| octolytics-dimension-user_id | 57027613 |
| octolytics-dimension-user_login | feast-dev |
| octolytics-dimension-repository_id | 161133770 |
| octolytics-dimension-repository_nwo | feast-dev/feast |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 161133770 |
| octolytics-dimension-repository_network_root_nwo | feast-dev/feast |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4a10310af51a1bfffbedc4fd81cb582acf0cb0ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width