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

run_sql_bigquery with invalid query fails with TypeError "exceptions must derive from BaseException" #467

Open
andreaskaltenbach opened this issue May 29, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@andreaskaltenbach
Copy link

Describe the bug
Executing run_sql_bigquery with an invalid SQL query results in a type error.

Example:

vn = VannaDefault(model='chinook', api_key=vanna.get_api_key('[email protected]'))
vn.connect_to_bigquery(cred_file_path="some.json", project_id="my_project")
vn.run_sql("SELECT xyz")

results in TypeError('exceptions must derive from BaseException')

def connect_to_bigquery(self, cred_file_path: str = None, project_id: str = None):
  ...
  try:
      job = conn.query(sql)
      df = job.result().to_dataframe()
      return df
  except GoogleAPIError as error:
      errors = []
      for error in error.errors:
          errors.append(error["message"]) 
      raise errors # errors is a list of strings

Expected behavior
GoogleAPIError should be handled properly and an exceptiobn should be raised instead of a list of strings.

Desktop (please complete the following information where):

  • OS: MacOS
  • Version: 14.4.1
  • Python: 3.12.3
  • Vanna: [2.8.0]

Additional context
Add any other context about the problem here.

@andreaskaltenbach andreaskaltenbach added the bug Something isn't working label May 29, 2024
@Molrn
Copy link
Contributor

Molrn commented May 30, 2024

this was fixed in version 0.4.2, just upgrade your vanna version

@everdark
Copy link
Contributor

everdark commented Jun 13, 2024

I'm using v0.6.0 but still got this error.

@a-brohi
Copy link

a-brohi commented Jun 15, 2024

same; im using vanna==0.6.0 and getting error TypeError: exceptions must derive from BaseException with below code. let me know if you require anything else.

vn = VannaDefault(model=vanna_model_name, api_key=api_key)

vn.connect_to_bigquery(project_id="project_id", cred_file_path="example.json")

_question= "What are the top 5 customers by spend?"
_sql = vn.generate_sql(question = "What are the top 5 customers by spend?")
_df = vn.run_sql(sql= _sql)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants