/// <inheritdoc /> public override async Task <BigqueryTable> CreateTableAsync(TableReference tableReference, TableSchema schema, CreateTableOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference)); var table = new Table { TableReference = tableReference, Schema = schema }; var request = Service.Tables.Insert(table, tableReference.ProjectId, tableReference.DatasetId); options?.ModifyRequest(table, request); var result = await request.ExecuteAsync(cancellationToken).ConfigureAwait(false); return(new BigqueryTable(this, result)); }
/// <summary> /// Attempts to fetch a table, creating it if it doesn't exist. /// </summary> /// <param name="tableReference">A fully-qualified identifier for the table. Must not be null.</param> /// <param name="schema">The schema to use to create the table if necessary. Must not be null.</param> /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param> /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param> /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> /// <returns>A task representing the asynchronous operation. When complete, the result is /// the existing or new table.</returns> public virtual Task <BigqueryTable> GetOrCreateTableAsync(TableReference tableReference, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null, CancellationToken cancellationToken = default(CancellationToken)) { throw new NotImplementedException(); }
/// <summary> /// Attempts to fetch the specified table within this client's project, creating it if it doesn't exist. /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="GetOrCreateTableAsync(TableReference, TableSchema, GetTableOptions, CreateTableOptions,CancellationToken)"/>. /// </summary> /// <param name="datasetId">The dataset ID. Must not be null.</param> /// <param name="tableId">The table ID. Must not be null.</param> /// <param name="schema">The schema to use to create the table if necessary. Must not be null.</param> /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param> /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param> /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> /// <returns>A task representing the asynchronous operation. When complete, the result is /// the existing or new table.</returns> public virtual Task <BigqueryTable> GetOrCreateTableAsync(string datasetId, string tableId, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null, CancellationToken cancellationToken = default(CancellationToken)) => GetOrCreateTableAsync(GetTableReference(datasetId, tableId), schema, getOptions, createOptions, cancellationToken);
/// <summary> /// Creates a table specified by a project ID, dataset ID and table ID. /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="CreateTableAsync(TableReference, TableSchema, CreateTableOptions,CancellationToken)"/>. /// </summary> /// <param name="projectId">The project ID. Must not be null.</param> /// <param name="datasetId">The dataset ID. Must not be null.</param> /// <param name="tableId">The table ID. Must not be null.</param> /// <param name="schema">The schema for the new table. Must not be null.</param> /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param> /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> /// <returns>A task representing the asynchronous operation. When complete, the result is /// the newly created table.</returns> public virtual Task <BigqueryTable> CreateTableAsync(string projectId, string datasetId, string tableId, TableSchema schema, CreateTableOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => CreateTableAsync(GetTableReference(projectId, datasetId, tableId), schema, options, cancellationToken);
/// <summary> /// Attempts to fetch a table, creating it if it doesn't exist. /// </summary> /// <param name="tableReference">A fully-qualified identifier for the table. Must not be null.</param> /// <param name="schema">The schema to use to create the table if necessary. Must not be null.</param> /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param> /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param> /// <returns>The existing or new table.</returns> public virtual BigqueryTable GetOrCreateTable(TableReference tableReference, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null) { throw new NotImplementedException(); }
/// <summary> /// Attempts to fetch the specified table within this client's project, creating it if it doesn't exist. /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="GetOrCreateTable(TableReference, TableSchema, GetTableOptions, CreateTableOptions)"/>. /// </summary> /// <param name="datasetId">The dataset ID. Must not be null.</param> /// <param name="tableId">The table ID. Must not be null.</param> /// <param name="schema">The schema to use to create the table if necessary. Must not be null.</param> /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param> /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param> /// <returns>The existing or new table.</returns> public virtual BigqueryTable GetOrCreateTable(string datasetId, string tableId, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null) => GetOrCreateTable(GetTableReference(datasetId, tableId), schema, getOptions, createOptions);
/// <summary> /// Creates a table with the given schema. /// </summary> /// <param name="tableReference">A fully-qualified identifier for the table. Must not be null.</param> /// <param name="schema">The schema for the new table. Must not be null.</param> /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param> /// <returns>The newly created table.</returns> public virtual BigqueryTable CreateTable(TableReference tableReference, TableSchema schema, CreateTableOptions options = null) { throw new NotImplementedException(); }
/// <summary> /// Creates a table within this project, specified by a dataset ID and table ID. /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="CreateTable(TableReference, TableSchema, CreateTableOptions)"/>. /// </summary> /// <param name="datasetId">The dataset ID. Must not be null.</param> /// <param name="tableId">The table ID. Must not be null.</param> /// <param name="schema">The schema for the new table. Must not be null.</param> /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param> /// <returns>The newly created table.</returns> public virtual BigqueryTable CreateTable(string datasetId, string tableId, TableSchema schema, CreateTableOptions options = null) => CreateTable(GetTableReference(datasetId, tableId), schema, options);
/// <summary> /// Attempts to fetch the specified table within this dataset, creating it if it doesn't exist. /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="BigqueryClient.GetOrCreateTableAsync(TableReference, TableSchema, GetTableOptions, CreateTableOptions, CancellationToken)"/>. /// </summary> /// <param name="tableId">The table ID. Must not be null.</param> /// <param name="schema">The schema to use to create the table if necessary. Must not be null.</param> /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param> /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param> /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> /// <returns>A task representing the asynchronous operation. When complete, the result is /// the existing or new table.</returns> public Task <BigqueryTable> GetOrCreateTableAsync(string tableId, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null, CancellationToken cancellationToken = default(CancellationToken)) => _client.GetOrCreateTableAsync(GetTableReference(tableId), schema, getOptions, createOptions, cancellationToken);
/// <summary> /// Attempts to fetch the specified table within this dataset, creating it if it doesn't exist. /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="BigqueryClient.GetOrCreateTable(TableReference, TableSchema, GetTableOptions, CreateTableOptions)"/>. /// </summary> /// <param name="tableId">The table ID. Must not be null.</param> /// <param name="schema">The schema to use to create the table if necessary. Must not be null.</param> /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param> /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param> /// <returns>The existing or new table.</returns> public BigqueryTable GetOrCreateTable(string tableId, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null) => _client.GetOrCreateTable(GetTableReference(tableId), schema, getOptions, createOptions);
/// <summary> /// Creates a table within this dataset. /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="BigqueryClient.CreateTable(TableReference, TableSchema, CreateTableOptions)"/>. /// </summary> /// <param name="tableId">The table ID. Must not be null.</param> /// <param name="schema">The schema of the data. Must not be null.</param> /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param> /// <returns>The newly created table.</returns> public BigqueryTable CreateTable(string tableId, TableSchema schema, CreateTableOptions options = null) => _client.CreateTable(GetTableReference(tableId), schema, options);
/// <inheritdoc /> public override BigqueryTable GetOrCreateTable(TableReference tableReference, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null) { GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference)); try { // TODO: Validate the schema matches? return(GetTable(tableReference, getOptions)); } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound) { return(CreateTable(tableReference, schema, createOptions)); } }
/// <inheritdoc /> public override BigqueryTable CreateTable(TableReference tableReference, TableSchema schema, CreateTableOptions options = null) { GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference)); var table = new Table { TableReference = tableReference, Schema = schema }; var request = Service.Tables.Insert(table, tableReference.ProjectId, tableReference.DatasetId); options?.ModifyRequest(table, request); var result = request.Execute(); return(new BigqueryTable(this, result)); }
/// <inheritdoc /> public override async Task <BigqueryTable> GetOrCreateTableAsync(TableReference tableReference, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null, CancellationToken cancellationToken = default(CancellationToken)) { GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference)); try { // TODO: Validate the schema matches? return(await GetTableAsync(tableReference, getOptions, cancellationToken).ConfigureAwait(false)); } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound) { return(await CreateTableAsync(tableReference, schema, createOptions, cancellationToken).ConfigureAwait(false)); } }