Using BigQuery repeated / nested fields in Power BI - google-bigquery

Problem: When connecting Power BI to a BigQuery table (using the native BQ connector) with repeated / nested fields, these fields do not appear in Power BI for use in report creation.
Example: Using a Public BigQuery data set called bigquery-public-data:samples, there is a table called github_nested which has repeated fields such as payload.pages.action (see below)
However, when connecting to this BigQuery table using Power BI I only get a handful of fields (see below)
As I understand, this is because the Power BI Big Query connector doesn't support repeated / nested or record fields.
Question: Is there any workaround to have all columns / fields in a BigQuery table (regardless of whether they are repeated / nested / records) available for use when building Power BI reports, specifically using a live connection over the native Power BI Big Query connector?
I do have write permissions in BigQuery so creating views on top of these tables with repeated / nested fields is possible if required as part of a solution.
One potential workaround might be to create a view in Big Query which un-nests repeated fields and then connect Power BI to said view. Open to any workaround suggestions.
Any help would be greatly appreciated.

Power BI does not have (as of 29/10/2018) a native Big Query connector, it just uses a generic ODBC connector. I would advise not to use it for production, current limitations are :
GCP billing accounts are not supported if your billing project is different than your dataset project
Google Service Accounts are not supported
Nested and repeated fields are not supported
Requests are not optimized (bad finops)
Dataset linked to Google Sheets through Big Query are not supported
Some data types are not correctly handled
Requests cannot be manually edited (using BQ Standard SQL for exemple)
Learn more in this article (i am the author): https://medium.com/#remy_david/which-bi-tool-for-big-query-d9eb838ff7ad

Example schema of products-and-stocks table:
[
{
name: 'timestamp',
type: 'TIMESTAMP'
}, {
name: 'data',
type: 'RECORD',
mode: "REPEATED",
fields: [
{
name: 'itemId',
type: 'STRING'
}, {
name: 'prodId',
type: 'STRING'
}, {
name: 'name',
type: 'STRING'
}, {
name: 'stockA',
type: 'INTEGER'
}, {
name: 'stockB',
type: 'INTEGER'
}, {
name: 'stockQ',
type: 'INTEGER'
}, {
name: 'stockD',
type: 'INTEGER'
}, {
name: 'stockE',
type: 'INTEGER'
}, {
name: 'weight',
type: 'INTEGER'
}, {
name: 'size',
type: 'RECORD',
fields: [
{
name: 'length',
type: 'INTEGER'
}, {
name: 'width',
type: 'INTEGER'
}, {
name: 'height',
type: 'INTEGER'
}
]
}, {
name: 'cnt',
type: 'INTEGER'
}, {
name: 'cntInBox',
type: 'INTEGER'
}, {
name: 'lifetime',
type: 'INTEGER'
}, {
name: 'barcode',
type: 'STRING',
mode: 'REPEATED',
}, {
name: 'dateStockUpdate',
type: 'TIMESTAMP'
}, {
name: 'label',
type: 'STRING'
}, {
name: 'comment',
type: 'STRING'
}, {
name: 'commentPack',
type: 'STRING'
}, {
name: 'skuBox',
type: 'INTEGER'
}, {
name: 'snRuleRegularExpression',
type: 'STRING'
}
]
}
]
Create flattening query in the BigQuery and save it as a View.
SELECT
`timestamp`,
repeated.*,
repeated.size.length as `size_length`,
repeated.size.width as `size_width`,
repeated.size.height as `size_height`,
ARRAY_TO_STRING(barcode, ", ") as barcodesFlat
FROM
`my-project-id.my-dataset.products-and-stocks`
CROSS JOIN UNNEST(`data`) as repeated
Import this view into Power BI.

Related

How to store Array of multipe types with realm in react native

When using realm, if i need to store filed with value like [783, "Name of"],
This is my code, when i use mixed i got null,
export const Schema = {
name: 'Schema',
primaryKey: 'id',
properties: {
id: 'int',
name: {type: 'string', indexed: true},
field: 'string[]', // mixed[] not work too
}
}
Any help please !!!

How to filter by item contained in a list in realm react native?

I'm doing the following query:
realm.objects('Maker').filtered("categories CONTAINS $0", categoryObject)
But I'm getting this error:
Only 'equal' and 'not equal' operators are supported for object comparison
And here's my schema:
{
name: 'MakerOption',
primaryKey: 'serverId',
properties: {
serverId: 'int',
name: 'string',
categories: {type: 'list', objectType: 'Category'},
}
{
name: 'Category',
primaryKey: 'serverId',
properties: {
serverId: 'int',
name: 'string'
}
The documentation is quite sparse on this subject. Is there an alternative method for doing this?
Filtering by properties on linked or child objects can be done by specifying a keypath in the query e.g. car.color == 'blue'
So you are looking for the following query:
realm.objects('Maker').filtered("categories.serverId == $0", categoryObject.serverId)

Realm-js schema with nested objects

I want to easily query such results:
[{
name: 'john_doe',
info: {
age: 24,
notes: 'custom text',
phoneNumbers: {
home: 112345678,
work: 1234567,
},
},
}, {...}, {...}...]
... by such query:
contacts.filtered("info.age = 24 AND info.notes CONTAINS 'custom'");
How should i create such schema? docs are very confusing about data types and nested properties:
https://realm.io/docs/react-native/0.14.0/api/Realm.html#~PropertyType
https://realm.io/docs/react-native/latest/#nested-objects
I do not need to retrieve any parts of this data separately - only complete object with all nested objects at once.
You could put all fields into a single object:
var ContactSchema = {
name: 'Contact',
properties: {
name: 'string',
age: 'int',
notes: 'string',
homePhone: 'string',
workPhone: 'string'
}
};
Alternatively you could create child objects for info and phoneNumbers but if you are not sharing this data across multiple contacts then this probably isn't needed.

Sencha Touch synch not saving to proxy

I have a piece of code in a Sencha Touch v2 controller as shown below. When this code is ran the count after the store.add is (6), the counter after the store.sync is (0) and the store.sync is succeeding.
NOTE: items holds 6 records received from a JsonP proxy, no errors are shown in the console and everything acts as though it was a full success.
requires: [
'Ext.data.proxy.JsonP',
'Ext.data.proxy.Sql'
],
config: {
models: ['Convention'],
stores: ['Conventions']
},
// ***additional code*** //
store.setProxy({
type: 'sql',
database: 'app',
table: 'Conventions'
});
store.removeAll();
store.sync({
success: function(batch){
store.add(items);
console.log("Count before: " + store.getCount()); << Shows (6)
store.sync({
failure: function (batch, options) {
console.log('Convention Sql failure');
},
success: function(batch,options){
console.log("Count after: " + store.getCount()); << Shows (0)
console.log("Convention Sql success");
store.load();
Ext.Viewport.unmask();
}
});
}
});
The model is show here
extend: 'Ext.data.Model',
config: {
idProperty: 'id',
fields: [
{ name: 'id', type: 'string' },
{ name: 'name', type: 'string' },
{ name: 'logoId', type: 'string' },
{ name: 'seasonId', type: 'string'},
{ name: 'viewed', type: 'string'},
{ name: 'dateCreated', type: 'string'},
{ name: 'dateUpdated', type: 'string'}
]
}
and the store is here
extend: 'Ext.data.Store',
requires: [
'Ext.data.proxy.Sql'
],
config: {
model: 'app.model.Convention',
autoLoad: false,
sorters:[{
property: 'name',
direction: 'ASC'
}],
proxy: {
type: 'sql',
database: 'app',
table: 'Conventions'
}
}
After much research it seems that Sencha recently changed some of their code on how they handle IDs. As such, if you are using code examples previous to this change you will get errors when you try to save to the ID field.
Sencha has added the clientIdProperty that you can add to the writer of a proxy and directly to the model.
Reference: http://docs.sencha.com/touch/2.4/2.4.2-apidocs/#!/api/Ext.data.Model-cfg-clientIdProperty
The name of a property that is used for submitting this Model's unique client-side identifier to the server when multiple phantom records are saved as part of the same Operation. In such a case, the server response should include the client id for each record so that the server response data can be used to update the client-side records if necessary. This property cannot have the same name as any of this Model's fields.
As such, my code above will have the following changes to the following where 'siteId' is my id being passed from the Json request and the ID on my server for the record.
model
idProperty: 'id',
clientIdProperty: 'siteId',
identifier: 'uuid',
Controller
store.setProxy({
type: 'sql',
database: 'app',
table: 'Conventions',
writer: {
clientIdProperty: 'siteId'
}
});

Loading Json in Store to display it on List Sencha Touch 2 jsonp

This is my model
Ext.define("StockWatch.model.Market", {
extend: "Ext.data.Model",
config: {
idProperty: 'CompanyCode',
fields: [
{ name: 'CompanyCode', type: 'string' },
{ name: 'LastTradedPrice', type: 'string' },
{ name: 'PercentageDiff', type: 'string' },
{ name: 'FiftyTwoWeekHigh', type: 'string' },
{ name: 'FiftyTwoWeekLow', type: 'string' },
{ name: 'ChangePercent', type: 'string' },
{ name: 'Change', type: 'string' },
{ name: 'MarketCap', type: 'string' },
{ name: 'High', type: 'string' },
{ name: 'Low', type: 'string' },
{ name: 'PrevClose', type: 'string' },
{ name: 'OpenInterest', type: 'string' },
{ name: 'MarketLot', type: 'string' },
{ name: 'ChangeInOpenInterest', type: 'string' },
{ name: 'LastTradedTime', type: 'date', dateFormat: 'c' },
]
}
});
this is my store
Ext.define("StockWatch.store.Markets", {
extend: "Ext.data.Store",
requires: ["Ext.data.proxy.LocalStorage", "Ext.data.proxy.JsonP", "StockWatch.model.Market"],
config: {
model: "StockWatch.model.Market",
autoLoad : true,
proxy : {
type : 'jsonp',
url : 'http://money.rediff.com/money1/current_status_new.php?companylist=17023928%7C17023929&id=1354690151&Rand=0.6305125835351646',
reader:{
type:'json',
rootProperty:''
}
}
}
});
I'm not able to get the data on to my list, may be somewhere fetching of data is wrong.
guide me to find the solution.
also I'm using pull to refresh list plugin, so will the data be loaded automatically each time i pull down the list or do i have to write something over there to??
thnx in advance
EDIT:
I also get this warning in the console
Resource interpreted as Script but transferred with MIME type text/html: "http://money.rediff.com/money1/current_status_new.php?companylist=17023928%7C17023929&id=1354690151&Rand=0.6305125835351646&_dc=1355822361093&page=1&start=0&limit=25&callback=Ext.data.JsonP.callback1".
use callbackKey
callbackKey: Specifies the GET parameter that will be sent to the server containing the function name to be executed when the request completes. Defaults to callback. Thus, a common request will be in the form of url?callback=Ext.data.JsonP.callback1
Defaults to: "callback"
You need to wrap the JSON response in a callback function for JSONP. It doesn't look like your remote call is returning this, try specifying a callback parameter - otherwise if the remote server does not allow this you need to pass it through another server to wrap it in a callback function.
Also, the warning you mentioned in the bottom of your post, don't worry about that. It won't cause any problems.