Class: Google::Cloud::Datastore::Dataset::AggregateQueryResults
- Inherits:
-
Object
- Object
- Google::Cloud::Datastore::Dataset::AggregateQueryResults
- Defined in:
- lib/google/cloud/datastore/dataset/aggregate_query_results.rb
Overview
AggregateQueryResults
An AggregateQueryResult object is a representation for a result of an AggregateQuery or a GqlQuery.
Instance Attribute Summary collapse
-
#aggregate_fields ⇒ Hash{String => Integer, Float}
readonly
The result of the aggregation query, returned as a hash of key-value pairs.
-
#explain_metrics ⇒ Google::Cloud::Datastore::V1::ExplainMetrics?
readonly
Query explain metrics.
-
#explain_options ⇒ Google::Cloud::Datastore::V1::ExplainOptions?
readonly
The options for query explanation.
-
#read_time ⇒ Google::Protobuf::Timestamp
readonly
The time when the query was executed.
Instance Method Summary collapse
-
#get(aggregate_alias = nil) ⇒ Integer, ...
Retrieves the aggregate data.
Instance Attribute Details
#aggregate_fields ⇒ Hash{String => Integer, Float}
The result of the aggregation query, returned as a hash of key-value pairs. The key is the alias of the aggregate function, and the value is the result of the aggregation.
The alias of the aggregate function can be:
- an aggregate literal "sum", "avg", or "count"
- a custom aggregate alias
52 53 54 |
# File 'lib/google/cloud/datastore/dataset/aggregate_query_results.rb', line 52 def aggregate_fields @aggregate_fields end |
#explain_metrics ⇒ Google::Cloud::Datastore::V1::ExplainMetrics?
Query explain metrics. This is only present when the explain_options
are provided to Google::Cloud::Datastore::Dataset#run_aggregation.
It is sent only once with the response.
65 66 67 |
# File 'lib/google/cloud/datastore/dataset/aggregate_query_results.rb', line 65 def explain_metrics @explain_metrics end |
#explain_options ⇒ Google::Cloud::Datastore::V1::ExplainOptions?
The options for query explanation.
This is a copy of the input parameter supplied to the Google::Cloud::Datastore::Dataset#run_aggregation function.
73 74 75 |
# File 'lib/google/cloud/datastore/dataset/aggregate_query_results.rb', line 73 def @explain_options end |
#read_time ⇒ Google::Protobuf::Timestamp
The time when the query was executed.
58 59 60 |
# File 'lib/google/cloud/datastore/dataset/aggregate_query_results.rb', line 58 def read_time @read_time end |
Instance Method Details
#get(aggregate_alias = nil) ⇒ Integer, ...
Retrieves the aggregate data.
if the aggregate_alias does not exist.
120 121 122 123 124 125 126 |
# File 'lib/google/cloud/datastore/dataset/aggregate_query_results.rb', line 120 def get aggregate_alias = nil if @aggregate_fields.count > 1 && aggregate_alias.nil? raise ArgumentError, "Required param aggregate_alias for AggregateQuery with multiple aggregate fields" end aggregate_alias ||= @aggregate_fields.keys.first @aggregate_fields[aggregate_alias] end |