@@ -228,6 +228,33 @@ Core Classes
228228 * :py:meth: `~datafusion.SessionContext.from_pandas ` - Create from Pandas DataFrame
229229 * :py:meth: `~datafusion.SessionContext.from_arrow ` - Create from Arrow data
230230
231+ ``SessionContext `` can automatically resolve SQL table names that match
232+ in-scope Python data objects. When automatic lookup is enabled, a query
233+ such as ``ctx.sql("SELECT * FROM pdf") `` will register a pandas or
234+ PyArrow object named ``pdf `` without calling
235+ :py:meth: `~datafusion.SessionContext.from_pandas ` or
236+ :py:meth: `~datafusion.SessionContext.from_arrow ` explicitly. This requires
237+ the corresponding library (``pandas `` for pandas objects, ``pyarrow `` for
238+ Arrow objects) to be installed.
239+
240+ .. code-block :: python
241+
242+ import pandas as pd
243+ from datafusion import SessionContext
244+
245+ ctx = SessionContext(auto_register_python_objects = True )
246+ pdf = pd.DataFrame({" value" : [1 , 2 , 3 ]})
247+
248+ df = ctx.sql(" SELECT SUM(value) AS total FROM pdf" )
249+ print (df.to_pandas()) # automatically registers `pdf`
250+
251+ Automatic lookup is disabled by default. Enable it by passing
252+ ``auto_register_python_objects=True `` when constructing the session or by
253+ configuring :py:class: `~datafusion.SessionConfig ` with
254+ :py:meth: `~datafusion.SessionConfig.with_python_table_lookup `. Use
255+ :py:meth: `~datafusion.SessionContext.set_python_table_lookup ` to toggle the
256+ behaviour at runtime.
257+
231258 See: :py:class: `datafusion.SessionContext `
232259
233260Expression Classes
0 commit comments