How to create a merged table with FusionTable API - google-maps-api-3

The Fusiontable API (https://developers.google.com/fusiontables/docs/v2/using#CreatingTables) allows you to create a new base table. The description here (https://developers.google.com/fusiontables/docs/v2/reference/table/insert) implies you can specify basetableIds, but using the "Try this API" I have not successfully create a merged table. I have one table with map geometry, which I don't want to duplicate, but want to let users specify their own colors for the geometry.
Has anyone been able to do this? If so, how do you specify the columns to join on?
Thanks.

Does the base table have the location type columns? If the "map geometry" column/columns have location type set then you may not be able to create a new base table from the existing tableId as there are warnings throughout the docs about using the API to modify or update columns which are two-column locations.
So I think that by "creating" a new table from a base table id which has columns defined as locations you also create new columns and as such wouldn't be able to do this via API.
Try to change the column types to strings and then create the new table. Revert back to location once completed if this is the case?
Hope that helps.

I recently ran into this problem and thought i would post my solution. It appears that creating merge tables via the API is done by creating views with the sql query endpoint.
From the Docs:
To create a new merged table, use the following syntax in an HTTP POST
request
CREATE VIEW <new_table_name>
AS (SELECT <column_spec> { <column_spec>}*
FROM <table_list>)
So you would generate something like this if you were merging two tables on a 'zipcode' column for example:
CREATE VIEW 'My New Table'
AS (
SELECT T1.'zipcode', T2.'state', T2.'area', T2.'latitude', T2.'longitude', T2.'geometry'
FROM somefusiontableid AS T1
LEFT OUTER JOIN someotherfusiontableid AS T2 ON T1.'zipcode' = T2.'zipcode'
)
Hope this helps anyone else who runs into this.

Related

Aggregation tool in BIRT : display a count like number on a table column

It must be very easy, baut i can't display a very simple filtered agregation on a table header row in BIRT 3.7. I manage to use count aggregation on groups headers or footers, buet not a filtered aggregation on a simple column table.
USE case : my sql statement car return the string value "ERROR..." for a string field name TEST. The query returns 734 results. My table display all the results.
In the header row i just want to diplay a count of which would be in SQL a count like "ERROR%".
I can't manage to do that whit the aggregation tool !
aggregation builder
Many thanks for your help.
Julien
as i can't manage to find the correct way of filtering my aggregation, i provide the results from my SQL request. By i'd be glad to find the dynamic way of filtering it.
Here is an image of a column that contains strings with "ERR". Le top field in red is my aggregation field served by a slq like '%ERR :%' statement.
example

Impala add column to existing VIEW

I went through the Cloudera docs.
It doesn't mention how to add a column to an existing view. Is it because there is no way to achieve that?
If I use DESCRIBE FORMATTED and use the original view definition of select * from xyz(an example is shown here) to drop the existing view and recreate the view with the same userId, will it work exactly as it did before?
You are right - DROP-CREATE should work. Even ALTER VIEW view_name AS SELECT ..., new_col FROM table should work. May be you can share what query you are trying and what is the error you are facing.

In App Maker, how do you make dynamic table cell text?

In App Maker, I am displaying a table and want to replace table cell data with different text using a data lookup from another table. Assume two tables, Departments and Employees.
Departments is two fields, DeptID and DeptDescription.
Employees is multiple fields including DeptID.
In the table listing for Employees, I would like to replace the DeptID with the DeptDescription. (The page datasource is Employees. I do not want to set up a relationship between the data models.)
I am guessing I want to do some scripting in the onDataLoad event for the table cell label for DeptID. I have this much so far:
app.datasources.Departments.query.filters.DeptID._equals = widget.datasource.item.DeptID;
app.datasources.Departments.newQuery().run();
widget.text = app.datasources.Departments.item.DeptDescription;
I know this is not correct, but am I close?
This answer is untested, but I wanted to present a possible solution that would not require a lot of DB calls, especially ones that make repeated calls to a server script which might consume a lot of processing time when you do line item calls.
Set up a separate datasource under the Department model. Change the default 'Query Builder' to 'Query Script' and add a parameter of type 'list(number)' or 'list(string)', this should match your Primary Key field type. Uncheck the 'auto load' option.
In your 'Query Script' portion enter the following code:
query.filters.Id._in = query.parameters.YourParameter;
return query.run();
Go to your Employees datasource that is supposed to generate your table and find your 'On Load' client script section. In this section enter the following code:
var departmentsDs = app.datasources.YourDepartmentsDs;
departmentsDs.properties.YourParameter = datasource.items.map(function(deptIds) {return deptIds.DeptID;});
departmentDs.load();
Now go the page that contains your table. If you have not already create a label widget do so now. In this label widget for the text binding enter the following:
#datasources.YourDepartmentsDs.loaded && (#datasources.YourDepartmentsDs.items).map(function(Id){return Id.Id}).indexOf(#widget.datasource.item.DeptID) !== -1 ? #datasources.YourDepartmentDs.items[(#datasources.YourDepartmentsDs.items).map(function(Id){return Id.Id}).indexOf(#widget.datasource.item.DeptID)].DeptDescription : 'Unable to retrieve Dept Description'
As stated this is untested and I wrote the code from memory without App Maker in front of me so it may require some additional tweaking. Going with the first option presented by J.G. would also be a very viable solution though. And I apologize but the code formatter does not seem to be working for me.
1 way) Create an aggregate table that joins your tables if you need to bypass using the relations feature. This way you can use sql to join the two tables in the datasource definition
2) if you don't want to make a new table. Change the text from a value binding to "more options"
=getDescription(#datasource.item.DeptId)
and then the code you wrote in a client side script
function getDescription(id){
google.script.run
.withSuccessHandler(function successHandler(result){ return result;})
.withFailureHandler( function failureHandler(e){ console.log(" Failed" +e);})
.queryValue(id);
}
server side script:
function queryValue(id){
var query = app.models.Departments.newQuery();
query.filters.DeptID._equals = id;
var results = query.run();
return results[0]["DeptDescription"];
}
that last line might be results[0].DeptDescription

Return one record from a form data source

I have a form with an existing data source. This data source has a one to many relationship to another table that is not an existing data source. Even though this second table contains multiple records (one to many), the field in the table that I want is duplicated across all records. Therefore I want to add this second table as a data source, but only return one record from it.
If I add the second table directly, than my form contains a line for each record instead of just one.
This problem was solved by creating a view to use as the new datasource. This view defined a calculated column that was based on a method that contained a query string that used TOP 1. The details in much more detail are at Martin Dráb's blog: https://community.dynamics.com/ax/b/goshoom/archive/2015/06/29/join-first-line-in-ax-2012.
Use the property LinkType=ExistJoin on the datasource for your second table.
See the TransactionLog form for example.

Binding to MS Access Local Database

I am using the Shield UI ASP.NET chart and am trying to add an ms access data source for a pie chart.. I have created a database and a table and added it to the solution. The table contains some data, so that couldn’t be the problem.
After this I configured the data source and specified the following select statement:
SELECT * FROM [Sales]
but the chart showed no data.
I than changed the query to
SELECT [ID], [ProductName], [SaleAmount] FROM [Sales]
because probably there was a column name missing but there was no success either. In both cases I ran the query and it returned rows.
What could I be doing wrong?
Since there is no data visualized on your chart while your database contains rows, the problem could be that you are not specifying the exact column needed for the chart. At design time when specifying the datasource the chart doesn’t acuire any specific field for any specific column. This means that you need to place some extra code:
<DataSeries>
<shield:ChartBarSeries DataFieldY="SaleAmount">
</shield:ChartBarSeries>
</DataSeries>
Furthermore- if you need to specify more than one series e.g. visualize more than one field you need to repeat that for each field adding the appropriate data series.
You may find more information here:
https://www.shieldui.com/documentation/asp.net.chart/databinding/data.source.controls

Resources