StarRocks / starrocks

StarRocks, a Linux Foundation project, is a next-generation sub-second MPP OLAP database for full analytics scenarios, including multi-dimensional analytics, real-time analytics, and ad-hoc queries.
https://starrocks.io
Apache License 2.0
8.38k stars 1.69k forks source link

"IndexError: no such group" in python driver when using with superset and partitionned tables #45149

Open renaudk opened 2 months ago

renaudk commented 2 months ago

Steps to reproduce the behavior (Required)

  1. Create a partitionned table with primary key

    CREATE TABLE IF NOT EXISTS mydata (
    id BIGINT,
    created_on DATETIME
    )
    ENGINE=OLAP
    PRIMARY KEY(`id`, `created_on`)
    PARTITION BY date_trunc('year', `created_on`)
    DISTRIBUTED BY HASH(`id`, `created_on`);
  2. Try to add dataset in superset

Expected behavior (Required)

Should work

Real behavior (Required)

Superset show error: An Error Occurred - Unable to load columns for the selected table. Please select a different table. superset-error

Output:

2024-05-06 16:39:43,982:ERROR:flask_appbuilder.api:no such group
Traceback (most recent call last):
  File "/root/venv/lib/python3.10/site-packages/flask_appbuilder/api/__init__.py", line 110, in wraps
    return f(self, *args, **kwargs)
  File "/root/venv/lib/python3.10/site-packages/superset/views/base_api.py", line 127, in wraps
    raise ex
  File "/root/venv/lib/python3.10/site-packages/superset/views/base_api.py", line 121, in wraps
    duration, response = time_function(f, self, *args, **kwargs)
  File "/root/venv/lib/python3.10/site-packages/superset/utils/core.py", line 1463, in time_function
    response = func(*args, **kwargs)
  File "/root/venv/lib/python3.10/site-packages/superset/utils/log.py", line 255, in wrapper
    value = f(*args, **kwargs)
  File "/root/venv/lib/python3.10/site-packages/superset/databases/api.py", line 742, in table_metadata
    table_info = get_table_metadata(database, table_name, schema_name)
  File "/root/venv/lib/python3.10/site-packages/superset/databases/utils.py", line 67, in get_table_metadata
    columns = database.get_columns(table_name, schema_name)
  File "/root/venv/lib/python3.10/site-packages/superset/models/core.py", line 839, in get_columns
    return self.db_engine_spec.get_columns(
  File "/root/venv/lib/python3.10/site-packages/superset/db_engine_specs/base.py", line 1340, in get_columns
    cast(list[SQLAColumnType], inspector.get_columns(table_name, schema))
  File "/root/venv/lib/python3.10/site-packages/sqlalchemy/engine/reflection.py", line 497, in get_columns
    col_defs = self.dialect.get_columns(
  File "<string>", line 2, in get_columns
  File "/root/venv/lib/python3.10/site-packages/sqlalchemy/engine/reflection.py", line 55, in cache
    ret = fn(self, con, *args, **kw)
  File "/root/venv/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/base.py", line 2835, in get_columns
    parsed_state = self._parsed_state_or_create(
  File "/root/venv/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/base.py", line 3085, in _parsed_state_or_create
    return self._setup_parser(
  File "<string>", line 2, in _setup_parser
  File "/root/venv/lib/python3.10/site-packages/sqlalchemy/engine/reflection.py", line 55, in cache
    ret = fn(self, con, *args, **kw)
  File "/root/venv/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/base.py", line 3121, in _setup_parser
    return parser.parse(sql, charset)
  File "/root/venv/lib/python3.10/site-packages/starrocks/reflection.py", line 58, in parse
    self._parse_table_options(re.split(r"\r?\n", show_create.rsplit(') ')[-1]), state)
  File "/root/venv/lib/python3.10/site-packages/starrocks/reflection.py", line 223, in _parse_table_options
    skip_lines = self._parse_partition_desc(lines, index, state)
  File "/root/venv/lib/python3.10/site-packages/starrocks/reflection.py", line 301, in _parse_partition_desc
    state.table_options["%s_%s" % (self.dialect.name, "partition_by")] = m.group("partition")
IndexError: no such group

StarRocks version (Required)

renaudk commented 2 months ago

As a workaround, I tried to comment line 300 & 301 of starrocks/reflection.py and the error has gone. Is there any risk of side effect?

mustafa-qamaruddin commented 6 days ago

Same issue on partitioned tables in superset 4.0.2 and Starrocks Version: 3.3.0

$ pip freeze | grep "starrocks"
starrocks==1.0.6
jaogoy commented 6 days ago

As a workaround, I tried to comment line 300 & 301 of starrocks/reflection.py and the error has gone. Is there any risk of side effect?

Do you know the cause, and can you fix it? What't the error message in FE or BE?