Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception for SimpleAggregateFunction #90

Open
shubhamsinha opened this issue Jun 2, 2023 · 0 comments
Open

Exception for SimpleAggregateFunction #90

shubhamsinha opened this issue Jun 2, 2023 · 0 comments

Comments

@shubhamsinha
Copy link

shubhamsinha commented Jun 2, 2023

Hi there,

I am running a pretty basic query to fetch rows from a Clickhouse table called "core_activity".

async def main():
    async with ClientSession() as s:
        client = ChClient(s, url='http://localhost:8123/',
                          user='default', password='password', database='default')
        alive = await client.is_alive()
        print(f"Is ClickHouse alive? -> {alive}")
        rows = await client.fetch("SELECT * FROM core_activity LIMIT 10")
        print(f"{rows}")

if __name__ == '__main__':
    asyncio.run(main())

The code block above throws the following exception:

Traceback (most recent call last):
  File "aiochclient/_types.pyx", line 688, in aiochclient._types.what_py_type
KeyError: "DateTime64(9, \\'UTC\\')"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/shubham/dev/processmining/process_mining.py", line 373, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/shubham/dev/processmining/process_mining.py", line 369, in main
    rows = await client.fetch("SELECT * FROM core_activity LIMIT 10")
  File "/home/shubham/.local/lib/python3.10/site-packages/aiochclient/client.py", line 265, in fetch
    return [
  File "/home/shubham/.local/lib/python3.10/site-packages/aiochclient/client.py", line 265, in <listcomp>
    return [
  File "/home/shubham/.local/lib/python3.10/site-packages/aiochclient/client.py", line 184, in _execute
    rf = RecordsFabric(
  File "/home/shubham/.local/lib/python3.10/site-packages/aiochclient/records.py", line 91, in __init__
    self.converters = [
  File "/home/shubham/.local/lib/python3.10/site-packages/aiochclient/records.py", line 92, in <listcomp>
    what_py_converter(tp) for tp in tps.decode().strip().split("\t")
  File "aiochclient/_types.pyx", line 693, in aiochclient._types.what_py_converter
  File "aiochclient/_types.pyx", line 695, in aiochclient._types.what_py_converter
  File "aiochclient/_types.pyx", line 690, in aiochclient._types.what_py_type
aiochclient.exceptions.ChClientError: Unrecognized type name: 'SimpleAggregateFunction(anyLast, DateTime64(9, \'UTC\'))'

Here is the definition of the core_activity table for reference:

CREATE TABLE core_activity
(
    `activity_id` SimpleAggregateFunction(anyLast, String),
    `ts` SimpleAggregateFunction(anyLast, DateTime64(9, 'UTC')) CODEC (Delta(8), ZSTD),
    `activity` SimpleAggregateFunction(anyLast, LowCardinality(String)),
    `entity_type` SimpleAggregateFunction(anyLast, LowCardinality(String)),
    `sub_entity_type` SimpleAggregateFunction(anyLast, LowCardinality(String))       DEFAULT '',
    `anonymous_customer_id` SimpleAggregateFunction(anyLast, LowCardinality(String)) DEFAULT '',
    `customer` SimpleAggregateFunction(anyLast, LowCardinality(String)),
    `revenue_impact` SimpleAggregateFunction(anyLast, Decimal(38, 5))                DEFAULT 0,
    `strings` SimpleAggregateFunction(anyLast, Map(String, String)),
    `numbers` SimpleAggregateFunction(anyLast, Map(String, Decimal(38, 5))),
    `bools` SimpleAggregateFunction(anyLast, Map(String, Boolean)),
    `dates` SimpleAggregateFunction(anyLast, Map(String, DateTime64(9, 'UTC'))) CODEC (Delta(8), ZSTD),
    `_p_case_id` SimpleAggregateFunction(anyLast, String),
    `_p_activity` SimpleAggregateFunction(anyLast, String),
    INDEX idx_activity_id activity_id TYPE bloom_filter(0.001) GRANULARITY 1,
    INDEX idx_ts (ts) TYPE minmax GRANULARITY 1,
    INDEX idx_activity activity TYPE bloom_filter(0.001) GRANULARITY 1,
    INDEX idx_entity_type entity_type TYPE bloom_filter(0.001) GRANULARITY 1,
    INDEX idx_customer customer TYPE bloom_filter(0.001) GRANULARITY 1,
    INDEX idx_revenue_impact revenue_impact TYPE minmax GRANULARITY 1,
    INDEX idx_strings_key mapKeys(strings) TYPE bloom_filter(0.01) GRANULARITY 1,
    INDEX idx_string_value mapValues(strings) TYPE bloom_filter(0.01) GRANULARITY 1,
    INDEX idx_numbers_key mapKeys(numbers) TYPE bloom_filter(0.01) GRANULARITY 1,
    INDEX idx_numbers_value mapValues(numbers) TYPE minmax GRANULARITY 1,
    INDEX idx_bools_key mapKeys(bools) TYPE bloom_filter(0.01) GRANULARITY 1,
    INDEX idx_bools_value mapValues(bools) TYPE bloom_filter(0.01) GRANULARITY 1,
    INDEX idx_dates_key mapKeys(dates) TYPE bloom_filter(0.01) GRANULARITY 1,
    INDEX idx_p_case_id _p_case_id TYPE bloom_filter(0.001) GRANULARITY 1,
    INDEX idx_p_activity_id _p_activity TYPE bloom_filter(0.001) GRANULARITY 1
)
    ENGINE = AggregatingMergeTree
        ORDER BY (`activity_id`)
        PARTITION BY toYYYYMM(`ts`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant