You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
how to get full result of the sql() function #1795
when the result is larger than 10 rows, it is truncated
>>>fromdatafusionimportSessionContext>>>importtime>>>ctx=SessionContext()
>>>ctx.sql("create table item as select i%7 i_category, i%11 i_color from (select value i from generate_series(1,10000\00))")
Nodatatodisplay>>>t=time.time();df=ctx.sql("select i_color, count(distinct i_color) from item group by i_color");t=time.time()-t>>>print(df)
DataFrame()
+---------+------------------------------+|i_color|count(DISTINCTitem.i_color) |+---------+------------------------------+|5|1||1|1||10|1||9|1||2|1||4|1||7|1||3|1||8|1||6|1|+---------+------------------------------+Datatruncated.
print(df) only shows a preview (the first 10 rows by default), so "Data truncated." doesn't mean the result is incomplete. I checked these options with datafusion 55.0.0 (Python 3.13, Linux) using your table:
# 1. print more rows (default num=20)df.show(num=100)
# 2. raise the limit used by print(df) / reprfromdatafusion.dataframe_formatterimportconfigure_formatterconfigure_formatter(max_rows=50)
print(df) # all 11 rows, no "Data truncated."# 3. get the full result as data instead of a printoutdf.to_pandas() # needs pandasdf.to_pylist() # list of dicts (11 rows here)df.collect() # list of pyarrow RecordBatchesdf.to_arrow_table()
configure_formatter applies to every DataFrame for the rest of the session. reset_formatter() from the same module restores the defaults.
One thing to watch for: print(df) and df.show() run the query each time. If you want to look at the result more than once, convert it once (for example pdf = df.to_pandas()), or use df.cache() to keep it in memory.
Activity
mohamd764 commentedon Oct 16, 2026
print(df)only shows a preview (the first 10 rows by default), so "Data truncated." doesn't mean the result is incomplete. I checked these options with datafusion 55.0.0 (Python 3.13, Linux) using your table:configure_formatterapplies to every DataFrame for the rest of the session.reset_formatter()from the same module restores the defaults.One thing to watch for:
print(df)anddf.show()run the query each time. If you want to look at the result more than once, convert it once (for examplepdf = df.to_pandas()), or usedf.cache()to keep it in memory.l1t1 commentedon Oct 16, 2026
Thanks @mohamd764