Skip to content

Confusing error message for invalid query #120

@mneedham

Description

@mneedham

When following the example showing how to query Pandas DataFrames from the README, if I execute an invalid query:

print(ret_tbl.query('select b, sum(a) from __table__ group by'))

Forgetting the column to group by. The error is like this:

Code: 62. DB::Exception: Syntax error: failed at position 109 (end of query): . Expected one of: ROLLUP, CUBE, GROUPING SETS, ALL, not empty list of expressions, list of expressions, list of elements, expression with optional alias, element of expression with optional alias, lambda expression. (SYNTAX_ERROR)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/markhneedham/Library/Caches/pypoetry/virtualenvs/pandas-clickhouse-2MxvpB9Q-py3.11/lib/python3.11/site-packages/chdb/dataframe/query.py", line 112, in __str__
    return str(self.to_pandas())
               ^^^^^^^^^^^^^^^^
  File "/Users/markhneedham/Library/Caches/pypoetry/virtualenvs/pandas-clickhouse-2MxvpB9Q-py3.11/lib/python3.11/site-packages/chdb/dataframe/query.py", line 64, in to_pandas
    return pandas_read_parquet(pq_reader)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/markhneedham/Library/Caches/pypoetry/virtualenvs/pandas-clickhouse-2MxvpB9Q-py3.11/lib/python3.11/site-packages/chdb/dataframe/query.py", line 318, in pandas_read_parquet
    return pd.read_parquet(path)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/markhneedham/Library/Caches/pypoetry/virtualenvs/pandas-clickhouse-2MxvpB9Q-py3.11/lib/python3.11/site-packages/pandas/io/parquet.py", line 670, in read_parquet
    return impl.read(
           ^^^^^^^^^^
  File "/Users/markhneedham/Library/Caches/pypoetry/virtualenvs/pandas-clickhouse-2MxvpB9Q-py3.11/lib/python3.11/site-packages/pandas/io/parquet.py", line 272, in read
    pa_table = self.api.parquet.read_table(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/markhneedham/Library/Caches/pypoetry/virtualenvs/pandas-clickhouse-2MxvpB9Q-py3.11/lib/python3.11/site-packages/pyarrow/parquet/core.py", line 2955, in read_table
    dataset = _ParquetDatasetV2(
              ^^^^^^^^^^^^^^^^^^
  File "/Users/markhneedham/Library/Caches/pypoetry/virtualenvs/pandas-clickhouse-2MxvpB9Q-py3.11/lib/python3.11/site-packages/pyarrow/parquet/core.py", line 2495, in __init__
    [fragment], schema=schema or fragment.physical_schema,
                                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "pyarrow/_dataset.pyx", line 1357, in pyarrow._dataset.Fragment.physical_schema.__get__
  File "pyarrow/error.pxi", line 144, in pyarrow.lib.pyarrow_internal_check_status
  File "pyarrow/error.pxi", line 100, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: Could not open Parquet input source '<Buffer>': Parquet file size is 0 bytes

But the error is nothing to do with Parquet, so I think it shouldn't show that as part of the error message.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions