From 56ad56c8128ae25a9a60e9d8331dd424f0fc553c Mon Sep 17 00:00:00 2001 From: Hassan Ouda Date: Thu, 25 May 2023 21:19:17 -0400 Subject: [PATCH] Support bigquery dialect - SQL (#5261) # Your PR Title (What it does) Adding an if statement to deal with bigquery sql dialect. When I use bigquery dialect before, it failed while using SET search_path TO. So added a condition to set dataset as the schema parameter which is equivalent to SET search_path TO . I have tested and it works. ## Who can review? Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested: @dev2049 --- langchain/sql_database.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/langchain/sql_database.py b/langchain/sql_database.py index f47273eb..24bf475b 100644 --- a/langchain/sql_database.py +++ b/langchain/sql_database.py @@ -329,6 +329,8 @@ class SQLDatabase: connection.exec_driver_sql( f"ALTER SESSION SET search_path='{self._schema}'" ) + elif self.dialect == "bigquery": + connection.exec_driver_sql(f"SET @@dataset_id='{self._schema}'") else: connection.exec_driver_sql(f"SET search_path TO {self._schema}") cursor = connection.execute(text(command))