GithubHelp home page GithubHelp logo

C# client about bigquery-emulator HOT 3 CLOSED

ambujs-ps avatar ambujs-ps commented on June 15, 2024
C# client

from bigquery-emulator.

Comments (3)

richardware avatar richardware commented on June 15, 2024 1

Hi @ambujs-ps, this has worked for me (using Test Containers):

// Build the container
var container = new ContainerBuilder()
   .WithImage("ghcr.io/goccy/bigquery-emulator:latest")
   .WithPortBinding(9050, true)
   .WithResourceMapping(new FileInfo("data.yaml"), "/srv/testdata/")
   .WithCommand("--project=test", "--data-from-yaml=/srv/testdata/data.yaml")
   .WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(9050))
   .Build();

// Start the container.
await container
   .StartAsync()
   .ConfigureAwait(false);

// Build the BigQuery Client
var bigQueryEndpoint = new UriBuilder(Uri.UriSchemeHttp, container.Hostname, container.GetMappedPublicPort(9050)).Uri;
var client = await new BigQueryClientBuilder {
   ProjectId = /* your project Id **/,
   ApiKey = "fake",
   BaseUri = bigQueryEndpoint.ToString()
}.BuildAsync();

from bigquery-emulator.

ambujs-ps avatar ambujs-ps commented on June 15, 2024
BigQueryClientBuilder

Thanks so much!, I'll give this a try.

from bigquery-emulator.

richardware avatar richardware commented on June 15, 2024

FYI a key part is providing a fake ApiKey to Google's BigQueryClientBuilder. Even if the BaseUri is pointing to a containerized emulator instance, you may still have problems - if you provide a null credential then the Client will look for the Application Default Credentials file, if you provide even a fake User credential from JSON or a file then the Client will attempt to refresh the auth token.

from bigquery-emulator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.