-
I copied it from chdb homepage. but I don't understand why table refers the dataframe
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I tried to rename it to >>> print(ret_tbl.query('select b, sum(a) from __t__ group by b'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/dist-packages/chdb/dataframe/query.py", line 120, in query
self._validate_sql(sql)
File "/usr/local/lib/python3.10/dist-packages/chdb/dataframe/query.py", line 148, in _validate_sql
raise ValueError("SQL should always contain `FROM __table__`")
ValueError: SQL should always contain `FROM __table__` |
Beta Was this translation helpful? Give feedback.
-
If you want to refer ret_tbl.query('select b, sum(a) from __table__ group by b') Otherwise, if you want to query on dataframe vars you can query with cdf.query(sql="select * from __tbl1__ t1 join __tbl2__ t2 on t1.a = t2.c",
tbl1=df1, tbl2=df2) where |
Beta Was this translation helpful? Give feedback.
-
thanks. the syntax of Python module duckdb seems simpler >>> import duckdb as dd
>>> df1=dd.sql("select 1 a").df()
>>> df2=dd.sql("select 2 b union select 3").df()
>>> dd.sql("select * from df1,df2") |
Beta Was this translation helpful? Give feedback.
If you want to refer
ret_tbl
itself, you must use__table__
which is something likeself
Like:
Otherwise, if you want to query on dataframe vars you can query with
where
__tbl1__
refer totbl1
,__tbl2__
refer totbl2