Skip to content
Merged
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
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ Extends `PostgresAdapter`. Uses `redshift_connector` (>=2.1.8,<2.2).

**Auth providers:** `IAMRoleAuthProvider`, `BrowserIdentityCenterAuthProvider`

**Behavior flag:** `REDSHIFT_USE_SHOW_APIS` in `impl.py` gates SHOW TABLES / SVV_* APIs vs legacy PostgreSQL catalog queries. Jinja: `redshift__use_show_apis()`. Python: `adapter.use_show_apis()`.
**Datasharing:** The `datasharing` profile credential gates SHOW TABLES / SVV_* APIs vs legacy PostgreSQL catalog queries (required for cross-database operations). Jinja: `redshift__use_show_apis()`. Python: `adapter.use_show_apis()`.

**Extra test command:** `hatch run integration-tests-flaky` (runs flaky tests sequentially)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Breaking Changes
body: Remove the `redshift_use_show_apis` behavior flag. Use the `datasharing` profile credential instead to enable SHOW/SVV_* APIs for cross-database Datasharing support.
time: 2026-04-28T12:00:00.000000+05:30
custom:
Author: tauhid621
Issue: "1621"
29 changes: 3 additions & 26 deletions dbt-redshift/src/dbt/adapters/redshift/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@
),
)

REDSHIFT_USE_SHOW_APIS = BehaviorFlag(
name="redshift_use_show_apis",
default=False,
description=(
"Use Redshift SVV_* system views instead of PostgreSQL catalog tables "
"for metadata queries. Required for cross-database operations with Datasharing. "
),
)

REDSHIFT_GRANTS_EXTENDED = BehaviorFlag(
name="redshift_grants_extended",
default=False,
Expand Down Expand Up @@ -149,20 +140,10 @@ def __init__(self, config, mp_context: SpawnContext) -> None:
lambda: self.behavior.redshift_skip_autocommit_transaction_statements.no_warn
)

if (
self.behavior.redshift_use_show_apis.no_warn
and not self.config.credentials.datasharing
):
logger.debug(
"The `redshift_use_show_apis` behavior flag has been replaced by the `datasharing` profile configuration. "
"Please migrate to `datasharing` as this flag will be removed in a future release."
)

@property
def _behavior_flags(self) -> List[BehaviorFlag]:
return [
REDSHIFT_SKIP_AUTOCOMMIT_TRANSACTION_STATEMENTS,
REDSHIFT_USE_SHOW_APIS,
REDSHIFT_GRANTS_EXTENDED,
]

Expand Down Expand Up @@ -214,13 +195,9 @@ def convert_time_type(cls, agate_table: "agate.Table", col_idx):
def use_show_apis(self) -> bool:
"""Whether to use Redshift SHOW/SVV_* APIs for metadata queries.

Returns True when the ``datasharing`` profile config is enabled
or the ``redshift_use_show_apis`` behavior flag is set.
Returns True when the ``datasharing`` profile config is enabled.
"""
return (
bool(self.config.credentials.datasharing)
or self.behavior.redshift_use_show_apis.no_warn
)
return bool(self.config.credentials.datasharing)
Comment thread
tauhid621 marked this conversation as resolved.

@available
def drop_without_cascade(self) -> bool:
Expand All @@ -245,7 +222,7 @@ def verify_database(self, database):

if database.lower() != expected.lower() and not ra3_node and not self.use_show_apis():
raise dbt_common.exceptions.NotImplementedError(
"Cross-db references allowed only in RA3.* node. ({} vs {})".format(
"Cross-db references allowed only in RA3.* node or with datasharing enabled. ({} vs {})".format(
database, expected
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def relation(database, schema, identifier):
def adapter(mocker):
a = RedshiftAdapter(mocker.MagicMock(), mocker.MagicMock())
a.config.credentials.datasharing = True
a.behavior.redshift_use_show_apis = mocker.MagicMock(no_warn=False)
return a


Expand Down
7 changes: 1 addition & 6 deletions dbt-redshift/tests/unit/test_standardize_grants_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ def adapter(mocker):
mock_config.flags = {}
mock_mp_context = mocker.MagicMock()
a = RedshiftAdapter(mock_config, mock_mp_context)
# Explicit defaults: extended off, show_apis off. Individual test classes override as needed.
# Explicit defaults: extended off, datasharing off. Individual test classes override as needed.
a.behavior.redshift_grants_extended = mocker.MagicMock(no_warn=False)
a.behavior.redshift_use_show_apis = mocker.MagicMock(no_warn=False)
return a


Expand All @@ -58,7 +57,6 @@ class TestStandardizeGrantsDictShowApi:
@pytest.fixture(autouse=True)
def set_flags(self, adapter, mocker):
adapter.behavior.redshift_grants_extended = mocker.MagicMock(no_warn=True)
adapter.behavior.redshift_use_show_apis = mocker.MagicMock(no_warn=True)
adapter.config.credentials.datasharing = True

def test_includes_all_privileges(self, adapter):
Expand Down Expand Up @@ -320,7 +318,6 @@ class TestStandardizeGrantsDictSvv:
@pytest.fixture(autouse=True)
def set_flags(self, adapter, mocker):
adapter.behavior.redshift_grants_extended = mocker.MagicMock(no_warn=True)
adapter.behavior.redshift_use_show_apis = mocker.MagicMock(no_warn=False)
adapter.config.credentials.datasharing = False

def test_distinguishes_users_groups_roles(self, adapter):
Expand Down Expand Up @@ -389,7 +386,6 @@ class TestStandardizeGrantsDictLegacyNoShowApis:
@pytest.fixture(autouse=True)
def set_flags(self, adapter, mocker):
adapter.behavior.redshift_grants_extended = mocker.MagicMock(no_warn=False)
adapter.behavior.redshift_use_show_apis = mocker.MagicMock(no_warn=False)
adapter.config.credentials.datasharing = False

def test_returns_plain_names(self, adapter):
Expand Down Expand Up @@ -423,7 +419,6 @@ class TestStandardizeGrantsDictLegacyWithShowApis:
@pytest.fixture(autouse=True)
def set_flags(self, adapter, mocker):
adapter.behavior.redshift_grants_extended = mocker.MagicMock(no_warn=False)
adapter.behavior.redshift_use_show_apis = mocker.MagicMock(no_warn=True)
adapter.config.credentials.datasharing = True

def test_returns_plain_identity_names(self, adapter):
Expand Down
4 changes: 0 additions & 4 deletions dbt-redshift/tests/unit/test_verify_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,3 @@ def test_cross_db_blocked_without_either_config(self, adapter):
adapter.config.credentials.datasharing = False
with pytest.raises(dbt_common.exceptions.NotImplementedError, match="Cross-db"):
adapter.verify_database("other_db")

def test_cross_db_allowed_with_show_apis_flag(self, adapter, mocker):
adapter.behavior.redshift_use_show_apis = mocker.MagicMock(no_warn=True)
assert adapter.verify_database("other_db") == ""
Loading