Visitar URL original
fix: Address Lance read review feedback · feast-dev/feast@8b8d17c · GitHub
Skip to content

Commit 8b8d17c

Browse files
haoxu0ntkathole
authored andcommitted
fix: Address Lance read review feedback
Signed-off-by: HaoXuAI <sduxuhao@gmail.com>
1 parent e7e2adf commit 8b8d17c

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

‎sdk/python/feast/infra/data_sources/contrib/lance/lance_source.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import json
3232
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple
3333

34-
from feast.credentials import ConnectionRef
3534
from feast.data_source import DataSource
3635
from feast.protos.feast.core.DataSource_pb2 import DataSource as DataSourceProto
3736
from feast.repo_config import RepoConfig
@@ -126,7 +125,6 @@ def __init__(
126125
description: Optional[str] = "",
127126
tags: Optional[Dict[str, str]] = None,
128127
owner: Optional[str] = "",
129-
connection_ref: Optional[ConnectionRef] = None,
130128
):
131129
if table_format is not None and not isinstance(table_format, LanceFormat):
132130
raise ValueError(
@@ -162,7 +160,6 @@ def __init__(
162160
description=description,
163161
tags=tags,
164162
owner=owner,
165-
connection_ref=connection_ref,
166163
)
167164
self.uri = uri
168165
self.lance_table = table
@@ -282,9 +279,11 @@ def to_arrow(
282279
of the result.
283280
"""
284281
dataset = self.get_dataset()
282+
if feature_view is not None:
283+
_validate_against_feature_view(self, dataset.schema, feature_view)
284+
285285
table = dataset.to_table(columns=columns)
286286
if feature_view is not None:
287-
_validate_against_feature_view(self, table.schema, feature_view)
288287
from feast.utils import _validate_vector_field_lengths
289288

290289
_validate_vector_field_lengths(table, feature_view)
@@ -395,7 +394,6 @@ def from_proto(data_source: DataSourceProto) -> Any:
395394
description=data_source.description,
396395
tags=tags,
397396
owner=data_source.owner,
398-
connection_ref=ConnectionRef.from_tags(tags),
399397
)
400398

401399

‎sdk/python/tests/unit/infra/data_sources/test_lance_source.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import pyarrow as pa
2626
import pytest
2727

28+
from feast.credentials import ConnectionRef
2829
from feast.entity import Entity
2930
from feast.feature_view import FeatureView
3031
from feast.field import Field
@@ -135,6 +136,14 @@ def test_rejects_a_non_lance_table_format():
135136
LanceSource(uri="/tmp/x.lance", table_format=IcebergFormat())
136137

137138

139+
def test_rejects_an_unimplemented_connection_ref():
140+
with pytest.raises(TypeError, match="unexpected keyword argument 'connection_ref'"):
141+
LanceSource(
142+
uri="s3://bucket/emb.lance",
143+
connection_ref=ConnectionRef(provider="env", name="LANCE"),
144+
)
145+
146+
138147
def test_default_name_is_the_uri_for_a_path_based_source():
139148
assert LanceSource(uri="/tmp/x.lance").name == "/tmp/x.lance"
140149

@@ -259,6 +268,17 @@ def test_path_based_read_projects_columns(tmp_path):
259268
assert source.to_arrow(columns=["driver_id"]).column_names == ["driver_id"]
260269

261270

271+
def test_projection_validates_the_full_source_schema(tmp_path):
272+
uri = str(tmp_path / "emb.lance")
273+
_write(uri, _driver_stats())
274+
source = LanceSource(uri=uri, timestamp_field="event_timestamp")
275+
feature_view = _feature_view(source)
276+
277+
table = source.to_arrow(columns=["driver_id"], feature_view=feature_view)
278+
279+
assert table.column_names == ["driver_id"]
280+
281+
262282
def test_path_based_schema_inference(tmp_path):
263283
uri = str(tmp_path / "emb.lance")
264284
_write(uri, _driver_stats())

0 commit comments

Comments
 (0)