@@ -735,9 +735,51 @@ def get_data_path(
735735 return tmp_file.name
736736
737737
738- # =============================================================================
739- # Utility functions for processing input data (shared by preview() and Validate class)
740- # =============================================================================
738+ def _process_data(data: FrameT | Any) -> FrameT | Any:
739+ """
740+ Centralized data processing pipeline that handles all supported input types.
741+
742+ This function consolidates the data processing pipeline used across multiple
743+ classes and functions in Pointblank. It processes data through a consistent
744+ sequence of transformations to handle different data source types.
745+
746+ The processing order is important:
747+
748+ 1. GitHub URLs (must come before connection string processing)
749+ 2. Database connection strings
750+ 3. CSV file paths
751+ 4. Parquet file paths
752+
753+ Parameters
754+ ----------
755+ data : FrameT | Any
756+ The input data which could be:
757+ - a DataFrame object (Polars, Pandas, Ibis, etc.)
758+ - a GitHub URL pointing to a CSV or Parquet file
759+ - a database connection string (e.g., "duckdb:///path/to/file.ddb::table_name")
760+ - a CSV file path (string or Path object with .csv extension)
761+ - a Parquet file path, glob pattern, directory, or partitioned dataset
762+ - any other data type (returned unchanged)
763+
764+ Returns
765+ -------
766+ FrameT | Any
767+ Processed data as a DataFrame if input was a supported data source type,
768+ otherwise the original data unchanged.
769+ """
770+ # Handle GitHub URL input (e.g., "https://github.com/user/repo/blob/main/data.csv")
771+ data = _process_github_url(data)
772+
773+ # Handle connection string input (e.g., "duckdb:///path/to/file.ddb::table_name")
774+ data = _process_connection_string(data)
775+
776+ # Handle CSV file input (e.g., "data.csv" or Path("data.csv"))
777+ data = _process_csv_input(data)
778+
779+ # Handle Parquet file input (e.g., "data.parquet", "data/*.parquet", "data/")
780+ data = _process_parquet_input(data)
781+
782+ return data
741783
742784
743785def _process_github_url(data: FrameT | Any) -> FrameT | Any:
@@ -1321,17 +1363,7 @@ def preview(
13211363 """
13221364
13231365 # Process input data to handle different data source types
1324- # Handle GitHub URL input (e.g., "https://github.com/user/repo/blob/main/data.csv")
1325- data = _process_github_url(data)
1326-
1327- # Handle connection string input (e.g., "duckdb:///path/to/file.ddb::table_name")
1328- data = _process_connection_string(data)
1329-
1330- # Handle CSV file input (e.g., "data.csv" or Path("data.csv"))
1331- data = _process_csv_input(data)
1332-
1333- # Handle Parquet file input (e.g., "data.parquet", "data/*.parquet", "data/")
1334- data = _process_parquet_input(data)
1366+ data = _process_data(data)
13351367
13361368 if incl_header is None:
13371369 incl_header = global_config.preview_incl_header
@@ -1816,17 +1848,7 @@ def missing_vals_tbl(data: FrameT | Any) -> GT:
18161848 """
18171849
18181850 # Process input data to handle different data source types
1819- # Handle GitHub URL input (e.g., "https://github.com/user/repo/blob/main/data.csv")
1820- data = _process_github_url(data)
1821-
1822- # Handle connection string input (e.g., "duckdb:///path/to/file.ddb::table_name")
1823- data = _process_connection_string(data)
1824-
1825- # Handle CSV file input (e.g., "data.csv" or Path("data.csv"))
1826- data = _process_csv_input(data)
1827-
1828- # Handle Parquet file input (e.g., "data.parquet", "data/*.parquet", "data/")
1829- data = _process_parquet_input(data)
1851+ data = _process_data(data)
18301852
18311853 # Make a copy of the data to avoid modifying the original
18321854 data = copy.deepcopy(data)
@@ -2431,14 +2453,7 @@ def get_column_count(data: FrameT | Any) -> int:
24312453
24322454 # Process different input types
24332455 if isinstance(data, str) or isinstance(data, Path):
2434- # Process GitHub URLs first
2435- data = _process_github_url(data)
2436- # Handle connection string input
2437- data = _process_connection_string(data)
2438- # Handle CSV file input
2439- data = _process_csv_input(data)
2440- # Handle Parquet file input
2441- data = _process_parquet_input(data)
2456+ data = _process_data(data)
24422457 elif isinstance(data, list):
24432458 # Handle list of file paths (likely Parquet files)
24442459 data = _process_parquet_input(data)
@@ -2607,14 +2622,7 @@ def get_row_count(data: FrameT | Any) -> int:
26072622
26082623 # Process different input types
26092624 if isinstance(data, str) or isinstance(data, Path):
2610- # Process GitHub URLs first
2611- data = _process_github_url(data)
2612- # Handle connection string input
2613- data = _process_connection_string(data)
2614- # Handle CSV file input
2615- data = _process_csv_input(data)
2616- # Handle Parquet file input
2617- data = _process_parquet_input(data)
2625+ data = _process_data(data)
26182626 elif isinstance(data, list):
26192627 # Handle list of file paths (likely Parquet files)
26202628 data = _process_parquet_input(data)
@@ -3550,17 +3558,8 @@ def send_report():
35503558 locale: str | None = None
35513559
35523560 def __post_init__(self):
3553- # Handle GitHub URL input for the data parameter
3554- self.data = _process_github_url(self.data)
3555-
3556- # Handle connection string input for the data parameter
3557- self.data = _process_connection_string(self.data)
3558-
3559- # Handle CSV file input for the data parameter
3560- self.data = _process_csv_input(self.data)
3561-
3562- # Handle Parquet file input for the data parameter
3563- self.data = _process_parquet_input(self.data)
3561+ # Process data through the centralized data processing pipeline
3562+ self.data = _process_data(self.data)
35643563
35653564 # Check input of the `thresholds=` argument
35663565 _check_thresholds(thresholds=self.thresholds)
0 commit comments