jpercent/pygrametl

There is no way to implement Slowly_changing_dimension#Type_1

GoogleCodeExporter opened this issue · 3 comments

What steps will reproduce the problem?
1. use Slowly_changing_dimension
2. only support Type2
3.

What is the expected output? What do you see instead?
need a Type1 support dimension function.

What version of the product are you using? On what operating system?
pygrametl 2.2, linux

Please provide any additional information below.
https://en.wikipedia.org/wiki/Slowly_changing_dimension#Type_1

Original issue reported on code.google.com by xia...@gmail.com on 2 Apr 2014 at 9:16

I give a sample logic on Dimension.ensure logic:
58     ¦   for row in role_results:
   59     ¦   ¦   try:
~  60     ¦   ¦   ¦   res = role_dim.lookup(row, {
   61     ¦   ¦   ¦   ¦   'name': 'Name', 'is_disabled': 'Disabled'}
~  62     ¦   ¦   ¦   ¦   )
+  63     ¦   ¦   ¦   if res is not None:
+  64     ¦   ¦   ¦   ¦   new_row = self._role_row_format(row)
+  65     ¦   ¦   ¦   ¦   print new_row
+  66     ¦   ¦   ¦   ¦   role_dim.update(new_row)
+  67     ¦   ¦   ¦   else:
+  68     ¦   ¦   ¦   ¦   role_dim.insert(row, {
+  69     ¦   ¦   ¦   ¦   ¦   'name': 'Name', 'is_disabled': 'Disabled'}
+  70     ¦   ¦   ¦   ¦   ¦   )
   71     ¦   ¦   except MySQLdb.IntegrityError:
   72     ¦   ¦   ¦   raise CommandError('get error by insert row data "%s" ' % row)
   73     ¦   connection.commit()

i just apply a update case on ensure. could you give a suggestion.

Original comment by xia...@gmail.com on 2 Apr 2014 at 11:47

The current SlowlyChangingDimension class supports type-2 changes or type-1 and 
type-2 changes together. It is correct that the class does not support type-1 
changes alone (i.e., without type-2 support enabled).

We expect to add a class for type-1 changes alone. In the meantime, the best 
option would probably be to use update(...) as in your example.


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

  • Changed state: Accepted
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect
The new TypeOneSlowlyChangingDimension class solves this.

Original comment by c...@cs.aau.dk on 7 Apr 2015 at 9:02

  • Changed state: Fixed