from risingwave import OutputFormat
result: pd.DataFrame = rw.fetch("""
SELECT window_start, window_end, product, ROUND(avg(price)) as avg_price
FROM tumble(test, ts, interval '10 seconds')
GROUP BY window_start, window_end, product""",
format=OutputFormat.DATAFRAME)
print(result)
# Output:
# window_start window_end product avg_price
# 0 2023-10-05 14:31:20 2023-10-05 14:31:30 bar 457.0
# 1 2023-10-05 14:30:00 2023-10-05 14:30:10 foo 123.0
# You can also use OutputFormat.RAW to get back list of tuples as the query results
# rw.fetch("...", format=OutputFormat.RAW)
# [(datetime.datetime(2023, 10, 5, 14, 31, 20), datetime.datetime(2023, 10, 5, 14, 31, 30), 'bar', 457.0),
# (datetime.datetime(2023, 10, 5, 14, 30), datetime.datetime(2023, 10, 5, 14, 30, 10), 'foo', 123.0)]