@@ -503,7 +503,7 @@ def __init__(
503503 config : SessionConfig | None = None ,
504504 runtime : RuntimeEnvBuilder | None = None ,
505505 * ,
506- auto_register_python_objects : bool | None = None ,
506+ auto_register_python_objects : bool = True ,
507507 ) -> None :
508508 """Main interface for executing queries with DataFusion.
509509
@@ -516,10 +516,7 @@ def __init__(
516516 runtime: Runtime configuration options.
517517 auto_register_python_objects: Automatically register referenced
518518 Python objects (such as pandas or PyArrow data) when ``sql``
519- queries reference them by name. When omitted, this defaults to
520- the value configured via
521- :py:meth:`~datafusion.SessionConfig.with_python_table_lookup`
522- (``False`` unless explicitly enabled).
519+ queries reference them by name.
523520
524521 Example usage:
525522
@@ -535,12 +532,6 @@ def __init__(
535532 config .config_internal if config is not None else None ,
536533 runtime .config_internal if runtime is not None else None ,
537534 )
538-
539- if auto_register_python_objects is None :
540- auto_register_python_objects = getattr (
541- config , "_python_table_lookup" , False
542- )
543-
544535 self ._auto_python_table_lookup = auto_register_python_objects
545536
546537 def __repr__ (self ) -> str :
@@ -569,18 +560,18 @@ def enable_url_table(self) -> SessionContext:
569560 obj = klass .__new__ (klass )
570561 obj .ctx = self .ctx .enable_url_table ()
571562 obj ._auto_python_table_lookup = getattr (
572- self , "_auto_python_table_lookup" , False
563+ self , "_auto_python_table_lookup" , True
573564 )
574565 return obj
575566
576567 def set_python_table_lookup (self , enabled : bool = True ) -> SessionContext :
577568 """Enable or disable automatic registration of Python objects in SQL.
578569
579570 Args:
580- enabled: When ``True``, SQL queries automatically attempt to
581- resolve missing table names by looking up Python objects in the
582- caller's scope. Use ``False`` to require explicit registration
583- of any referenced tables .
571+ enabled: When ``True`` (default) , SQL queries automatically attempt
572+ to resolve missing table names by looking up Python objects in
573+ the caller's scope. When ``False``, missing tables will raise an
574+ error unless they have been explicitly registered .
584575
585576 Returns:
586577 The current :py:class:`SessionContext` instance for chaining.
@@ -662,7 +653,7 @@ def _execute_sql() -> DataFrame:
662653 try :
663654 return _execute_sql ()
664655 except Exception as err :
665- if not getattr (self , "_auto_python_table_lookup" , False ):
656+ if not getattr (self , "_auto_python_table_lookup" , True ):
666657 raise
667658
668659 missing_tables = self ._extract_missing_table_names (err )
0 commit comments