File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ class ColumnChars:
2020 column_type : str | None = None
2121 db_data_type : str | None = None
2222 is_decimal : bool = False
23- object_type : str | None = None # ObjectType values
23+ object_type : ObjectType | None = None
2424 approx_record_ct : int | None = None
2525 # This should not default to 0 since we don't always retrieve actual row counts
2626 # UI relies on the null value to know that the approx_record_ct should be displayed instead
Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ class MssqlFlavorService(FlavorService):
1111 escaped_underscore = "[_]"
1212 row_limiting_clause = "top"
1313 url_scheme = "mssql+pyodbc"
14- # TABLESAMPLE applies only to tables and materialized views
15- sampleable_object_types = frozenset ({ObjectType .TABLE , ObjectType . MATERIALIZED_VIEW })
14+ # TABLESAMPLE is rejected on views; SQL Server has no materialized views, so only base tables.
15+ sampleable_object_types = frozenset ({ObjectType .TABLE })
1616
1717 def get_connection_string_from_fields (self , params : ResolvedConnectionParams ) -> str :
1818 connection_url = URL .create (
Original file line number Diff line number Diff line change 1717)
1818from sqlalchemy .dialects import postgresql
1919
20+ from testgen .common .database .column_chars import ObjectType
2021from testgen .common .models import get_current_session
2122from testgen .common .models .data_column import DataColumnChars
2223from testgen .common .models .entity import Entity
@@ -42,7 +43,7 @@ class TableProfilingOverview:
4243 table_groups_id : UUID
4344 schema_name : str | None
4445 table_name : str
45- object_type : str | None
46+ object_type : ObjectType | None
4647 record_ct : int | None
4748 column_ct : int | None
4849 dq_score_profiling : float | None
@@ -62,7 +63,7 @@ class DataTable(Entity):
6263 table_groups_id : UUID = Column (postgresql .UUID (as_uuid = True ), ForeignKey ("table_groups.id" ))
6364 schema_name : str | None = Column (String )
6465 table_name : str = Column (String )
65- object_type : str | None = Column (String )
66+ object_type : ObjectType | None = Column (String )
6667 column_ct : int | None = Column (BigInteger )
6768 record_ct : int | None = Column (BigInteger )
6869 approx_record_ct : int | None = Column (BigInteger )
Original file line number Diff line number Diff line change 1212pytestmark = pytest .mark .unit
1313
1414
15- @pytest .mark .parametrize ("flavor" , ["mssql" , "postgresql" ])
16- def test_sampleable_restricted_to_physical_where_clause_rejects_views (flavor ):
17- # Verified live: TABLESAMPLE errors on a view for these flavors, so only physical
18- # relations are sampleable; views/external/other are profiled in full.
19- assert get_flavor_service (flavor ).sampleable_object_types == {
15+ # Verified live: TABLESAMPLE errors on a view for these flavors, so only physical relations
16+ # are sampleable; views/external/other are profiled in full.
17+ def test_mssql_samples_only_base_tables ():
18+ # SQL Server has no materialized views, so the sampleable set is just base tables.
19+ assert get_flavor_service ("mssql" ).sampleable_object_types == {ObjectType .TABLE }
20+
21+
22+ def test_postgresql_samples_tables_and_materialized_views ():
23+ assert get_flavor_service ("postgresql" ).sampleable_object_types == {
2024 ObjectType .TABLE ,
2125 ObjectType .MATERIALIZED_VIEW ,
2226 }
You can’t perform that action at this time.
0 commit comments