i am fetching records from Google big query using gem 'google-api-client',
When I fetch records from table
client.execute(api_method: #compute_api.tabledata.list,
parameters: {projectId: project,
datasetId: dataset,
tableId: table,
maxResults: 10}).body
I get response like,
{
"kind": "bigquery#tableDataList",
"etag": "\"iBDiwpngzDA0oFU52344ksWOrjA/-xEFKhLUueR63_XVaLG4z_mJt-8\"",
"totalRows": "2000113",
"pageToken": "BEIYURQ3J4AQAAAS23IIBAEAAUNAICAMCAGCBMFOCU======",
"rows": [
{
"f": [
{
"v": "11873943041"
},
{
"v": "639592585-0-1809110554#8.19.146.76"
},
{
"v": "1.430438401E9"
},
{
"v": "1.430438402E9"
},
{
"v": "1.430438404E9"
},
{
"v": "1.430438862E9"
}]}]}
Which does not have column names in it, Does anyone have any idea about how to get columns names along with data?
Currently I need to make another API request to fetch schema and get column names.
I found answer for this myself using bigquery command line tool (bq),
bq --format=json query "select * from calls.details limit 10"
when using bq if we dont provide --quiet option then it returns response with additional text to it(status about big query job), that causes problem in parsing Json as shown below
Waiting on bqjob_r36676afce1bcba8d_0000014f1ba0e36b_1 ... (0s) Current status: DONE
[{"status":null,"userfield":null,"answer_stamp":"2015-05-01 00:00:04","term_roid":"a"}]
Thats the reason I moved to use google api to fetch data and again that doesn't give you column names along with data. But I found that we can remove that extra text by using --quiet option for bq command like
bq --quiet --format=json query "select * from calls.details limit 10"
The API does not provide a way to get the schema and rows for an arbitrary table in a single API call. You need to call tables.get to get the schema, and then tabledata.list to get the rows.
However, if you're running a query, you can get the output schema and output rows in a single API call by using jobs.query or jobs.getQueryResults. You can even call jobs.getQueryResults on an already-completed query job, even if that query job was executed by some other means.
https://cloud.google.com/bigquery/docs/reference/v2/jobs/query
https://cloud.google.com/bigquery/docs/reference/v2/jobs/getQueryResults
Related
I've been using the Microsoft Graph to perform Delta Queries on Users. My requirement is to return the values of ExtensionAttributes (custom properties synced to Azure AD from AD on-prem).
The following request works:
/v1.0/users?$select=extension_8928938292839829832_value
And returns the extension attributes as desired:
"value": [
{
"extension_8928938292839829832_value": "String1",
}
However when trying to use the Delta Query and including extension attributes:
/v1.0/users/delta?$select=extension_8928938292839829832_value
The value returned is just the basic user properties, NOT the requested extension value:
"value": [
{
"deletedDateTime": null,
"accountEnabled": true,
"assignedLicenses": [],
etc, etc, etc
},
I'm not sure if the extension values are exposed in the v1.0 Delta Query.
Anyone have thoughts on how to approach this issue? Grabbing these extension attributes and using the delta query to track changes is vital to my solution.
I'm afraid this isn't supported at the moment. This is listed in the Known Issues:
Delta query
OData context is sometimes returned incorrectly when tracking changes to relationships.
Schema extensions (legacy) are not returned with $select statement, but are returned without $select.
Clients cannot track changes to open extensions or registered schema extensions.
How do I connect my database to API.AI
Making every sentence into INTENT and creating entities for each doesn't seem to be a good idea? So what is the best possible way to go about?
As far as I know it is not possible yet, but you can switch to row mode and past your entities inCVS or JSON format OR import a JSON/CSV file containing all your entities.
The file should look like below (JSON format):
[
{
"value": "val1",
"synonyms": [
"syn1",
"syn2"
]
},
{
"value": "val2",
"synonyms": [
"syn21",
"syn22"
]
},
]
So you can image of writing a small job that reads entities from you DB and make a JSON/CSV file according the wanted format.
Once the job done, this process may dramatically facilitate the creation of your entities on api.ai.
If you use a webhook for an intent, you can pass params to your endpoint where you can do all the queries to your db
I did a demo where I was querying news (cheating as I was getting it from the web, but I could plug a DB).
The was getting requests such as:
"What are the latest news about France"
latest and France would be params that I send through to the webhook endpoint.
You would get the following JSON sent your endpoint by API.AI
"result": {
"source": "agent",
"resolvedQuery": "latest news about France",
"action": "show.news",
"actionIncomplete": false,
"parameters": {
"adjective": "latest",
"subject": "France"
}
Then you can query all the news for France and order them by latest
In my understanding the idea is to create entities that are "placeholders" for the values you need to query.
Then you teach the AI with few examples by tagging in the request what did the person ask. Let say someone asks:
"what is the oldest news about France?"
The AI may not know what is oldest thus you tell it is is an adjective and from now on you can get oldest as a param
I am attempting to truncate the results of an $expand parameter from SensorThingsAPI e.g.
http://example.org/v1.0/Things?$expand=Datastreams
However, $top only restricts the trunk of the query (e.g. Things). Is there a way to truncate the results of the 'leaves' of an $expand?
In this case, the server-side pagination should be controlling the 'leaves' of an $expand.
For example, if the service limit 100 entities for each response and the expanded entities (or the collection) have more than 100, the service will return the top 100 entities following a service-defined order. A #iot.nextLink will also be returned, so that the client know how to fetch the next 100 entities (i.e., next page). Using the above query as an example, an example nextLink to retrieve the Datastreams will be
Datastreams#iot.nextLink:"http://URL_to_retrieve_the_next_page/"
You can use this OGC SensorThings sandbox to see an example return of $expand: http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams?$expand=Observations
The following JSON shows an example response of the following query with $expand: http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams?$expand=Observations:
{
"#iot.count": 1,
"value": [{
"#iot.id": 8,
"#iot.selfLink": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams(8)",
"description": "Daily Water level",
"observationType": "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Observation",
"unitOfMeasurement": {
"symbol": "m",
"name": "meter",
"definition": "https://en.wikipedia.org/wiki/Metre"
},
"Observations#iot.nextLink": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams(8)/Observations?$top=3&$skip=3",
"Observations#iot.count": 1826,
"Observations": [{
"#iot.id": 1835,
"#iot.selfLink": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Observations(1835)",
"phenomenonTime": "2015-12-30T16:00:00.000Z",
"result": "1375.44",
"resultTime": null,
"Datastream#iot.navigationLink": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Observations(1835)/Datastream",
"FeatureOfInterest#iot.navigationLink": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Observations(1835)/FeatureOfInterest"
}],
"ObservedProperty#iot.navigationLink": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams(8)/ObservedProperty",
"Sensor#iot.navigationLink": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams(8)/Sensor",
"Thing#iot.navigationLink": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams(8)/Thing"
},{},{}]
}
Is there a way to retrieve the query metadata within Neo4jClient which can be returned after executing a Cypher querty.
Within the Neo4j browser when making a request against the server the following kind of response is returned.
{
"results":[
{
"columns":[
],
"data":[
],
"stats":{
"contains_updates":false,
"nodes_created":0,
"nodes_deleted":0,
"properties_set":0,
"relationships_created":0,
"relationship_deleted":0,
"labels_added":0,
"labels_removed":0,
"indexes_added":0,
"indexes_removed":0,
"constraints_added":0,
"constraints_removed":0
}
}
],
"errors":[
]
}
The block I am interested in is the stats block.
A quick look at the request shows a includeStats=true flag being set but I see no inclusion of it within the neo4jclient code.
Many thanks.
Not at this time, no.
There are some stats on the IGraphClient.OperationCompleted event, but not these ones.
You are welcome to extend this event and send a pull request at https://github.com/readify/Neo4jClient/
I have a problem while fetching data from an array that I obtain with a fql query.
The data that I receive has this structure:
{
"data": [
{
"name": "Just Café Pacini",
"can_post": true,
"page_id": 401836073222759,
},``
{....},
{....},
]
}
I'm working with the php SDK and I'm trying to receive some informations about several pages.
I've tried with foreach($ret_obj['data'] as $single_obj) as usual but php tells me that there's no index "data".
I'm sure that facebook doesn't return any error.
first you must call json_decode($ret_obj) to get a php array
then you can call foreach to iterate