Skip to content

Commit 98866ed

Browse files
committed
Require LONGTEXT when validating Dolt datasets
1 parent 148c988 commit 98866ed

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎src/openstatspec/sql/wide.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ def _wide_column_type(profile: Any, storage_kind: str) -> Any:
6868
return binary64_type() if storage_kind == "numeric" else string_type(profile)
6969

7070

71+
def _valid_wide_string_type(profile: Any, column_type: Any) -> bool:
72+
"""Require Dolt's declared LONGTEXT boundary during reflected validation."""
73+
return (
74+
isinstance(column_type, mysql.LONGTEXT)
75+
if profile.name == "dolt"
76+
else isinstance(column_type, Text)
77+
)
78+
79+
7180
def _canonical_sha256(value: Any) -> str:
7281
return hashlib.sha256(
7382
json.dumps(value, sort_keys=True, separators=(",", ":"), default=str).encode("utf-8")
@@ -3244,6 +3253,9 @@ def validate_wide_dataset(
32443253
dataset_id: str,
32453254
dolt_conformance_source: DoltConformanceSource | None = None,
32463255
) -> dict[str, Any]:
3256+
profile, _active = effective_profile(
3257+
database_url, dolt_conformance_source=dolt_conformance_source,
3258+
)
32473259
dataset, variables, rows = read_wide_dataset(
32483260
database_url=database_url,
32493261
dataset_id=dataset_id,
@@ -3274,7 +3286,7 @@ def validate_wide_dataset(
32743286
if item["storage_kind"] == "numeric":
32753287
if not isinstance(column.type, Float) or not column.nullable:
32763288
raise ValueError(f"Numeric variable {item['source_name']!r} must be a nullable binary64 column.")
3277-
elif not isinstance(column.type, Text) or column.nullable:
3289+
elif not _valid_wide_string_type(profile, column.type) or column.nullable:
32783290
raise ValueError(f"String variable {item['source_name']!r} must be a non-null text column.")
32793291
if [row["__case_ordinal"] for row in rows] != list(range(1, len(rows) + 1)):
32803292
raise ValueError("Case ordinals are not contiguous source order.")

0 commit comments

Comments
 (0)