@@ -295,7 +295,7 @@ def __init__(self) -> None:
295295
296296
297297def test_sql_auto_register_arrow_table ():
298- ctx = SessionContext (auto_register_python_variables = True )
298+ ctx = SessionContext (auto_register_python_objects = True )
299299 arrow_table = pa .Table .from_pydict ({"value" : [1 , 2 , 3 ]}) # noqa: F841
300300
301301 result = ctx .sql (
@@ -326,9 +326,7 @@ def test_sql_auto_register_multiple_tables_single_query():
326326 ).collect ()
327327
328328 actual = pa .Table .from_batches (result )
329- expected = pa .Table .from_pydict (
330- {"customer_id" : [1 , 2 ], "order_id" : [100 , 200 ]}
331- )
329+ expected = pa .Table .from_pydict ({"customer_id" : [1 , 2 ], "order_id" : [100 , 200 ]})
332330
333331 assert actual .equals (expected )
334332 assert ctx .table_exist ("customers" )
@@ -337,7 +335,7 @@ def test_sql_auto_register_multiple_tables_single_query():
337335
338336def test_sql_auto_register_arrow_outer_scope ():
339337 ctx = SessionContext ()
340- ctx .auto_register_python_variables = True
338+ ctx .set_python_table_lookup ( True )
341339 arrow_table = pa .Table .from_pydict ({"value" : [1 , 2 , 3 , 4 ]}) # noqa: F841
342340
343341 def run_query ():
@@ -365,7 +363,7 @@ def run_query():
365363
366364def test_sql_auto_register_case_insensitive_lookup ():
367365 ctx = SessionContext (auto_register_python_objects = True )
368- MyTable = pa .Table .from_pydict ({"value" : [2 , 3 ]}) # noqa: F841
366+ MyTable = pa .Table .from_pydict ({"value" : [2 , 3 ]}) # noqa: N806, F841
369367
370368 batches = ctx .sql (
371369 "SELECT SUM(value) AS total FROM mytable" ,
@@ -377,7 +375,7 @@ def test_sql_auto_register_case_insensitive_lookup():
377375def test_sql_auto_register_pandas_dataframe ():
378376 pd = pytest .importorskip ("pandas" )
379377
380- ctx = SessionContext (auto_register_python_variables = True )
378+ ctx = SessionContext (auto_register_python_objects = True )
381379 pandas_df = pd .DataFrame ({"value" : [1 , 2 , 3 , 4 ]}) # noqa: F841
382380
383381 result = ctx .sql (
@@ -411,7 +409,7 @@ def test_sql_auto_register_refreshes_reassigned_dataframe():
411409def test_sql_auto_register_polars_dataframe ():
412410 pl = pytest .importorskip ("polars" )
413411
414- ctx = SessionContext (auto_register_python_variables = True )
412+ ctx = SessionContext (auto_register_python_objects = True )
415413 polars_df = pl .DataFrame ({"value" : [2 , 4 , 6 ]}) # noqa: F841
416414
417415 result = ctx .sql (
@@ -421,39 +419,6 @@ def test_sql_auto_register_polars_dataframe():
421419 assert result [0 ].column (0 ).to_pylist ()[0 ] == 2
422420
423421
424- def test_session_context_constructor_alias_disables_lookup ():
425- with pytest .deprecated_call ():
426- ctx = SessionContext (auto_register_python_variables = False )
427-
428- arrow_table = pa .Table .from_pydict ({"value" : [1 , 2 , 3 ]}) # noqa: F841
429-
430- with pytest .raises (Exception , match = "not found|No table named" ):
431- ctx .sql ("SELECT * FROM arrow_table" ).collect ()
432-
433- with pytest .deprecated_call ():
434- assert ctx .auto_register_python_variables is False
435-
436-
437- def test_session_context_property_alias_setter_enables_lookup ():
438- ctx = SessionContext (auto_register_python_objects = False )
439- arrow_table = pa .Table .from_pydict ({"value" : [1 , 2 , 3 ]}) # noqa: F841
440-
441- with pytest .raises (Exception , match = "not found|No table named" ):
442- ctx .sql ("SELECT COUNT(*) FROM arrow_table" ).collect ()
443-
444- with pytest .deprecated_call ():
445- ctx .auto_register_python_variables = True
446-
447- result = ctx .sql (
448- "SELECT SUM(value) AS total FROM arrow_table" ,
449- ).collect ()
450-
451- assert result [0 ].column (0 ).to_pylist ()[0 ] == 6
452-
453- with pytest .deprecated_call ():
454- assert ctx .auto_register_python_variables is True
455-
456-
457422def test_from_pydict (ctx ):
458423 # create a dataframe from Python dictionary
459424 data = {"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]}
@@ -486,7 +451,7 @@ def test_from_pandas(ctx):
486451
487452def test_sql_from_local_arrow_table (ctx ):
488453 ctx .set_python_table_lookup (True ) # Enable implicit table lookup
489- arrow_table = pa .Table .from_pydict ({"a" : [1 , 2 ], "b" : ["x" , "y" ]})
454+ arrow_table = pa .Table .from_pydict ({"a" : [1 , 2 ], "b" : ["x" , "y" ]}) # noqa: F841
490455
491456 result = ctx .sql ("SELECT * FROM arrow_table ORDER BY a" ).collect ()
492457 actual = pa .Table .from_batches (result )
@@ -498,7 +463,7 @@ def test_sql_from_local_arrow_table(ctx):
498463def test_sql_from_local_pandas_dataframe (ctx ):
499464 ctx .set_python_table_lookup (True ) # Enable implicit table lookup
500465 pd = pytest .importorskip ("pandas" )
501- pandas_df = pd .DataFrame ({"a" : [3 , 1 ], "b" : ["z" , "y" ]})
466+ pandas_df = pd .DataFrame ({"a" : [3 , 1 ], "b" : ["z" , "y" ]}) # noqa: F841
502467
503468 result = ctx .sql ("SELECT * FROM pandas_df ORDER BY a" ).collect ()
504469 actual = pa .Table .from_batches (result )
@@ -510,7 +475,7 @@ def test_sql_from_local_pandas_dataframe(ctx):
510475def test_sql_from_local_polars_dataframe (ctx ):
511476 ctx .set_python_table_lookup (True ) # Enable implicit table lookup
512477 pl = pytest .importorskip ("polars" )
513- polars_df = pl .DataFrame ({"a" : [2 , 1 ], "b" : ["beta" , "alpha" ]})
478+ polars_df = pl .DataFrame ({"a" : [2 , 1 ], "b" : ["beta" , "alpha" ]}) # noqa: F841
514479
515480 result = ctx .sql ("SELECT * FROM polars_df ORDER BY a" ).collect ()
516481 actual = pa .Table .from_batches (result )
@@ -520,7 +485,7 @@ def test_sql_from_local_polars_dataframe(ctx):
520485
521486
522487def test_sql_from_local_unsupported_object (ctx ):
523- unsupported = object ()
488+ unsupported = object () # noqa: F841
524489
525490 with pytest .raises (Exception , match = "table 'unsupported' not found" ):
526491 ctx .sql ("SELECT * FROM unsupported" ).collect ()
@@ -876,7 +841,7 @@ def test_sql_with_options_no_statements(ctx):
876841def test_session_config_python_table_lookup_enables_auto_registration ():
877842 pd = pytest .importorskip ("pandas" )
878843
879- ctx = SessionContext (config = SessionConfig ().with_python_table_lookup (True ))
844+ ctx = SessionContext (config = SessionConfig ().with_python_table_lookup (enabled = True ))
880845 pdf = pd .DataFrame ({"value" : [1 , 2 , 3 ]})
881846 assert len (pdf ) == 3
882847
0 commit comments