# Issue Initializing BigQuery Datasource in Great Expectations

**URL:** <https://discourse.greatexpectations.io/t/issue-initializing-bigquery-datasource-in-great-expectations/2102>\
**Category:** GX Core Support\
**Created:** [February 17, 2025, 2:32pm UTC](https://discourse.greatexpectations.io/t/issue-initializing-bigquery-datasource-in-great-expectations/2102 "2025-02-17T14:32:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![usmanmohammed](https://avatars.discourse-cdn.com/v4/letter/u/bcef8e/32.png) [@usmanmohammed](https://discourse.greatexpectations.io/u/usmanmohammed)\
**Post date:** [February 17, 2025, 2:32pm UTC](https://discourse.greatexpectations.io/t/issue-initializing-bigquery-datasource-in-great-expectations/2102/1 "2025-02-17T14:32:35Z")

</div>

Hi GE Community,

I’m trying to set up **Great Expectations** with **BigQuery** as my datasource, but I keep running into the following error:

python

CopyEdit

```auto

```

```auto
raise gx_exceptions.DatasourceError(
great_expectations.exceptions.exceptions.DatasourceError: Cannot initialize datasource my_bigquery_datasource, error: The given datasource could not be retrieved from the DataContext; please confirm that your configuration is accurate.

```

```auto

```

### **What I Have Tried:**

- Verified that my `great_expectations.yml` configuration includes the correct **BigQuery connection details**.
- Ensured that my **Google Cloud credentials** are properly set up and `gcloud auth` works.
- Tried creating the datasource manually in a Python script using:

python

CopyEdit

```auto

```

from great\_expectations.data\_context import DataContext

context = DataContext()

context.add\_datasource(  
name=“my\_bigquery\_datasource”,  
class\_name=“Datasource”,  
execution\_engine={  
“class\_name”: “SqlAlchemyExecutionEngine”,  
“connection\_string”: “bigquery://my-project-id”  
},  
data\_connectors={  
“default\_runtime\_data\_connector”: {  
“class\_name”: “RuntimeDataConnector”,  
“batch\_identifiers”: [“batch\_id”],  
}  
}  
)

```auto

```

### **Issue Details:**

- The error suggests that GE cannot retrieve the datasource from the DataContext.
- I suspect an issue with how GE initializes the datasource.

Any guidance on troubleshooting this issue would be greatly appreciated! Has anyone faced a similar problem when setting up BigQuery as a datasource?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![adeola](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@adeola](https://discourse.greatexpectations.io/u/adeola)\
**Post date:** [March 31, 2025, 6:35pm UTC](https://discourse.greatexpectations.io/t/issue-initializing-bigquery-datasource-in-great-expectations/2102/2 "2025-03-31T18:35:53Z")

</div>

im not sure what version of GX you are using but your example doesn’t appear to be up to date.  
I would use:

```auto
context.data_sources.add_sql(name: str, connection_string:str)

```

this is compatible with our latest version
