SQLDatabaseChain - Questions/error
Labels: name: bug, name: question

### System Info

While trying to run example from https://python.langchain.com/docs/modules/chains/popular/sqlite I get the following error:



````
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[42], line 1
----> 1 db_chain.run("What is the expected assisted goals by Erling Haaland")

File ~/.local/lib/python3.10/site-packages/langchain/chains/base.py:273, in Chain.run(self, callbacks, tags, *args, **kwargs)
    271     if len(args) != 1:
    272         raise ValueError("`run` supports only one positional argument.")
--> 273     return self(args[0], callbacks=callbacks, tags=tags)[_output_key]
    275 if kwargs and not args:
    276     return self(kwargs, callbacks=callbacks, tags=tags)[_output_key]

File ~/.local/lib/python3.10/site-packages/langchain/chains/base.py:149, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, include_run_info)
    147 except (KeyboardInterrupt, Exception) as e:
    148     run_manager.on_chain_error(e)
--> 149     raise e
    150 run_manager.on_chain_end(outputs)
    151 final_outputs: Dict[str, Any] = self.prep_outputs(
    152     inputs, outputs, return_only_outputs
    153 )

File ~/.local/lib/python3.10/site-packages/langchain/chains/base.py:143, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, include_run_info)
    137 run_manager = callback_manager.on_chain_start(
    138     dumpd(self),
    139     inputs,
    140 )
    141 try:
    142     outputs = (
--> 143         self._call(inputs, run_manager=run_manager)
    144         if new_arg_supported
    145         else self._call(inputs)
    146     )
    147 except (KeyboardInterrupt, Exception) as e:
    148     run_manager.on_chain_error(e)

File ~/.local/lib/python3.10/site-packages/langchain/chains/sql_database/base.py:105, in SQLDatabaseChain._call(self, inputs, run_manager)
    103 # If not present, then defaults to None which is all tables.
    104 table_names_to_use = inputs.get("table_names_to_use")
--> 105 table_info = self.database.get_table_info(table_names=table_names_to_use)
    106 llm_inputs = {
    107     "input": input_text,
    108     "top_k": str(self.top_k),
   (...)
    111     "stop": ["\nSQLResult:"],
    112 }
    113 intermediate_steps: List = []

File ~/.local/lib/python3.10/site-packages/langchain/sql_database.py:289, in SQLDatabase.get_table_info(self, table_names)
    287     table_info += f"\n{self._get_table_indexes(table)}\n"
    288 if self._sample_rows_in_table_info:
--> 289     table_info += f"\n{self._get_sample_rows(table)}\n"
    290 if has_extra_info:
    291     table_info += "*/"

File ~/.local/lib/python3.10/site-packages/langchain/sql_database.py:311, in SQLDatabase._get_sample_rows(self, table)
    308 try:
    309     # get the sample rows
    310     with self._engine.connect() as connection:
--> 311         sample_rows_result = connection.execute(command)  # type: ignore
    312         # shorten values in the sample rows
    313         sample_rows = list(
    314             map(lambda ls: [str(i)[:100] for i in ls], sample_rows_result)
    315         )

File /opt/conda/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1413, in Connection.execute(self, statement, parameters, execution_options)
   1411     raise exc.ObjectNotExecutableError(statement) from err
   1412 else:
-> 1413     return meth(
   1414         self,
   1415         distilled_parameters,
   1416         execution_options or NO_OPTIONS,
   1417     )

File /opt/conda/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:483, in ClauseElement._execute_on_connection(self, connection, distilled_params, execution_options)
    481     if TYPE_CHECKING:
    482         assert isinstance(self, Executable)
--> 483     return connection._execute_clauseelement(
    484         self, distilled_params, execution_options
    485     )
    486 else:
    487     raise exc.ObjectNotExecutableError(self)

File /opt/conda/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1629, in Connection._execute_clauseelement(self, elem, distilled_parameters, execution_options)
   1621 schema_translate_map = execution_options.get(
   1622     "schema_translate_map", None
   1623 )
   1625 compiled_cache: Optional[CompiledCacheType] = execution_options.get(
   1626     "compiled_cache", self.engine._compiled_cache
   1627 )
-> 1629 compiled_sql, extracted_params, cache_hit = elem._compile_w_cache(
   1630     dialect=dialect,
   1631     compiled_cache=compiled_cache,
   1632     column_keys=keys,
   1633     for_executemany=for_executemany,
   1634     schema_translate_map=schema_translate_map,
   1635     linting=self.dialect.compiler_linting | compiler.WARN_LINTING,
   1636 )
   1637 ret = self._execute_context(
   1638     dialect,
   1639     dialect.execution_ctx_cls._init_compiled,
   (...)
   1647     cache_hit=cache_hit,
   1648 )
   1649 if has_events:

File /opt/conda/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:684, in ClauseElement._compile_w_cache(self, dialect, compiled_cache, column_keys, for_executemany, schema_translate_map, **kw)
    682 else:
    683     extracted_params = None
--> 684     compiled_sql = self._compiler(
    685         dialect,
    686         cache_key=elem_cache_key,
    687         column_keys=column_keys,
    688         for_executemany=for_executemany,
    689         schema_translate_map=schema_translate_map,
    690         **kw,
    691     )
    693     if not dialect._supports_statement_cache:
    694         cache_hit = dialect.NO_DIALECT_SUPPORT

File /opt/conda/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:288, in CompilerElement._compiler(self, dialect, **kw)
    286 if TYPE_CHECKING:
    287     assert isinstance(self, ClauseElement)
--> 288 return dialect.statement_compiler(dialect, self, **kw)

File ~/.local/lib/python3.10/site-packages/pybigquery/sqlalchemy_bigquery.py:137, in BigQueryCompiler.__init__(self, dialect, statement, column_keys, inline, **kwargs)
    135 if isinstance(statement, Column):
    136     kwargs['compile_kwargs'] = util.immutabledict({'include_table': False})
--> 137 super(BigQueryCompiler, self).__init__(dialect, statement, column_keys, inline, **kwargs)

TypeError: SQLCompiler.__init__() got multiple values for argument 'cache_key'
````

I use a VertexAI model (MODEL_TEXT_BISON_001) as the LLM.

Some essential library versions:
langchain == 0.0.206
SQLAlchemy == 2.0.11
ipython == 8.12.1
python == 3.10.10
google-cloud-bigquery == 3.10.0
google-cloud-bigquery-storage == 2.16.2


### Who can help?

@hwchase17 

### Information

- [X] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

`db` = SQLDatabase.from_uri(f"bigquery://{project_id}/{dataset}")
toolkit = SQLDatabaseToolkit(llm=llm, db=db)
db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True)
db_chain.run("What is the sport that generates highest revenue")`

### Expected behavior

When running the db_chain, I expect to get an answer from the bigquery database