Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions infra/website/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ features = store.retrieve_online_documents(
<div class="logo-item">
<img src="/images/logos/seatgeek.svg" alt="SeatGeek" class="company-logo">
</div>
<div class="logo-item">
<img src="/images/logos/castai.png" alt="Cast.ai" class="company-logo">
</div>
</div>
</div>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from feast.infra.offline_stores.contrib.clickhouse_offline_store.clickhouse_source import (
ClickhouseSource,
)
from feast.infra.utils.clickhouse.clickhouse_config import ClickhouseConfig
from feast.infra.utils.clickhouse.connection_utils import get_client
from tests.integration.feature_repos.universal.data_source_creator import (
DataSourceCreator,
)
Expand Down Expand Up @@ -114,3 +116,29 @@ def create_saved_dataset_destination(self):

def teardown(self):
pass


def test_get_client_with_additional_params(clickhouse_container):
"""
Test that get_client works with a real ClickHouse container and properly passes
additional settings like send_receive_timeout.
"""
# Create config with custom send_receive_timeout
config = ClickhouseConfig(
host=clickhouse_container.get_container_host_ip(),
port=clickhouse_container.get_exposed_port(8123),
user=CLICKHOUSE_USER,
password=CLICKHOUSE_PASSWORD,
database=CLICKHOUSE_OFFLINE_DB,
additional_client_args={"send_receive_timeout": 60},
)

# Get client and verify it works
client = get_client(config)

# Verify client is connected and functional by running a simple query
result = client.query("SELECT 1 AS test_value")
assert result.result_rows == [(1,)]

# Verify the send_receive_timeout was applied
assert client.timeout._read == 60
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Any

from pydantic import ConfigDict, StrictStr

from feast.repo_config import FeastConfigBaseModel
Expand All @@ -11,4 +13,8 @@ class ClickhouseConfig(FeastConfigBaseModel):
password: StrictStr
use_temporary_tables_for_entity_df: bool = True

# See https://github.com/ClickHouse/clickhouse-connect/blob/main/clickhouse_connect/driver/__init__.py#L51
# Some typical ones e.g. send_receive_timeout (read_timeout), etc
additional_client_args: dict[str, Any] | None = None

model_config = ConfigDict(frozen=True)
26 changes: 19 additions & 7 deletions sdk/python/feast/infra/utils/clickhouse/connection_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,24 @@
def get_client(config: ClickhouseConfig) -> Client:
# Clickhouse client is not thread-safe, so we need to create a separate instance for each thread.
if not hasattr(thread_local, "clickhouse_client"):
thread_local.clickhouse_client = clickhouse_connect.get_client(
host=config.host,
port=config.port,
user=config.user,
password=config.password,
database=config.database,
)
additional_client_args = config.additional_client_args

if additional_client_args:
thread_local.clickhouse_client = clickhouse_connect.get_client(
host=config.host,
port=config.port,
user=config.user,
password=config.password,
database=config.database,
**additional_client_args,
)
else:
thread_local.clickhouse_client = clickhouse_connect.get_client(
host=config.host,
port=config.port,
user=config.user,
password=config.password,
database=config.database,
)

return thread_local.clickhouse_client
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project: my_project
provider: local
registry:
registry_type: sql
path: postgresql://postgres:mysecretpassword@127.0.0.1:55001/feast
path: postgresql://DB_USERNAME:DB_PASSWORD@DB_HOST:DB_PORT/DB_NAME
cache_ttl_seconds: 60
sqlalchemy_config_kwargs:
echo: false
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/feast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ def _group_feature_refs(

# on demand view to on demand view proto
on_demand_view_index: Dict[str, "OnDemandFeatureView"] = {}

# FIXME: broken for get_historical_features, for them, we need to treat ODFVs as ODFVs
# not like FVs (that's only convenient for online request)
for view in all_on_demand_feature_views:
if view.projection and not view.write_to_online_store:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need projections IIRC in the materialization

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if you want to avoid the transformation on get_historical_features then i would put that logic there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'll check and adjust.

on_demand_view_index[view.projection.name_to_use()] = view
Expand Down
57 changes: 57 additions & 0 deletions sdk/python/tests/unit/infra/offline_stores/test_clickhouse.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import threading
from unittest.mock import MagicMock, patch

Expand All @@ -6,6 +7,8 @@
from feast.infra.utils.clickhouse.clickhouse_config import ClickhouseConfig
from feast.infra.utils.clickhouse.connection_utils import get_client, thread_local

logger = logging.getLogger(__name__)


@pytest.fixture
def clickhouse_config():
Expand Down Expand Up @@ -76,3 +79,57 @@ def thread_2_work():
assert client_1a is not client_2, (
"Different threads should get different client instances (not cached)"
)


def test_clickhouse_config_parses_additional_client_args():
"""
Test that ClickhouseConfig correctly parses additional_client_args from a dict,
simulating how it would be parsed from YAML by Pydantic.
"""
# This simulates the dict that would come from yaml.safe_load()
raw_config = {
"host": "localhost",
"port": 8123,
"database": "default",
"user": "default",
"password": "password",
"additional_client_args": {
"send_receive_timeout": 60,
"compress": True,
"client_name": "feast_test",
},
}

# Pydantic should parse this dict into a ClickhouseConfig object
config = ClickhouseConfig(**raw_config)

# Verify all fields are correctly parsed
assert config.host == "localhost"
assert config.port == 8123
assert config.database == "default"
assert config.user == "default"
assert config.password == "password"

# Verify additional_client_args is correctly parsed as a dict
assert config.additional_client_args is not None
assert isinstance(config.additional_client_args, dict)
assert config.additional_client_args["send_receive_timeout"] == 60
assert config.additional_client_args["compress"] is True
assert config.additional_client_args["client_name"] == "feast_test"


def test_clickhouse_config_handles_none_additional_client_args():
"""
Test that ClickhouseConfig correctly handles when additional_client_args is not provided.
"""
raw_config = {
"host": "localhost",
"port": 8123,
"database": "default",
"user": "default",
"password": "password",
}

config = ClickhouseConfig(**raw_config)

assert config.additional_client_args is None
14 changes: 14 additions & 0 deletions sdk/python/tests/unit/local_feast_tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,17 @@ def test_repo_init_with_underscore_in_project_name() -> None:
)
result = runner.run(["apply"], cwd=repo_dir)
assert result.returncode != 0


def test_postgres_template_registry_path_is_parameterized() -> None:
template_fs_yaml = (
Path(__file__).resolve().parents[3]
/ "feast"
/ "templates"
/ "postgres"
/ "feature_repo"
/ "feature_store.yaml"
)
contents = template_fs_yaml.read_text(encoding="utf-8")
expected = "path: postgresql://DB_USERNAME:DB_PASSWORD@DB_HOST:DB_PORT/DB_NAME"
assert expected in contents
Loading