pub struct Client { /* private fields */ }

Implementations§

source§

impl Client

source

pub async fn new(config: ClientConfig) -> Result<Self, Error>

New client

source

pub fn dataset(&self) -> &BigqueryDatasetClient

https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets BigqueryDatasetClient

source

pub fn table(&self) -> &BigqueryTableClient

https://cloud.google.com/bigquery/docs/reference/rest/v2/tables BigqueryTableClient

source

pub fn tabledata(&self) -> &BigqueryTabledataClient

https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata BigqueryTabledataClient

source

pub fn job(&self) -> &BigqueryJobClient

https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs BigqueryJobClient

source

pub fn routine(&self) -> &BigqueryRoutineClient

https://cloud.google.com/bigquery/docs/reference/rest/v2/routines BigqueryRoutineClient

source

pub fn row_access_policy(&self) -> &BigqueryRowAccessPolicyClient

https://cloud.google.com/bigquery/docs/reference/rest/v2/rowAccessPolicy BigqueryRowAccessPolicyClient

source

pub fn model(&self) -> &BigqueryModelClient

https://cloud.google.com/bigquery/docs/reference/rest/v2/models BigqueryModelClient

source

pub async fn query<T>( &self, project_id: &str, request: QueryRequest ) -> Result<Iterator<T>, QueryError>where T: StructDecodable + StructDecodable,

Run query job and get result.

use google_cloud_bigquery::http::job::query::QueryRequest;
use google_cloud_bigquery::query::row::Row;
use google_cloud_bigquery::client::Client;

async fn run(client: &Client, project_id: &str) {
    let request = QueryRequest {
        query: "SELECT * FROM dataset.table".to_string(),
        ..Default::default()
    };
    let mut iter = client.query::<Row>(project_id, request).await.unwrap();
    while let Some(row) = iter.next().await.unwrap() {
        let col1 = row.column::<String>(0);
        let col2 = row.column::<Option<String>>(1);
    }
}
source

pub async fn query_with_option<T>( &self, project_id: &str, request: QueryRequest, option: QueryOption ) -> Result<Iterator<T>, QueryError>where T: StructDecodable + StructDecodable,

Run query job and get result.

use google_cloud_bigquery::http::job::query::QueryRequest;
use google_cloud_bigquery::query::row::Row;
use google_cloud_bigquery::client::Client;
use google_cloud_bigquery::query::QueryOption;
use google_cloud_bigquery::query::ExponentialBuilder;

async fn run(client: &Client, project_id: &str) {
    let request = QueryRequest {
        query: "SELECT * FROM dataset.table".to_string(),
        ..Default::default()
    };
    let retry = ExponentialBuilder::default().with_max_times(10);
    let option = QueryOption::default().with_retry(retry).with_enable_storage_read(true);
    let mut iter = client.query_with_option::<Row>(project_id, request, option).await.unwrap();
    while let Some(row) = iter.next().await.unwrap() {
        let col1 = row.column::<String>(0);
        let col2 = row.column::<Option<String>>(1);
    }
}
source

pub async fn read_table<T>( &self, table: &TableReference, option: Option<ReadTableOption> ) -> Result<Iterator<T>, Error>where T: StructDecodable,

Read table data by BigQuery Storage Read API.

use google_cloud_bigquery::storage::row::Row;
use google_cloud_bigquery::client::Client;
use google_cloud_bigquery::http::table::TableReference;

async fn run(client: &Client, project_id: &str) {
    let table = TableReference {
        project_id: project_id.to_string(),
        dataset_id: "dataset".to_string(),
        table_id: "table".to_string(),
    };
    let mut iter = client.read_table::<Row>(&table, None).await.unwrap();
    while let Some(row) = iter.next().await.unwrap() {
        let col1 = row.column::<String>(0);
        let col2 = row.column::<Option<String>>(1);
    }
}

Trait Implementations§

source§

impl Clone for Client

source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for Twhere T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more