/// <inheritdoc />
        public override async Task <BigQueryTable> CreateTableAsync(TableReference tableReference, TableSchema schema,
                                                                    CreateTableOptions options = null, CancellationToken cancellationToken = default)
        {
            var request = CreateInsertTableRequest(tableReference, schema, options);
            var result  = await request.ExecuteAsync(cancellationToken).ConfigureAwait(false);

            return(new BigQueryTable(this, result));
        }
        /// <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 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) =>
 CreateTable(tableReference, new Table {
     Schema = GaxPreconditions.CheckNotNull(schema, nameof(schema))
 }, options);
 /// <summary>
 /// Asynchronously attempts to fetch the specified table, 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="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 to use to create the table if necessary. Must not be null unless the schema can be inferred (e.g. for a view).</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 projectId, string datasetId, string tableId, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null, CancellationToken cancellationToken = default(CancellationToken)) =>
 GetOrCreateTableAsync(GetTableReference(projectId, datasetId, tableId), schema, getOptions, createOptions, cancellationToken);
 /// <summary>
 /// Attempts to fetch the specified table, 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="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 to use to create the table if necessary. Must not be null unless the schema can be inferred (e.g. for a view).</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 projectId, string datasetId, string tableId, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null) =>
 GetOrCreateTable(GetTableReference(projectId, datasetId, tableId), schema, getOptions, createOptions);
 /// <summary>
 /// Creates the specified table.
 /// </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 unless the schema can be inferred (e.g. for a view).</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();
        /// <inheritdoc />
        public override BigQueryTable CreateTable(TableReference tableReference, TableSchema schema, CreateTableOptions options = null)
        {
            var request = CreateInsertTableRequest(tableReference, schema, options);
            var result  = request.Execute();

            return(new BigQueryTable(this, result));
        }
        private InsertRequest CreateInsertTableRequest(TableReference tableReference, Table resource, CreateTableOptions options)
        {
            CheckResourceForCreation(tableReference, resource);

            resource.TableReference ??= tableReference;

            var request = Service.Tables.Insert(resource, tableReference.ProjectId, tableReference.DatasetId);

            options?.ModifyRequest(request);
            return(request);
        }
        /// <inheritdoc />
        public override async Task <BigQueryTable> GetOrCreateTableAsync(
            TableReference tableReference, Table resource, GetTableOptions getOptions = null, CreateTableOptions createOptions = null, CancellationToken cancellationToken = default)
        {
            CheckResourceForCreation(tableReference, resource);

            try
            {
                return(await GetTableAsync(tableReference, getOptions, cancellationToken).ConfigureAwait(false));
            }
            catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound)
            {
                return(await CreateTableAsync(tableReference, resource, createOptions, cancellationToken).ConfigureAwait(false));
            }
        }
        /// <inheritdoc />
        public override BigQueryTable GetOrCreateTable(TableReference tableReference, Table resource, GetTableOptions getOptions = null, CreateTableOptions createOptions = null)
        {
            CheckResourceForCreation(tableReference, resource);

            try
            {
                return(GetTable(tableReference, getOptions));
            }
            catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound)
            {
                return(CreateTable(tableReference, resource, createOptions));
            }
        }
 /// <inheritdoc />
 public override Task <BigQueryTable> GetOrCreateTableAsync(
     TableReference tableReference, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null, CancellationToken cancellationToken = default) =>
 GetOrCreateTableAsync(tableReference, new Table {
     Schema = GaxPreconditions.CheckNotNull(schema, nameof(schema))
 }, getOptions, createOptions, cancellationToken);
 /// <inheritdoc />
 public override BigQueryTable GetOrCreateTable(
     TableReference tableReference, TableSchema schema, GetTableOptions getOptions = null, CreateTableOptions createOptions = null) =>
 GetOrCreateTable(tableReference, new Table {
     Schema = GaxPreconditions.CheckNotNull(schema, nameof(schema))
 }, getOptions, createOptions);
示例#16
0
 /// <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) =>
 _client.GetOrCreateTableAsync(GetTableReference(tableId), schema, getOptions, createOptions, cancellationToken);
 /// <summary>
 /// Creates the specified table.
 /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="CreateTable(TableReference, TableSchema, CreateTableOptions)"/>.
 /// </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 unless the schema can be inferred (e.g. for a view).</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 projectId, string datasetId, string tableId, TableSchema schema, CreateTableOptions options = null) =>
 CreateTable(GetTableReference(projectId, datasetId, tableId), schema, options);
        private InsertRequest CreateInsertTableRequest(TableReference tableReference, TableSchema schema, CreateTableOptions options)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));

            var table = new Table {
                TableReference = tableReference, Schema = schema
            };
            var request = Service.Tables.Insert(table, tableReference.ProjectId, tableReference.DatasetId);

            request.ModifyRequest += _versionHeaderAction;
            options?.ModifyRequest(table, request);
            return(request);
        }
 /// <summary>
 /// Asynchronously creates the specified table within this client's project.
 /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="CreateTableAsync(TableReference, TableSchema, 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 for the new table. Must not be null unless the schema can be inferred (e.g. for a view).</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 datasetId, string tableId, TableSchema schema, CreateTableOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) =>
 CreateTableAsync(GetTableReference(datasetId, tableId), schema, options, cancellationToken);
示例#20
0
 /// <summary>
 /// Asynchronously creates a table within this dataset.
 /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="BigQueryClient.CreateTableAsync(TableReference, TableSchema, CreateTableOptions, CancellationToken)"/>.
 /// </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>
 /// <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 Task <BigQueryTable> CreateTableAsync(string tableId, TableSchema schema, CreateTableOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) =>
 _client.CreateTableAsync(GetTableReference(tableId), schema, options, cancellationToken);
 /// <summary>
 /// Attempts to fetch the specified 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 unless the schema can be inferred (e.g. for a view).</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();
        /// <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));
            }
        }
 /// <summary>
 /// Asynchronously attempts to fetch the specified 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 unless the schema can be inferred (e.g. for a view).</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();
        /// <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);

            request.ModifyRequest += _versionHeaderAction;
            options?.ModifyRequest(table, request);
            var result = request.Execute();

            return(new BigQueryTable(this, result));
        }