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

Table name already exists #717

Closed
ahuang11 opened this issue Oct 4, 2024 · 4 comments · Fixed by #920
Closed

Table name already exists #717

ahuang11 opened this issue Oct 4, 2024 · 4 comments · Fixed by #920

Comments

@ahuang11
Copy link
Contributor

ahuang11 commented Oct 4, 2024

LLM generated table name could be duplicate of previous and when recreating the eph table, it crashes:

  File "/Users/ahuang/repos/lumen/lumen/ai/assistant.py", line 482, in invoke
    await agent.invoke(messages[-context_length:], **kwargs)
  File "/Users/ahuang/repos/lumen/lumen/ai/agents.py", line 738, in invoke
    sql_query = await self.answer(messages)
  File "/Users/ahuang/repos/lumen/lumen/ai/agents.py", line 734, in answer
    sql_query = await self._create_valid_sql(messages, system, tables_to_source)
  File "/Users/ahuang/repos/lumen/lumen/ai/utils.py", line 47, in async_wrapper
    output = await func(*args, **kwargs)
  File "/Users/ahuang/repos/lumen/lumen/ai/agents.py", line 606, in _create_valid_sql
    raise e
  File "/Users/ahuang/repos/lumen/lumen/ai/agents.py", line 580, in _create_valid_sql
    sql_expr_source = source.create_sql_expr_source({expr_slug: sql_query})
  File "/Users/ahuang/repos/lumen/lumen/sources/duckdb.py", line 232, in create_sql_expr_source
    raise e
  File "/Users/ahuang/repos/lumen/lumen/sources/duckdb.py", line 217, in create_sql_expr_source
    self._connection.execute(table_expr)
duckdb.duckdb.CatalogException: Catalog Error: Table with name "top_5_winter_olympic_games" already exists
@philippjfr
Copy link
Member

Can we agree to record the dataset and prompt that generated a particular error.

@ahuang11
Copy link
Contributor Author

ahuang11 commented Dec 6, 2024

Will close for now; can't reproduce and it should theoretically be handled:


            if table in existing or sql_expr == self.sql_expr.format(table=f'"{table}"'):
                continue

@ahuang11 ahuang11 closed this as completed Dec 6, 2024
@ahuang11
Copy link
Contributor Author

ahuang11 commented Dec 27, 2024

Image

Encountered this again
lumen-ai serve *.csv --log-level debug

Data:
data.zip

Traceback (most recent call last):

  File "/Users/ahuang/repos/lumen/lumen/sources/duckdb.py", line 218, in create_sql_expr_source
    self._connection.execute(table_expr)

duckdb.duckdb.CatalogException: Catalog Error: Table with name "min_max_airfare_values" already exists!


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/Users/ahuang/repos/lumen/lumen/ai/coordinator.py", line 421, in _execute_graph_node
    result = await subagent.respond(
             ^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/ahuang/repos/lumen/lumen/ai/agents.py", line 744, in respond
    sql_query = await self._create_valid_sql(messages, system_prompt, tables_to_source, step_title)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/ahuang/repos/lumen/lumen/ai/utils.py", line 110, in async_wrapper
    raise e

  File "/Users/ahuang/repos/lumen/lumen/ai/utils.py", line 104, in async_wrapper
    output = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/ahuang/repos/lumen/lumen/ai/agents.py", line 580, in _create_valid_sql
    raise e

  File "/Users/ahuang/repos/lumen/lumen/ai/agents.py", line 571, in _create_valid_sql
    sql_expr_source = source.create_sql_expr_source({expr_slug: sql_query})
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/ahuang/repos/lumen/lumen/sources/duckdb.py", line 224, in create_sql_expr_source
    real = self.tables[name] if name in self.tables else self.tables[name.strip('"')]
                                                         ~~~~~~~~~~~^^^^^^^^^^^^^^^^^

KeyError: 'min_max_airfare_values'

@ahuang11 ahuang11 reopened this Dec 27, 2024
@ahuang11
Copy link
Contributor Author

ahuang11 commented Jan 6, 2025

Still encountering this

Image
Traceback (most recent call last):

  File "/Users/ahuang/repos/lumen/lumen/sources/duckdb.py", line 218, in create_sql_expr_source
    self._connection.execute(table_expr)

duckdb.duckdb.CatalogException: Catalog Error: Table with name "average_delay_by_carrier" already exists!


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/Users/ahuang/repos/lumen/lumen/ai/coordinator.py", line 421, in _execute_graph_node
    result = await subagent.respond(
             ^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/ahuang/repos/lumen/lumen/ai/agents.py", line 753, in respond
    sql_query = await self._create_valid_sql(messages, system_prompt, tables_to_source, step_title)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/ahuang/repos/lumen/lumen/ai/utils.py", line 110, in async_wrapper
    raise e

  File "/Users/ahuang/repos/lumen/lumen/ai/utils.py", line 104, in async_wrapper
    output = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/ahuang/repos/lumen/lumen/ai/agents.py", line 587, in _create_valid_sql
    raise e

  File "/Users/ahuang/repos/lumen/lumen/ai/agents.py", line 578, in _create_valid_sql
    sql_expr_source = source.create_sql_expr_source({expr_slug: sql_query})
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/ahuang/repos/lumen/lumen/sources/duckdb.py", line 224, in create_sql_expr_source
    real = self.tables[name] if name in self.tables else self.tables[name.strip('"')]
                                                         ~~~~~~~~~~~^^^^^^^^^^^^^^^^^

KeyError: 'average_delay_by_carrier'

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

Successfully merging a pull request may close this issue.

2 participants