@@ -58,13 +58,6 @@ def _gfql_otel_attrs(
5858
5959
6060def detect_query_type (query : Any ) -> QueryType :
61- """Detect query type for policy context.
62-
63- Returns:
64- 'dag' for ASTLet queries
65- 'chain' for list/Chain queries
66- 'single' for single ASTObject queries
67- """
6861 if isinstance (query , ASTLet ):
6962 return "dag"
7063 elif isinstance (query , (list , Chain )):
@@ -218,30 +211,24 @@ def policy(context: PolicyContext) -> None:
218211 # Dict → DAG execution (convenience)
219212 g.gfql({'people': n({'type': 'person'})})
220213 """
221- # Create ExecutionContext at start
222214 context = ExecutionContext ()
223215
224- # Recursion prevention - check if we're already in a policy execution
225216 if policy and context .policy_depth >= 1 :
226217 logger .debug ('Policy disabled due to recursion depth limit (depth=%d)' , context .policy_depth )
227- policy = None # Disable policy for recursive calls
218+ policy = None
228219
229- # Set depth for this execution
230220 policy_depth = context .policy_depth
231221 if policy :
232222 context .policy_depth = policy_depth + 1
233223
234- # Expand policy shortcuts to full hook names (e.g., 'pre' → all pre* hooks)
235224 expanded_policy : Optional [PolicyDict ] = None
236225 if policy :
237226 expanded_policy = expand_policy (policy )
238227
239228 try :
240- # Get current execution depth (0 for top-level)
241229 current_depth = context .execution_depth
242230 current_path = context .operation_path
243231
244- # Preload policy phase - before any processing
245232 if expanded_policy and 'preload' in expanded_policy :
246233 policy_context : PolicyContext = {
247234 'phase' : 'preload' ,
@@ -256,16 +243,12 @@ def policy(context: PolicyContext) -> None:
256243 }
257244
258245 try :
259- # Policy can only accept (None) or deny (exception)
260246 expanded_policy ['preload' ](policy_context )
261-
262247 except PolicyException as e :
263- # Enrich exception with context if not already set
264248 if e .query_type is None :
265249 e .query_type = policy_context .get ('query_type' )
266250 raise
267251
268- # Handle dict convenience first
269252 if isinstance (query , dict ) and "chain" in query :
270253 chain_items : List [ASTObject ] = []
271254 for item in query ["chain" ]:
@@ -279,7 +262,6 @@ def policy(context: PolicyContext) -> None:
279262 where_meta = parse_where_json (query .get ("where" ))
280263 query = Chain (chain_items , where = where_meta )
281264 elif isinstance (query , dict ):
282- # Auto-wrap ASTNode and ASTEdge values in Chain for GraphOperation compatibility
283265 wrapped_dict = {}
284266 for key , value in query .items ():
285267 if isinstance (value , (ASTNode , ASTEdge )):
@@ -289,16 +271,12 @@ def policy(context: PolicyContext) -> None:
289271 wrapped_dict [key ] = value
290272 query = ASTLet (wrapped_dict ) # type: ignore
291273
292- # Push execution depth and operation path before dispatching
293- # This moves us from depth 0 (gfql entry) to depth 1 (chain/let execution)
294274 context .push_depth ()
295275
296- # Determine query type segment for operation path
297276 query_segment = 'dag' if isinstance (query , ASTLet ) else 'chain'
298277 context .push_path (query_segment )
299278
300279 try :
301- # Dispatch based on type - check specific types before generic
302280 if isinstance (query , ASTLet ):
303281 logger .debug ('GFQL executing as DAG' )
304282 return chain_let_impl (self , query , engine , output , policy = expanded_policy , context = context )
@@ -308,7 +286,6 @@ def policy(context: PolicyContext) -> None:
308286 logger .warning ('output parameter ignored for chain queries' )
309287 return _chain_dispatch (self , query , engine , expanded_policy , context )
310288 elif isinstance (query , ASTObject ):
311- # Single ASTObject -> execute as single-item chain
312289 logger .debug ('GFQL executing single ASTObject as chain' )
313290 if output is not None :
314291 logger .warning ('output parameter ignored for chain queries' )
@@ -318,7 +295,6 @@ def policy(context: PolicyContext) -> None:
318295 if output is not None :
319296 logger .warning ('output parameter ignored for chain queries' )
320297
321- # Convert any dictionaries in the list to AST objects
322298 converted_query : List [ASTObject ] = []
323299 for item in query :
324300 if isinstance (item , dict ):
@@ -334,11 +310,9 @@ def policy(context: PolicyContext) -> None:
334310 f"Got { type (query ).__name__ } "
335311 )
336312 finally :
337- # Pop execution depth and operation path when returning
338313 context .pop_depth ()
339314 context .pop_path ()
340315 finally :
341- # Reset policy depth
342316 if policy :
343317 context .policy_depth = policy_depth
344318
@@ -350,9 +324,6 @@ def _chain_dispatch(
350324 policy : Optional [PolicyDict ],
351325 context : ExecutionContext ,
352326) -> Plottable :
353- """Dispatch chain execution, using same-path executor for WHERE clauses."""
354-
355- # Use same-path Yannakakis executor for ANY engine with WHERE clause
356327 if chain_obj .where :
357328 is_cudf = engine == EngineAbstract .CUDF or engine == "cudf"
358329 engine_enum = Engine .CUDF if is_cudf else Engine .PANDAS
0 commit comments