Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Redshift push ignores schema #3671

Merged
merged 10 commits into from
Jul 24, 2023
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
Prev Previous commit
Next Next commit
pre-commit
Signed-off-by: Robin Neufeld <metavee@users.noreply.github.com>
  • Loading branch information
metavee committed Jun 30, 2023
commit 37a8a84f56de224df458905527ae5f7846c11e69
8 changes: 5 additions & 3 deletions sdk/python/feast/infra/offline_stores/redshift_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ def fully_qualified_table_name(self) -> Optional[str]:
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

# self.table may already contain the database and schema
parts = self.table.split(".")
if len(parts) == 3:
Expand All @@ -319,7 +319,9 @@ def fully_qualified_table_name(self) -> Optional[str]:
schema = self.schema
table = parts[0]
else:
raise ValueError(f"Invalid table name: {self.table} - can't determine database and schema")
raise ValueError(
f"Invalid table name: {self.table} - can't determine database and schema"
)

if database and schema:
return f"{database}.{schema}.{table}"
Expand Down
30 changes: 24 additions & 6 deletions sdk/python/tests/unit/test_data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,34 @@ def test_column_conflict():
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"),
(
{
"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"}, ""),
]
(
{
"database": "test_database",
"schema": "test_schema",
"query": "select * from abc",
},
"",
),
],
)
def test_redshift_fully_qualified_table_name(source_kwargs, expected_name):
redshift_source = RedshiftSource(
Expand All @@ -211,7 +229,7 @@ def test_redshift_fully_qualified_table_name(source_kwargs, expected_name):
description="test description",
tags={"test": "test"},
owner="test@gmail.com",
**source_kwargs
**source_kwargs,
)

assert redshift_source.redshift_options.fully_qualified_table_name == expected_name
assert redshift_source.redshift_options.fully_qualified_table_name == expected_name