Skip to content
Open
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
11 changes: 7 additions & 4 deletions great_expectations/datasource/fluent/sql_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,12 +1055,15 @@ class TableAsset(_SQLAsset):

@pydantic.validator("schema_name", pre=True, always=True)
@classmethod
def _schema_name_deprecation_warning(cls, v: str | Missing | None) -> str | Missing | None:
if v is MISSING:
return v
def _schema_name_deprecation_warning(
cls, v: str | Missing | None, values: dict
) -> str | Missing | None:
if v is MISSING or v is None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If v is None, that means the user passed schema_name=None right? We don't want that, because eventually we will remove schema_name and break them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means that OR - and this is what Don was hitting in the ticket I believe - we hit this when loading data from the server. But I guess you're right that we probably do want to keep warning if users pass it.. maybe I should just move this to make mercury filter out that field

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. It sounds like mercury "cleanup" needs to happen. Even if he was using an old asset, I wouldn't expect to see the warning.

return MISSING
# deprecated-v1.14.0
asset_name = values.get("name", "unknown")
warnings.warn(
"`schema_name` is deprecated."
f"`schema_name` is deprecated on asset '{asset_name}'."
" Pass the schema in your datasource's connection configuration instead.",
category=DeprecationWarning,
)
Expand Down
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,6 @@ filterwarnings = [
# --------------------------------------- Great Expectations Deprecation Warnings ----------------------------------
"once:The condition_parser parameter is deprecated:DeprecationWarning",
"once:Passing a string to the row_condition parameter is deprecated:DeprecationWarning",
# Existing cloud configs store "schema_name": null. During deserialization, Pydantic passes
# None to the validator which triggers the deprecation warning. The TableAsset.dict() override
# strips schema_name from new serializations, so these will clean up over time.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these got cleaned up from our cloud org! I think cloud-tests was failing and that's why I added this.

'once:The `schema_name` argument is deprecated:DeprecationWarning',
'once:`schema_name` is deprecated:DeprecationWarning',

# --------------------------------------- TEMPORARY IGNORES --------------------------------------------------------
# The warnings in this section should be addressed (fixed or ignored) but are ignored here temporarily to help allow
Expand Down
31 changes: 31 additions & 0 deletions tests/datasource/fluent/test_sql_datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from great_expectations.datasource.fluent import GxDatasourceWarning, SQLDatasource
from great_expectations.datasource.fluent.sql_datasource import (
DEFAULT_INITIAL_QUOTE_CHARACTERS,
MISSING,
Missing,
TableAsset,
to_lower_if_not_quoted,
)
Expand Down Expand Up @@ -472,6 +474,35 @@ def test_table_name_serialization_preserves_quotes(
serialized = table_asset.dict()
assert serialized["table_name"] == serialized_name

@pytest.mark.parametrize(
"schema_name",
[
pytest.param(MISSING, id="MISSING"),
pytest.param(None, id="None"),
],
)
def test_schema_name_non_string_values_normalize_to_missing_without_warning(
self,
schema_name: Missing | None,
) -> None:
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
asset = TableAsset(name="my_asset", table_name="my_table", schema_name=schema_name)

deprecation_warnings = [
w
for w in caught
if issubclass(w.category, DeprecationWarning) and "schema_name" in str(w.message)
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list-comprehension line exceeds the repo's Ruff line-length = 100 and will likely fail the ruff check (E501). Please reformat/wrap the comprehension (or split the predicate) so the line length stays within 100 characters.

Suggested change
if issubclass(w.category, DeprecationWarning) and "schema_name" in str(w.message)
if (
issubclass(w.category, DeprecationWarning)
and "schema_name" in str(w.message)
)

Copilot uses AI. Check for mistakes.
]
assert len(deprecation_warnings) == 0
assert asset.schema_name is MISSING

def test_schema_name_string_value_emits_deprecation_warning_with_asset_name(self) -> None:
with pytest.warns(DeprecationWarning, match=r"my_asset"):
asset = TableAsset(name="my_asset", table_name="my_table", schema_name="public")

assert asset.schema_name == "public"


if __name__ == "__main__":
pytest.main([__file__, "-vv"])
Loading