Initialize with data source
(self, data_source: XCaptureDataSource, use_materialized: bool = False, duckdb_profiling_mode: Optional[str] = None)
| 87 | } |
| 88 | |
| 89 | def __init__(self, data_source: XCaptureDataSource, use_materialized: bool = False, duckdb_profiling_mode: Optional[str] = None): |
| 90 | """Initialize with data source""" |
| 91 | self.data_source = data_source |
| 92 | self.query_cache = {} |
| 93 | # Get the SQL directory relative to this file |
| 94 | self.template_path = Path(__file__).parent.parent / 'sql' |
| 95 | self.fragments_path = self.template_path / 'fragments' |
| 96 | self.logger = logging.getLogger('xtop.query_engine') |
| 97 | |
| 98 | # Initialize the new query builder |
| 99 | self.query_builder = QueryBuilder( |
| 100 | datadir=data_source.datadir, |
| 101 | fragments_path=self.fragments_path, |
| 102 | use_materialized=use_materialized |
| 103 | ) |
| 104 | |
| 105 | # Initialize materializer |
| 106 | self.materializer = DataMaterializer(data_source.conn, data_source.datadir) |
| 107 | self.use_materialized = use_materialized |
| 108 | # Desired DuckDB profiling mode when debug logging is enabled |
| 109 | # Accepts 'standard', 'query_tree', or 'json' (DuckDB options). Defaults to 'standard'. |
| 110 | self.duckdb_profiling_mode = (duckdb_profiling_mode or 'standard').lower() |
| 111 | |
| 112 | # Cache for schema information |
| 113 | self.schema_cache: Dict[str, List[Tuple[str, str]]] = {} |
| 114 | self._discover_all_schemas() |
| 115 | try: |
| 116 | self.query_builder.set_schema_info(self.data_source.get_schema_info()) |
| 117 | except Exception as exc: |
| 118 | self.logger.warning(f"Failed to share schema info with QueryBuilder: {exc}") |
| 119 | |
| 120 | # Removed load_template method - no longer needed with only dynamic queries |
| 121 |
nothing calls this directly
no test coverage detected