Package: feast-trino
Feast Trino SupportTrino is not included in currentFeastroadmap, this project intends to add Trino support for Offline Store.Version compatibilitiesThe feast-trino plugin is tested on the following versions of python [3.7, 3.8, 3.9]Here is also how the current feast-trino plugin has been tested against different versions of Feast and TrinoFeast-trinoFeastTrino1.0.*From 0.15.* to 0.18.*364QuickstartInstall feast-trinoInstall stable versionpipinstallfeast-trinoInstall develop version (not stable):pipinstallgit+https://github.com/shopify/feast-trino.git@mainCreate a feature repositoryfeastinitfeature_repoEditfeature_store.yamlsetoffline_storetype to befeast_trino.TrinoOfflineStoreproject:feature_reporegistry:data/registry.dbprovider:localoffline_store:type:feast_trino.trino.TrinoOfflineStorehost:localhostport:8080catalog:memoryconnector:type:memoryonline_store:path:data/online_store.dbCreate Trino TableEditfeature_repo/example.py# This is an example feature definition fileimportpandasaspdfromgoogle.protobuf.duration_pb2importDurationfromfeastimportEntity,Feature,FeatureView,FileSource,ValueType,FeatureStorefromfeast_trino.connectors.uploadimportupload_pandas_dataframe_to_trinofromfeast_trinoimportTrinoSourcefromfeast_trino.trino_utilsimportTrinostore=FeatureStore(repo_path="feature_repo")client=Trino(user="user",catalog=store.config.offline_store.catalog,host=store.config.offline_store.host,port=store.config.offline_store.port,)client.execute_query("CREATE SCHEMA IF NOT EXISTS feast")client.execute_query("DROP TABLE IF EXISTS feast.driver_stats")input_df=pd.read_parquet("./feature_repo/data/driver_stats.parquet")upload_pandas_dataframe_to_trino(client=client,df=input_df,table_ref="feast.driver_stats",connector_args={"type":"memory"},)# Read data from parquet files. Parquet is convenient for local development mode. For# production, you can use your favorite DWH, such as BigQuery. See Feast documentation# for more info.driver_hourly_stats=TrinoSource(event_timestamp_column="event_timestamp",table_ref="feast.driver_stats",created_timestamp_column="created",)# Define an entity for the driver. You can think of entity as a primary key used to# fetch features.driver=Entity(name="driver_id",value_type=ValueType.INT64,description="driver id",)# Our parquet files contain sample data that includes a driver_id column, timestamps and# three feature column. Here we define a Feature View that will allow us to serve this# data to our model online.driver_hourly_stats_view=FeatureView(name="driver_hourly_stats",entities=["driver_id"],ttl=Duration(seconds=86400*1),features=[Feature(name="conv_rate",dtype=ValueType.FLOAT),Feature(name="acc_rate",dtype=ValueType.FLOAT),Feature(name="avg_daily_trips",dtype=ValueType.INT64),],online=True,batch_source=driver_hourly_stats,tags={},)store.apply([driver,driver_hourly_stats_view])# Run an historical retrieval queryoutput_df=store.get_historical_features(entity_df="""SELECT1004 AS driver_id,TIMESTAMP '2021-11-21 15:00:00+00:00' AS event_timestamp""",features=["driver_hourly_stats:conv_rate"]).to_df()print(output_df.head())Apply the feature definitionspythonfeature_repo/example.pyDeveloping and TestingDevelopinggitclonehttps://github.com/shopify/feast-trino.gitcdfeast-trino# creating virtual env ...python-vvenvvenv/sourcevenv/bin/activate

makebuild# before commitmakeformat
makelintTesting unit testmakestart-local-cluster
maketestmakekill-local-clusterNote: You can visithttp://localhost:8080/ui/to access the Web UI of Trino. This makes it easy to look for queries.Testing against Feast universal suitemakeinstall-feast-submodule
makestart-local-cluster
maketest-python-universal
makekill-local-clusterUsing different versions of Feast or TrinoThemakefilecontains the following default values:FEAST_VERSION: v0.15.1TRINO_VERSION: 364Thus,make install-feast-submodulewill automatically compile Feastv0.15.1. If you want to try another version likev0.14.1, you just need to runmake install-feast-submodule FEAST_VERSION=v0.14.1Same applies for TRINO_VERSION when you start the local clustermake start-local-cluster TRINO_VERSION=XXX