Comments (8)
Can you post the docker run
configuration you are using when starting the emulator as well as any logs from the container? Are you mapping a host port to the container port?
We are using a similar setup and can create datasets just fine.
python
Python 3.11.7 (main, Dec 4 2023, 18:10:11) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud import bigquery
from google.auth.credentials import AnonymousCredentials
from google.api_core.client_options import ClientOptions
client_options = ClientOptions(api_endpoint="http://0.0.0.0:9050")
client = bigquery.Client(
"local",
client_options=client_options,
credentials=AnonymousCredentials(),
)
dataset = bigquery.Dataset('local.test_dataset')
dataset = client.create_dataset(dataset)
print(dataset)
>>> from google.auth.credentials import AnonymousCredentials
>>> from google.api_core.client_options import ClientOptions
>>>
>>>
>>> client_options = ClientOptions(api_endpoint="http://0.0.0.0:9050")
>>> client = bigquery.Client(
... "local",
... client_options=client_options,
... credentials=AnonymousCredentials(),
... )
>>> dataset = bigquery.Dataset('local.test_dataset')
>>> dataset = client.create_dataset(dataset)
>>> print(dataset)
Dataset(DatasetReference('local', 'test_dataset'))
docker run -p 9050:9050 --rm ghcr.io/goccy/bigquery-emulator:latest /bin/bigquery-emulator --project=local --log-level=info
[bigquery-emulator] REST server listening at 0.0.0.0:9050
[bigquery-emulator] gRPC server listening at 0.0.0.0:9060
2024-03-28T17:41:34.742Z INFO server/middleware.go:53 POST /bigquery/v2/projects/local/datasets {"query": "prettyPrint=false"}
from bigquery-emulator.
Thanks for the response. I am using the below docker run command
docker run -it ghcr.io/goccy/bigquery-emulator:latest --project=local --log-level=info
The only log I see in the container is below
[bigquery-emulator] REST server listening at 0.0.0.0:9050
[bigquery-emulator] gRPC server listening at 0.0.0.0:9060
from bigquery-emulator.
You'll need to map a Docker host port to the emulator container port via docker run -p 9050:9050
when running the emulator in order for the client to access it on the local 0.0.0.0
network.
from bigquery-emulator.
Thanks for the response! I did try with port mapping too. Getting the same error
docker run -p 9050:9050 ghcr.io/goccy/bigquery-emulator:latest --project=local --log-level=info
P.S.: I am using python 3.12.2 version
from bigquery-emulator.
Are you running your pytest
command locally or in a separate Docker container? If you are running it in another docker container you may need to run it in the same Docker network.
I'd recommend going over this page and have a look at the example they lay out with redis-server
and redis-cli
.
https://docs.docker.com/network/#container-networks
from bigquery-emulator.
I am running the pytest locally
from bigquery-emulator.
The reproduction case you provided does not fully encompass what might be going wrong as it works just fine for me.
Are you able to use port mapping successfully with other containers? Perhaps Docker doesn't have permission to mount ports? Does the bq
tool work when the emulator is running?
bq --api "http://0.0.0.0:9050" query --nouse_legacy_sql --format prettyjson --project_id local 'SELECT TRUE;'
from bigquery-emulator.
Not sure why, but I had to use http://localhost:9050 instead of http://0.0.0.0:9050 to get this working. I used all the above docker commands with connection to localhost to get it working. Thanks for the help!
from bigquery-emulator.
Related Issues (20)
- JSON_EXTRACT_SCALAR nor JSON_QUERY does not work as expected HOT 1
- Does the emulator work with Pandas GBQ? HOT 3
- Error when executing bq command from google-cloud-cli version 469.0.0
- Response from table update is incompatible with Google's Python SDK HOT 1
- Improve emulator performance for large projects HOT 7
- Failes to exec merge statement UPDATE
- Cannot create a view with a query that ends in semicolon
- Cannot materialize job results when table does not yet exist
- [Golang] Errors from zetasql parser HOT 3
- The BigQuery emulator doesn't support CREATE TABLE AS SELECT with column definition list HOT 2
- Error querying a nested struct using UNNEST HOT 1
- Support of UNPIVOT operator HOT 3
- `UPDATE ... FROM ( SELECT ... )` results in the error: `Update with joins not supported`
- Unable to use UploadCsvAsync HOT 1
- Error checking null string parameter in where clause HOT 1
- BQ-Emulator does not release memory when deleting tables
- Python SDK always retries requests for invalid queries
- Ingestion-time partitioning not (fully) supported HOT 1
- Support for the `bqutil` community user-defined functions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bigquery-emulator.