mistercrunch opened a new pull request, #34522:
URL: https://github.com/apache/superset/pull/34522

   The get_sqla_query method, where the bulk of the SQL-generation logic for 
Explore is in Superset, had grown to over 750 lines, making it difficult to 
understand, maintain, and test. This refactor breaks it down into 12 focused 
helper methods, each with a single responsibility and clear interfaces.
   
   Key improvements:
   - Extracted 12 helper methods with max 4-5 parameters and 1-2 return values
   - Added comprehensive unit tests achieving 100% coverage for new methods
   - Improved code organization with high cohesion and low coupling
   - Enhanced type safety with proper type hints throughout
   - Fixed Flask best practices by using current_app instead of direct import
   - Maintained exact behavior compatibility with original implementation
   
   New helper methods:
   - _build_metric_expression: Builds SQLAlchemy expressions for metrics
   - _process_adhoc_sql_expression: Validates adhoc SQL with template processing
   - _normalize_column_labels: Normalizes labels for database compatibility
   - _build_top_groups_filter: Creates filter expressions for series limits
   - _get_series_orderby_expression: Handles series ordering logic
   - _normalize_filter_value: Type-aware filter value normalization
   - _build_time_filter_expression: Constructs time range filters
   - _wrap_query_for_rowcount: Wraps queries for row counting
   - _create_others_case_expression: Handles "Others" grouping logic
   - _apply_advanced_data_type_filter: Processes advanced data types
   - _apply_orderby_direction: Applies sort directions to queries
   - _deduplicate_select_columns: Removes duplicate SELECT columns
   
   This refactoring improves maintainability without changing functionality, 
making the codebase more approachable for future contributors.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to