コード例 #1
0
        /// <inheritdoc />
        public override BigQueryTable GetTable(TableReference tableReference, GetTableOptions options = null)
        {
            var request  = CreateGetTableRequest(tableReference, options);
            var resource = request.Execute();

            return(new BigQueryTable(this, resource));
        }
コード例 #2
0
        // Request creation
        private GetRequest CreateGetTableRequest(TableReference tableReference, GetTableOptions options)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));

            var request = Service.Tables.Get(tableReference.ProjectId, tableReference.DatasetId, tableReference.TableId);

            options?.ModifyRequest(request);
            RetryHandler.MarkAsRetriable(request);
            return(request);
        }
        /// <inheritdoc />
        public override BigQueryTable GetTable(TableReference tableReference, GetTableOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));

            var request = Service.Tables.Get(tableReference.ProjectId, tableReference.DatasetId, tableReference.TableId);

            options?.ModifyRequest(request);
            var resource = request.Execute();

            return(new BigQueryTable(this, resource));
        }
コード例 #4
0
        /// <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 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));
            }
        }
コード例 #6
0
 /// <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();
コード例 #7
0
 /// <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();
コード例 #8
0
 /// <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);
コード例 #9
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);
コード例 #10
0
 /// <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);
コード例 #11
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.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);
コード例 #12
0
 /// <summary>
 /// Asynchronously retrieves a table within this dataset.
 /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="BigQueryClient.GetTableAsync(TableReference, GetTableOptions, CancellationToken)"/>.
 /// </summary>
 /// <param name="tableId">The table ID. 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 requested table.</returns>
 public Task <BigQueryTable> GetTableAsync(string tableId, GetTableOptions options = null, CancellationToken cancellationToken = default) =>
 _client.GetTableAsync(GetTableReference(tableId), options, cancellationToken);
コード例 #13
0
 /// <summary>
 /// Asynchronously retrieves the specified table.
 /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="GetTableAsync(TableReference, GetTableOptions, 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="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 requested table.</returns>
 public virtual Task <BigQueryTable> GetTableAsync(string projectId, string datasetId, string tableId, GetTableOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) =>
 GetTableAsync(GetTableReference(projectId, datasetId, tableId), options, cancellationToken);
コード例 #14
0
 /// <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);
コード例 #15
0
 /// <summary>
 /// Retrieves the specified table.
 /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="GetTable(TableReference, GetTableOptions)"/>.
 /// </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="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>The requested table.</returns>
 public virtual BigQueryTable GetTable(string projectId, string datasetId, string tableId, GetTableOptions options = null) =>
 GetTable(GetTableReference(projectId, datasetId, tableId), options);
        /// <inheritdoc />
        public override async Task <BigQueryTable> GetTableAsync(TableReference tableReference, GetTableOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));

            var request = Service.Tables.Get(tableReference.ProjectId, tableReference.DatasetId, tableReference.TableId);

            request.ModifyRequest += _versionHeaderAction;
            options?.ModifyRequest(request);
            var resource = await request.ExecuteAsync(cancellationToken).ConfigureAwait(false);

            return(new BigQueryTable(this, resource));
        }
コード例 #17
0
        /// <inheritdoc />
        public override async Task <BigQueryTable> GetTableAsync(TableReference tableReference, GetTableOptions options = null, CancellationToken cancellationToken = default)
        {
            var request  = CreateGetTableRequest(tableReference, options);
            var resource = await request.ExecuteAsync(cancellationToken).ConfigureAwait(false);

            return(new BigQueryTable(this, resource));
        }
コード例 #18
0
 /// <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);
コード例 #19
0
        /// <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));
            }
        }
コード例 #20
0
 /// <summary>
 /// Retrieves the specified table.
 /// </summary>
 /// <param name="tableReference">A fully-qualified identifier for the 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 requested table.</returns>
 public virtual BigQueryTable GetTable(TableReference tableReference, GetTableOptions options = null) =>
 throw new NotImplementedException();
        /// <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));
            }
        }
コード例 #22
0
 /// <summary>
 /// Asynchronously retrieves the specified table.
 /// </summary>
 /// <param name="tableReference">A fully-qualified identifier for the 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 requested table.</returns>
 public virtual Task <BigQueryTable> GetTableAsync(TableReference tableReference, GetTableOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) =>
 throw new NotImplementedException();
コード例 #23
0
 /// <summary>
 /// Retrieves a table within this dataset.
 /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="BigQueryClient.GetTable(TableReference, GetTableOptions)"/>.
 /// </summary>
 /// <param name="tableId">The table ID. 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 requested table.</returns>
 public BigQueryTable GetTable(string tableId, GetTableOptions options = null) =>
 _client.GetTable(GetTableReference(tableId), options);