Skip to content

Commit

Permalink
Revert "fix: Redshift push ignores schema (feast-dev#3671)"
Browse files Browse the repository at this point in the history
This reverts commit 2810d97.
  • Loading branch information
EXPEbdodla authored Jun 11, 2024
1 parent 98bd324 commit 11f341d
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 147 deletions.
2 changes: 1 addition & 1 deletion sdk/python/feast/infra/offline_stores/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def offline_write_batch(
s3_resource=s3_resource,
s3_path=f"{config.offline_store.s3_staging_location}/push/{uuid.uuid4()}.parquet",
iam_role=config.offline_store.iam_role,
table_name=redshift_options.fully_qualified_table_name,
table_name=redshift_options.table,
schema=pa_schema,
fail_if_exists=False,
)
Expand Down
37 changes: 1 addition & 36 deletions sdk/python/feast/infra/offline_stores/redshift_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,42 +294,6 @@ def from_proto(cls, redshift_options_proto: DataSourceProto.RedshiftOptions):

return redshift_options

@property
def fully_qualified_table_name(self) -> str:
"""
The fully qualified table name of this Redshift table.
Returns:
A string in the format of <database>.<schema>.<table>
May be empty or None if the table is not set
"""

if not self.table:
return ""

# self.table may already contain the database and schema
parts = self.table.split(".")
if len(parts) == 3:
database, schema, table = parts
elif len(parts) == 2:
database = self.database
schema, table = parts
elif len(parts) == 1:
database = self.database
schema = self.schema
table = parts[0]
else:
raise ValueError(
f"Invalid table name: {self.table} - can't determine database and schema"
)

if database and schema:
return f"{database}.{schema}.{table}"
elif schema:
return f"{schema}.{table}"
else:
return table

def to_proto(self) -> DataSourceProto.RedshiftOptions:
"""
Converts an RedshiftOptionsProto object to its protobuf representation.
Expand Down Expand Up @@ -359,6 +323,7 @@ def __init__(self, table_ref: str):

@staticmethod
def from_proto(storage_proto: SavedDatasetStorageProto) -> SavedDatasetStorage:

return SavedDatasetRedshiftStorage(
table_ref=RedshiftOptions.from_proto(storage_proto.redshift_storage).table
)
Expand Down
67 changes: 0 additions & 67 deletions sdk/python/tests/unit/infra/offline_stores/test_redshift.py

This file was deleted.

43 changes: 0 additions & 43 deletions sdk/python/tests/unit/test_data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,46 +190,3 @@ def test_column_conflict():
timestamp_field="event_timestamp",
created_timestamp_column="event_timestamp",
)


@pytest.mark.parametrize(
"source_kwargs,expected_name",
[
(
{
"database": "test_database",
"schema": "test_schema",
"table": "test_table",
},
"test_database.test_schema.test_table",
),
(
{"database": "test_database", "table": "test_table"},
"test_database.public.test_table",
),
({"table": "test_table"}, "public.test_table"),
({"database": "test_database", "table": "b.c"}, "test_database.b.c"),
({"database": "test_database", "table": "a.b.c"}, "a.b.c"),
(
{
"database": "test_database",
"schema": "test_schema",
"query": "select * from abc",
},
"",
),
],
)
def test_redshift_fully_qualified_table_name(source_kwargs, expected_name):
redshift_source = RedshiftSource(
name="test_source",
timestamp_field="event_timestamp",
created_timestamp_column="created_timestamp",
field_mapping={"foo": "bar"},
description="test description",
tags={"test": "test"},
owner="test@gmail.com",
**source_kwargs,
)

assert redshift_source.redshift_options.fully_qualified_table_name == expected_name

0 comments on commit 11f341d

Please sign in to comment.