These are chat archives for DataBrewery/cubes

31st
May 2016
voldesh
@voldesh
May 31 2016 09:30
Hello again !
I need help in setting up my model and slicer file with MongoDB backend.
Cant seem to understand the docs
It would help to understand if there are active examples of cubes with MongoDB backend.
Affan Sadiq
@affansadiq
May 31 2016 15:28
Hey guys anyone here who is familiar with sqlalchemy?
Jose Juan Montes
@jjmontesl
May 31 2016 15:48
@voldesh I haven't used the mongo backend.
@affansadiq I have used sqlalchemy to some extent, what are you looking for?
Affan Sadiq
@affansadiq
May 31 2016 15:50
Actually ill sent you the link to the stackoverflow post.. :D
Affan Sadiq
@affansadiq
May 31 2016 15:55
Oh sorry @jjmontesl
Now i had to mention you
Jose Juan Montes
@jjmontesl
May 31 2016 15:58
Why are you doing this in SQLAchemy? I mean, shouldn't be Cubes doing this?
Affan Sadiq
@affansadiq
May 31 2016 15:59
Actually i could understand cubes that well so i did it on my own
and did a quite good progress
and my project is already onwards and half-finished so.. no way back anymore ahah
Jose Juan Montes
@jjmontesl
May 31 2016 16:00
:D
I'm not skilled enough to answer your question on SO.
Affan Sadiq
@affansadiq
May 31 2016 16:00
Not skilled enough ? :D
But by the way thanks for upvoting :D
soon i can comment :D
Jose Juan Montes
@jjmontesl
May 31 2016 16:02
Umm it's been long since I used SQLAlchemy directly, and I'm rusty, and never grasped it that much anyway. I'm having a look anyway, and I'll tell you.
That becomes off topic here though :/
Affan Sadiq
@affansadiq
May 31 2016 16:02
Ok thanks :)
Jose Juan Montes
@jjmontesl
May 31 2016 16:02
It's a well formulated question. I never upvote without a justified reason ;).
Nice first question. Give me 5 min.
Affan Sadiq
@affansadiq
May 31 2016 16:02
Thanks :)
Btw. @jjmontesl i have seen your cubesviewer and its amazing!
Maybe you could have a look at this .. http://www.chartjs.org .. Have you heard of chartJS its quite amazing. I am using it for my project right now thats why i was asking
Jose Juan Montes
@jjmontesl
May 31 2016 16:10
Yeah I know of ChartJS, I like it, and I might as well haveused that but I'm a fan of D3 and nvd3. Anyhow, the biggest showstopper was that I wanted SVG graphics, and ChartJS is canvas. A matter of taste, maybe, but I am a DOM-guy.
Next additions to CubesViewer are maps, though.
Thanks :)
We'd be happier in this channel if you had used Cubes and CubesViewer ;-)
Affan Sadiq
@affansadiq
May 31 2016 16:11
I know but i had problems using it so.. and i think ill deal with it later..
Jose Juan Montes
@jjmontesl
May 31 2016 16:12
What does dim_sales contain in your case?
Affan Sadiq
@affansadiq
May 31 2016 16:12
From lack of knowledge i think i was not able to use it
Uhm wait..
Okay so it contains something like this
Jose Juan Montes
@jjmontesl
May 31 2016 16:12
These kind of infrastructures are always difficult the first time. Cubes model.json imho could be easier.
But once you have an initial setup it's normally very easy to cut and paste to map new data. Next time try hard! ;) ;) :D
Affan Sadiq
@affansadiq
May 31 2016 16:13
Yeah but what would be the result.. I would be struggling around again.. And the result i don't really know whether i would get the same result.. So second thing is that i want to learn as much coding as possible in python and sqlalchemy aswell
Jose Juan Montes
@jjmontesl
May 31 2016 16:14
I'm missing a group_by clause in your query, anyway. How is your SQL?
Affan Sadiq
@affansadiq
May 31 2016 16:14
Because im a newbie to backend programming .. so i think doing the hard stuff would help much better
Jose Juan Montes
@jjmontesl
May 31 2016 16:14
So, show your dim_sales table.
Affan Sadiq
@affansadiq
May 31 2016 16:14
I can "talk" SQL for ages :D
wait..
cps_id  sales_in_usd
1             20000
2             300000
3             40000
4             320320
5             430430
Jose Juan Montes
@jjmontesl
May 31 2016 16:25
oh, wow, strange schema, I'd normally store sales_in_usd directly into fact_sales
Affan Sadiq
@affansadiq
May 31 2016 16:26
yeah... xD but thing is that i have some other fact_tables which need dim_sales
Jose Juan Montes
@jjmontesl
May 31 2016 16:27
Ummm, it's an integer / decimal, I'd possibly copy it during ETL, but anyhow.
Remove the outerjoins, I don't think they have any impact but just in case.
Remove the filter, add it at the end, it doesn't help for designing this.
Affan Sadiq
@affansadiq
May 31 2016 16:28
Okay thanks :)
so should i use join instead of outerjoin?
Jose Juan Montes
@jjmontesl
May 31 2016 16:31
sales_in_shop_query = session.query(Sales_in_shop, dim_product.name, func.sum(dim_sales.sales)).
                        join(product).
                        join(sales).
                        group_by(Sales_in_shop.productKey)
Try something like that
I'm unsure about your actual column and table names so...
Sales_in_shop being the fact table, right?
You were definitely missing a group_by. You need to delve deeper into SQL ;)
If it works I'll paste the answer to SO :D
(the query needs an .all() at the end I reckon)
Jose Juan Montes
@jjmontesl
May 31 2016 16:38
(Note that outer_joins have no commutative property, the order of joins matters).
Ok, enough for the off topic :D, regards!
Affan Sadiq
@affansadiq
May 31 2016 19:15
Hey thanks :) I was off from work and got home right now
Affan Sadiq
@affansadiq
May 31 2016 21:05
Great @jjmontesl im heading into the right direction its working somehow but i cant find the summed variable
did print dir(query_name) -> what i got so far
['Corporatesaleshelp', 'add', 'class', 'contains', 'delattr', 'doc', 'eq', 'format', 'ge', 'getattribute', 'getitem', 'getnewargs', 'getslice', 'gt', 'hash', 'init', 'iter', 'le', 'len', 'lt', 'module', 'mul', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'rmul', 'setattr', 'sizeof', 'slots', 'str', '__subclasshook', '_asdict', '_fields', '_real_fields', 'company_name', 'count', 'cps_id', 'index', 'keys']
Sorry it was not formatting correctly
i cant see anything which tells me there is a sum .. :D
i think i need to import label from sqlalchemy.sql and use it
Affan Sadiq
@affansadiq
May 31 2016 22:33
@jjmontesl :)