jpercent / pygrametl

Automatically exported from code.google.com/p/pygrametl
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

lookupatts only support one key #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. in Dimension initialized process, the options: lookupatts only support one 
key, if you use composed key, the query can't works.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by xia...@gmail.com on 3 Apr 2014 at 1:43

GoogleCodeExporter commented 9 years ago
This is not a defect. By design, pygrametl expects that every dimension table 
has a non-composite key (otherwise, the fact table would also need several FK 
columns to reference single a dimension value).

pygrametl does support several lookupatts (for the "business key"):

    dim = Dimension(name='dimtest', key='a', attributes=('b','c','d'),
                    lookupatts=('b','c'))
    dim.ensure({'a':0 ,'b':0 , 'c':0 , 'd':0})
    dim.ensure({'a':1 ,'b':1 , 'c':1 , 'd':1})
    dim.ensure({'a':2 ,'b':2 , 'c':2 , 'd':2})

    print(dim.lookup({'b':1, 'c':1}))     # prints 1 as expected
    print(dim.lookup({'b':1, 'c':9999}))  # prints None as expected

Original comment by c...@cs.aau.dk on 3 Apr 2014 at 7:33