When performing a query against BigQuery, it outputs useful info in logs, but the return value is simply the query payload. Is there any way to programmatically get the query metadata in addition to the query result?
Example:
bigquery = Google::Cloud::Bigquery.new(…)
result = bigquery.query(sql)
Debug-level logs will show something like:
#total_bytes_processed=102412,
#total_rows=12915
I'm wondering how that could be accessed programmatically.
Don't know the specifics of Ruby (I don't use that language), but when you submit your query, you'll get back a "job id". Use this id to retrieve the meta information about the job/query using the Job API.
https://cloud.google.com/bigquery/docs/jobs-overview
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#resource
Related
I have my Sql query stored as value in one of key attributes in MongoDb database.I am able to fetch the records from the MongoDb database.I want to run the sql query assosciated after retrieving it from there.
The format of record is as follow:
{
"Id":2,
"Type":"SqlQuery",
"Syntax":"select id from table_name where id = pid and optional_id in ('AC','SU')",
"ValueSpecifiers":{
"id":"request.id"
}
}
I am beginner in springboot.It would be very helpful if someone could guide me some resource or in correct direction .I am confused about is it possible to hit queries by setting few filter parameters here like id dynamically as it varies with request object.I want to run it dynamically without extending crud repository.Its just like hitting db by native queries.
You could use a character like "?" on your recorded query, and then you replace it with your filters. Example:
In the database you save the query like
select id from table_name where id = pid and optional_id in (?)
And then you retrieve the query to a variable and replace the "?" with the parameters you want to filter. Something like
varQuery.replace("?", "'AC', 'SU'")
or
Replace(varQuery, "?", "'AC', 'SU'")
I am new to elasticsearch, I use it to store my dataset.
I created a IHM where I can type a query and get the response
I would like to know if there is a way to get the response before finishing typing the query
for example, I would like to look for the china, I would like to get some result while I am typing the word chi.
can you tell me how to make
DB::table()->where()->get() result into a JSON script?. In this script I want get a row as a result
DB::table('users')->get()->toJson() should be enough. Ref docs
If you are making API, use Eloquent resource.
I have some sample data on the Elasticsearch, which looks like the following:
I am using the data table in the Visualize section to get the counts for each error type, for example: it should output
Error: Update failed for online booking with id, count is 5.
Not the count 1 for different id of the same error type.
What I have done is to build a query to output the counts for each error type, which looks like this:
However, when I save the query as the saved search, then visualize it as data table, it still have the same issue as above.
I was thinking to only save the output of that query as saved search, one issue is that the output is too verbose, has a lot of information I don't really need.
Any suggestions please !
I find myself having to write two db queries and I would like to know whether it's possible to reduce to one.
I am updating a document and then finding the document again in the database. Is it possible to update and receive the full updated document in the response of the update query? This would save a call to the db.
I should explain that the document I'm saving won't be a complete document which is why I'm having to retrieve it from the database to get all the fields.
Yes, it is possible. Please have a look at the documentation of the Query.Apply method, which runs the findAndModify MongoDB command.
Straight from the documentation, this example increments a counter and prints its new value:
change := mgo.Change{
Update: bson.M{"$inc": bson.M{"n": 1}},
ReturnNew: true,
}
info, err = col.Find(M{"_id": id}).Apply(change, &doc)
fmt.Println(doc.N)