Using the guidelines here I have successfully queried a simple fusion table for some basic data with the following code:
google.load('visualization', '1', { packages: ['corechart'] });
function drawVisualization() {
google.visualization.drawChart({
containerId: 'visualization',
dataSourceUrl: 'http://www.google.com/fusiontables/gvizdata?tq=',
query: 'SELECT sector, revenue FROM 2961086',
chartType: 'LineChart',
options: {
title: 'Net Revenue by Sector',
vAxis: {
title: 'Revenue'
},
hAxis: {
title: 'Sector'
}
}
});
}
google.setOnLoadCallback(drawVisualization);
A problem arises when I attempt to aggregate the data by sector. I've tried the following
query: 'SELECT sector, revenue FROM 2961086 GROUP BY sector'
with no luck, the request eventually times out.
I threw together two pages demonstrating the issue.
I've also tried queries with various other parameters that work with no trouble whatsoever. Am I missing something?
I'm not a google.visualization user, just a fusion-table user but I would guess that you need an aggregate function in your query: SELECT sector, sum(revenue) from ... GROUP BY sector
Eric
Related
Inside typeorm 0.3 we are able to find users who have posts by the next code:
userRepo.find({
where: {
posts: {
post_id: Not(IsNull())
}
},
relations: ['posts']
})
Does anyone know how to find users who have no posts at all (without using raw code)?
I have a Table in the google docs and want to change its alignment to -0.71 but i do not see any Python API to change table properties. This can be done easily using following UI on google UI (as shown below):
I also tries looking at following requests but could not find it:
updateTableColumnProperties
updateTableCellStyle
For debugging, i created a doc with mentioned alignment and tried dumping JSON of it. But i do not see alignment keyword in the JSON.
Thanks #jescanellas for reply.
I found a hack, this may not be the best solution but works.
1) Update paragraph style and set the indentation, alignment as required. Here the start_idx is the index where table needs to be created.
request = [{
'updateParagraphStyle': {
'paragraphStyle': {
'namedStyleType': 'HEADING_5',
'direction': 'LEFT_TO_RIGHT',
'alignment': 'START',
'indentFirstLine': {
'magnitude': -51.839999999999996,
'unit': 'PT'
},
'indentStart': {
'magnitude': -51.839999999999996,
'unit': 'PT'
},
},
'fields': '*',
'range': {
'startIndex': start_idx,
'endIndex': end_idx
}
}
}]
2) Create the table, it will get created at new indented place.
request = [{
'insertTable': {
'rows': 1,
'columns': 1,
'location': {
'segmentId':'',
'index': start_idx
}
},
}]
It's not currently possible to do so. You can create a Feature Request for the Docs API, and you can also subscribe to this one for Apps Script by clicking on the star next to the Issue number to give more priority to the request and to receive updates.
In case of the second request being implemented, you could call the script from the command line using Clasp.
I defined a GraphQL Mutation using graphql-relay but am having issues figuring out how to submit a mutation to it.
Here is the relevant schema:
const userType = new GraphQLObjectType({
name: 'User',
description: 'user',
fields: () => ({
id: {
type: new GraphQLNonNull(GraphQLString),
description: 'The UUID for the user.',
resolve(user) {
return user.uuid;
},
},
})
});
const registerUser = mutationWithClientMutationId({
name: 'registerUser',
inputFields: {
},
outputFields: {
user: {
type: userType,
resolve: (payload) => {
models.user.findById(payload.userId);
}
},
},
mutateAndGetPayload: (args) => {
var newUser = models.user.build().save();
return {
userId: newUser.id,
};
}
});
const rootMutation = new GraphQLObjectType({
name: 'RootMutationType',
fields: {
registerUser: registerUser,
},
});
const schema = new GraphQLSchema({
query: rootQuery,
mutation: rootMutation,
});
What should an HTTP call look like to register a new user and get back the userId?
Thanks!
I want to point out that I see that you're saying that your mutation requires no parameters - how does it know what the new user's details are? You'll probably need some parameters on that mutation, eventually. They would be available to your mutateAndGetPayload on that first function parameter. (I'm not saying every mutation needs parameters, but this one probably does)
If you're using Relay, there is some pretty good information on the official document as to how to use your mutations from Relay. Particularly down at the bottom where it shows the various mutator configs. If you're using connections, you may want to use RANGE_ADD to add this new account to the Relay store manually, otherwise if you'd like to perform a more broad refetch you can use FIELDS_CHANGE. You said you need the new user id after the mutation finishes. If you're using Relay, you may need to look into REQUIRED_CHILDREN to specify that regardless of the computed query that Relay will build, you always want that id to be queried.
The output of your mutation is a userType, so you'd be able to access it with a fragment on the payload type, which would probably be RegisterUserPayload, that might look something like ...
fragment on RegisterUserPayload {
user {
id
}
}
Now, that's assuming you're using Relay. If you'd like to try this out manually via GraphiQL, then you can use the examples of how to do mutations through there on the GraphQL Mutation docs. There's a direct example of how you'd query your mutation.
Last, since you asked how to do this at a low level of issuing the HTTP request yourself, for that you can look at express-graphql documentation, which explains how to query it.
I figured out a mutation format that worked:
mutation RootMutationType {
registerUser(input:{clientMutationId:"123"}){
clientMutationId, user { id }
}
}
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
I'm using the jqueryUI autocomplete functionality (http://jqueryui.com/demos/autocomplete/#remote-jsonp) to search surrounding shops of cities in germany and austria. my code is the following:
$.ajax({
url: "http://ws.geonames.org/searchJSON?lang=de&country=DE&country=AT&isNameRequired=true&featureClass=A&featureCode=ADM3&featureCode=ADM4&featureCode=ADM1",
dataType: "jsonp",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: request.term
}...
the problem now is, for austria, i need all the administrative devisions ADM3, ADM1... to get all of the cities. For Germany ADM4 would be enough. But because of the other codes, I get Berlin for example three times, because its ADM3, ADM1 and ADM4.
How can i remove the duplicates of certain cities to autosuggest it only once?