Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Update snowflake source
Signed-off-by: Kevin Zhang <kzhang@tecton.ai>
  • Loading branch information
kevjumba committed Apr 1, 2022
commit c6ace5594870e67ffe034b268d31eda26d71bc79
3 changes: 3 additions & 0 deletions protos/feast/core/DataSource.proto
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ message DataSource {

// Snowflake schema name
string database = 4;

// Snowflake warehouse name
string warehouse = 5;
}

// Defines configuration for custom third-party data sources.
Expand Down
25 changes: 23 additions & 2 deletions sdk/python/feast/infra/offline_stores/snowflake_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class SnowflakeSource(DataSource):
def __init__(
self,
database: Optional[str] = None,
warehouse: Optional[str] = None,
schema: Optional[str] = None,
table: Optional[str] = None,
query: Optional[str] = None,
Expand All @@ -33,6 +34,7 @@ def __init__(

Args:
database (optional): Snowflake database where the features are stored.
warehouse (optional): Snowflake warehouse where the database is stored.
schema (optional): Snowflake schema in which the table is located.
table (optional): Snowflake table where the features are stored.
event_timestamp_column (optional): Event timestamp column used for point in
Expand All @@ -55,7 +57,7 @@ def __init__(
_schema = "PUBLIC" if (database and table and not schema) else schema

self.snowflake_options = SnowflakeOptions(
database=database, schema=_schema, table=table, query=query
database=database, schema=_schema, table=table, query=query, warehouse=warehouse
)

# If no name, use the table as the default name
Expand Down Expand Up @@ -152,6 +154,11 @@ def query(self):
"""Returns the snowflake options of this snowflake source."""
return self.snowflake_options.query

@property
def warehouse(self):
"""Returns the warehouse of this snowflake source."""
return self.snowflake_options.warehouse

def to_proto(self) -> DataSourceProto:
"""
Converts a SnowflakeSource object to its protobuf representation.
Expand Down Expand Up @@ -239,11 +246,13 @@ def __init__(
schema: Optional[str],
table: Optional[str],
query: Optional[str],
warehouse: Optional[str],
):
self._database = database
self._schema = schema
self._table = table
self._query = query
self._warehouse = warehouse

@property
def query(self):
Expand Down Expand Up @@ -285,6 +294,16 @@ def table(self, table):
"""Sets the table ref of this snowflake table."""
self._table = table

@property
def warehouse(self):
"""Returns the warehouse name of this snowflake table."""
return self._warehouse

@table.setter
def warehouse(self, warehouse):
"""Sets the warehouse name of this snowflake table."""
self._warehouse = warehouse

@classmethod
def from_proto(cls, snowflake_options_proto: DataSourceProto.SnowflakeOptions):
"""
Expand All @@ -301,6 +320,7 @@ def from_proto(cls, snowflake_options_proto: DataSourceProto.SnowflakeOptions):
schema=snowflake_options_proto.schema,
table=snowflake_options_proto.table,
query=snowflake_options_proto.query,
warehouse=snowflake_options_proto.warehouse,
)

return snowflake_options
Expand All @@ -317,6 +337,7 @@ def to_proto(self) -> DataSourceProto.SnowflakeOptions:
schema=self.schema,
table=self.table,
query=self.query,
warehouse=self.warehouse,
)

return snowflake_options_proto
Expand All @@ -329,7 +350,7 @@ class SavedDatasetSnowflakeStorage(SavedDatasetStorage):

def __init__(self, table_ref: str):
self.snowflake_options = SnowflakeOptions(
database=None, schema=None, table=table_ref, query=None
database=None, schema=None, table=table_ref, query=None, warehouse=None
)

@staticmethod
Expand Down