internal BigQueryResults(BigQueryClient client, GetQueryResultsResponse response, TableReference tableReference, ListRowsOptions options)
 {
     _client        = GaxPreconditions.CheckNotNull(client, nameof(client));
     _response      = GaxPreconditions.CheckNotNull(response, nameof(response));
     TableReference = GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
     _options       = options;
 }
Beispiel #2
0
        private TabledataResource.ListRequest CreateListRequest(TableReference tableReference, ListRowsOptions options)
        {
            var request = Service.Tabledata.List(tableReference.ProjectId, tableReference.DatasetId, tableReference.TableId);

            options?.ModifyRequest(request);
            RetryHandler.MarkAsRetriable(request);
            return(request);
        }
Beispiel #3
0
        /// <inheritdoc />
        public override PagedAsyncEnumerable <TableDataList, BigQueryRow> ListRowsAsync(TableReference tableReference, TableSchema schema = null, ListRowsOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            // TODO: This is a synchronous call. We can't easily make this part asynchronous - we don't have a cancellation token, and we're returning
            // a non-task value. We could defer until the first MoveNext call, but that's tricky.
            schema = schema ?? GetSchema(tableReference);

            var pageManager = new TableRowPageManager(schema);

            return(new RestPagedAsyncEnumerable <TabledataResource.ListRequest, TableDataList, BigQueryRow>(
                       () => CreateListRequest(tableReference, options), pageManager));
        }
Beispiel #4
0
        /// <inheritdoc />
        public override PagedEnumerable <TableDataList, BigQueryRow> ListRows(TableReference tableReference, TableSchema schema = null, ListRowsOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            schema = schema ?? GetSchema(tableReference);

            var pageManager = new TableRowPageManager(schema);

            return(new RestPagedEnumerable <TabledataResource.ListRequest, TableDataList, BigQueryRow>(
                       () => CreateListRequest(tableReference, options), pageManager));
        }
Beispiel #5
0
 /// <summary>
 /// Asynchronously lists the rows within this table, similar to a <c>SELECT * FROM ...</c> query.
 /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="BigQueryClient.ListRowsAsync(TableReference, TableSchema, ListRowsOptions)"/>.
 /// </summary>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>An asynchronous sequence of the rows within the table.</returns>
 public PagedAsyncEnumerable <TableDataList, BigQueryRow> ListRowsAsync(ListRowsOptions options = null) => _client.ListRowsAsync(Reference, Schema, options);
Beispiel #6
0
        /// <inheritdoc />
        public override PagedAsyncEnumerable <TableDataList, BigQueryRow> ListRowsAsync(TableReference tableReference, TableSchema schema = null, ListRowsOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            // TODO: This is a synchronous call. We can't easily make this part asynchronous - we don't have a cancellation token, and we're returning
            // a non-task value. We could defer until the first MoveNext call, but that's tricky.
            // There's no way to specify fetching rows with no fields (that looks more like a dry run anyways).
            // So, if the schema is empty, the whole rows will be fetch, so we need to get the whole schema.
            var resultSchema = schema?.Fields?.Count > 0 ? schema : GetSchema(tableReference);

            var pageManager = new TableRowPageManager(resultSchema);

            return(new RestPagedAsyncEnumerable <TabledataResource.ListRequest, TableDataList, BigQueryRow>(
                       // Pass the original schema, if it was null then the whole table will be fetch and we don't need to
                       // specify selected fields.
                       () => CreateListRequest(tableReference, options, schema), pageManager));
        }
Beispiel #7
0
        private TabledataResource.ListRequest CreateListRequest(TableReference tableReference, ListRowsOptions options, TableSchema schema)
        {
            var request = Service.Tabledata.List(tableReference.ProjectId, tableReference.DatasetId, tableReference.TableId);

            options?.ModifyRequest(request);
            // null and empty schemas are handled by BuildSelectedFields,
            // but both values mean the same, and that is to return whole rows.
            request.SelectedFields = schema.BuildSelectedFields();
            RetryHandler.MarkAsRetriable(request);
            return(request);
        }
Beispiel #8
0
        /// <inheritdoc />
        public override PagedEnumerable <TableDataList, BigQueryRow> ListRows(TableReference tableReference, TableSchema schema = null, ListRowsOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            // There's no way to specify fetching rows with no fields (that looks more like a dry run anyways).
            // So, if the schema is empty, the whole rows will be fetch, so we need to get the whole schema.
            var resultSchema = schema?.Fields?.Count > 0 ? schema : GetSchema(tableReference);

            var pageManager = new TableRowPageManager(resultSchema);

            return(new RestPagedEnumerable <TabledataResource.ListRequest, TableDataList, BigQueryRow>(
                       // Pass the original schema, if it was null then the whole table will be fetch and we don't need to
                       // specify selected fields.
                       () => CreateListRequest(tableReference, options, schema), pageManager));
        }
 /// <summary>
 /// Lists the rows within a table, similar to a <c>SELECT * FROM ...</c> query.
 /// </summary>
 /// <remarks>
 /// No network requests are made until the returned sequence is enumerated.
 /// This means that any exception due to an invalid request will be deferred until that time. Callers should be prepared
 /// for exceptions to be thrown while enumerating the results. In addition to failures due to invalid requests, network
 /// or service failures can cause exceptions even after the first results have been returned.
 /// </remarks>
 /// <param name="tableReference">A fully-qualified identifier for the table. Must not be null.</param>
 /// <param name="schema">The schema to use when interpreting results. This may be null, in which case it will be fetched from
 /// the table first.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>An asynchronous sequence of the rows within the table.</returns>
 public virtual PagedAsyncEnumerable <TableDataList, BigQueryRow> ListRowsAsync(TableReference tableReference, TableSchema schema = null, ListRowsOptions options = null)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Lists the rows within a table within this client's project specified by dataset ID and table ID, similar to a <c>SELECT * FROM ...</c> query.
 /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="ListRowsAsync(TableReference, TableSchema, ListRowsOptions)"/>.
 /// </summary>
 /// <remarks>
 /// No network requests are made until the returned sequence is enumerated.
 /// This means that any exception due to an invalid request will be deferred until that time. Callers should be prepared
 /// for exceptions to be thrown while enumerating the results. In addition to failures due to invalid requests, network
 /// or service failures can cause exceptions even after the first results have been returned.
 /// </remarks>
 /// <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 when interpreting results. This may be null, in which case it will be fetched from
 /// the table first.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>An asynchronous sequence of the rows within the table.</returns>
 public virtual PagedAsyncEnumerable <TableDataList, BigQueryRow> ListRowsAsync(string datasetId, string tableId, TableSchema schema = null, ListRowsOptions options = null) =>
 ListRowsAsync(GetTableReference(datasetId, tableId), schema, options);
        /// <inheritdoc />
        public override PagedAsyncEnumerable <TableDataList, BigQueryRow> ListRowsAsync(TableReference tableReference, TableSchema schema = null, ListRowsOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            schema = schema ?? GetSchema(tableReference);

            var pageManager = new TableRowPageManager(this, schema);

            Func <TabledataResource.ListRequest> requestProvider = () =>
            {
                var request = Service.Tabledata.List(tableReference.ProjectId, tableReference.DatasetId, tableReference.TableId);
                request.ModifyRequest += _versionHeaderAction;
                options?.ModifyRequest(request);
                return(request);
            };

            return(new RestPagedAsyncEnumerable <TabledataResource.ListRequest, TableDataList, BigQueryRow>(
                       requestProvider,
                       pageManager));
        }
 public BigQueryResults(BigQueryClient client, GetQueryResultsResponse response, TableReference tableReference, ListRowsOptions options)
     : this(client, response, tableReference, options?.ToGetQueryResultsOptions())
 {
 }