sandwich 0.2.1__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,164 +1,179 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.3
2
2
  Name: sandwich
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: DataVault 2.0 code gen
5
- Author-email: Andrey Morozov <andrey@morozov.lv>
6
- License-File: LICENSE
7
5
  Keywords: DWH,Data Vault 2.0
8
- Classifier: Development Status :: 1 - Planning
9
- Classifier: Environment :: Console
10
- Classifier: Intended Audience :: Developers
6
+ Author: Andrey Morozov
7
+ Author-email: Andrey Morozov <andrey@morozov.lv>
8
+ Classifier: Programming Language :: Python :: 3
11
9
  Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Topic :: Database
12
11
  Classifier: Operating System :: OS Independent
13
- Classifier: Programming Language :: Python :: 3
12
+ Classifier: Environment :: Console
13
+ Classifier: Development Status :: 2 - Pre-Alpha
14
+ Classifier: Intended Audience :: Developers
14
15
  Classifier: Typing :: Typed
15
- Requires-Python: >=3.14
16
16
  Requires-Dist: sqlalchemy
17
+ Requires-Python: >=3.14
17
18
  Description-Content-Type: text/markdown
18
19
 
19
- ## Data Vault 2.0 scaffolding tool
20
- This tool is designed to streamline the process of creating Data Vault 2.0 entities,
21
- such as hubs, links, and satellites.
22
- As well as building information layer objects such as dim and fact tables
23
- from a multidimensional paradigm.
24
-
25
- ### How it works:
26
- User: provides a staging view `stg.[entity_name]` (or a table if the staging layer persisted)
27
- with all requirements for the `[entity_name]` defined in the schema (how to define see below).
28
- Tool:
29
- 1. Validates metadata of the provided staging view or table.
30
- 2. Generates the necessary DDL statements to create the Data Vault 2.0 entities.
31
- 3. Generates ELT procedures to load data to the generated entities.
32
- 4. Generates support procedures such as `meta.Drop_all_related_to_[entity_name]` and `elt.Run_all_related_to_[entity_name]`
33
-
34
- ```text
35
- +----------------------+
36
- | hub.[entity_name] |
37
- +----------------------+
38
- ^
39
- o 1.define +-------------------+ | 3.create
40
- /|\ -------> | stg.[entity_name] | # +----------------------+
41
- / \ +-------------------+ /|\ ---------> | sat.[entity_name] |
42
- User ---------------------------------------> / \ 3.create +----------------------+
43
- 2.use Tool
44
- | 3.create
45
- v
46
- +----------------------+
47
- | dim.[entity_name] |
48
- +----------------------+
49
-
50
- ```
51
-
52
- ### How to define a staging view or table:
53
- * `bk_` (BusinessKey) - at least one `bk_` column
54
- * `hk_[entity_name]` (HashKey) - exactly one `hk_[entity_name]` column if you want a `hub` table created
55
- * `LoadDate` - required by dv2 standard for an auditability
56
- * `RecordSource` - required by dv2 standard for an auditability
57
- * `HashDiff` - optional, required if you want to have a scd2 type `dim` table created
58
- * `IsAvailable` - optional, required if you want to track missing/deleted records
59
- * all other columns will be considered as business columns and will be included to the `sat` table definition
60
-
61
-
62
- | staging fields | scd2dim profile |
63
- |--------------------|-----------------|
64
- | bk_ | ✅ |
65
- | hk_`[entity_name]` | ✅ |
66
- | LoadDate | ✅ |
67
- | RecordSource | ✅ |
68
- | HashDiff | ✅ |
69
- | IsAvailable | ✅ |
70
-
71
- ```sql
72
- -- staging view example for the scd2dim profile (mssql)
73
- create view [stg].[UR_officers] as
74
- select cast(31 as bigint) [bk_id]
75
- , core.StringToHash1(cast(31 as bigint)) [hk_UR_officers]
76
- , sysdatetime() [LoadDate]
77
- , cast('LobSystem.dbo.officers_daily' as varchar(200)) [RecordSource]
78
- , core.StringToHash8(
79
- cast('uri' as nvarchar(100))
80
- , cast('00000000000000' as varchar(20))
81
- , cast('NATURAL_PERSON' as varchar(50))
82
- , cast(null as varchar(20))
83
- , cast('INDIVIDUALLY' as varchar(50))
84
- , cast(0 as int)
85
- , cast('2008-04-07' as date)
86
- , cast('2008-04-07 18:00:54.000' as datetime)
87
- ) [HashDiff]
88
- , cast('uri' as nvarchar(100)) [uri]
89
- , cast('00000000000000' as varchar(20)) [at_legal_entity_registration_number]
90
- , cast('NATURAL_PERSON' as varchar(50)) [entity_type]
91
- , cast(null as varchar(20)) [legal_entity_registration_number]
92
- , cast('INDIVIDUALLY' as varchar(50)) [rights_of_representation_type]
93
- , cast(0 as int) [representation_with_at_least]
94
- , cast('2008-04-07' as date) [registered_on]
95
- , cast('2008-04-07 18:00:54.000' as datetime) [last_modified_at]
96
- , cast(1 as bit) [IsAvailable]
97
- ```
98
- ### scd2dim profile example:
99
- | stg | hub | sat | dim |
100
- |--------------------|------------------------|----------------------------|--------------------|
101
- | | | | hk_`[entity_name]` |
102
- | BKs... | (uk)BKs... | BKs... | (pk)BKs... |
103
- | hk_`[entity_name]` | (pk)hk_`[entity_name]` | (pk)(fk)hk_`[entity_name]` | |
104
- | LoadDate | LoadDate | (pk)LoadDate | |
105
- | RecordSource | RecordSource | RecordSource | |
106
- | HashDiff | | HashDiff | |
107
- | FLDs... | | FLDs... | FLDs... |
108
- | IsAvailable | | IsAvailable | IsAvailable |
109
- | | | | IsCurrent |
110
- | | | | (pk)DateFrom |
111
- | | | | DateTo |
112
-
113
- ### link2fact profile example:
114
- | stg | link | sat | fact |
115
- |--------------------|------------------------|----------------------------|------|
116
- | HKs... | (uk)(fk)HKs... | | |
117
- | hk_`[entity_name]` | (pk)hk_`[entity_name]` | (pk)(fk)hk_`[entity_name]` | |
118
- | degenerate_field | (uk)degenerate_field | degenerate_field | |
119
- | LoadDate | LoadDate | LoadDate | |
120
- | RecordSource | RecordSource | RecordSource | |
121
- | FLDs... | | FLDs... | |
122
-
123
-
124
- ### Schemas:
125
- * `core` - framework-related code
126
- * `stg` - staging layer for both virtual (views) and materialized (tables)
127
- * `hub` - hub layer
128
- * `sat` - satellite layer
129
- * `dim` - dimension layer (information vault)
130
- * `fact` - fact layer (information vault)
131
- * `elt` - ELT procedures
132
- * `job` - top level ELT procedures
133
- * `meta` - metadata vault
134
- * `proxy` - source data for materialized staging area (meant for wrapping external data sources as SQL views)
135
-
136
- ### DV2-related schemas layering
137
- | LoB* | staging | raw vault | business vault | information vault |
138
- |-------|---------|-----------|----------------|-------------------|
139
- | proxy | stg | hub | sal | dim |
140
- | | | sat | | fact |
141
- | | | link | | |
142
- _* Line of Business applications_
143
-
144
- ### Usage diagram
145
- ```text
146
- + +-----------+ automation
147
- +---- + -------> | Dv2Utils | -------+------+
148
- | + uses +-----------+ |
149
- | + | uses | creates
150
- | + v |
151
- | + uses +-----------+ uses |
152
- +---- + -------> | Dv2Helper | --------------+
153
- | + +-----------+ |
154
- o + | |
155
- /|\ + | DDL | python
156
- / \ ==========================================================
157
- DWH Dev + creates | | database
158
- | + v V
159
- | + uses +--------+ uses +---------------+
160
- +---- + -------> | entity | -----> | core objects |
161
- + +--------+ +---------------+
162
- +
163
-
164
- ```
20
+ ## Data Vault 2.0 scaffolding tool
21
+ This tool is designed to streamline the process of creating Data Vault 2.0 entities,
22
+ such as hubs, links, and satellites.
23
+ As well as building information layer objects such as dim and fact tables
24
+ from a multidimensional paradigm.
25
+
26
+ ### How it works:
27
+ User: provides a staging view `stg.[entity_name]` (or a table if the staging layer persisted)
28
+ with all requirements for the `[entity_name]` defined in the schema (how to define see below).
29
+ Tool:
30
+ 1. Validates metadata of the provided staging view or table.
31
+ 2. Generates the necessary DDL statements to create the Data Vault 2.0 entities.
32
+ 3. Generates ELT procedures to load data to the generated entities.
33
+ 4. Generates support procedures such as `meta.Drop_all_related_to_[entity_name]` and `elt.Run_all_related_to_[entity_name]`
34
+
35
+ #### App design (layers):
36
+ DV2Modeler (service)
37
+ 1. gets user input (stg) and analyzes it, producing `stg_info`
38
+ 2. chooses strategy (`scd2dim`, `link2fact`)
39
+
40
+ Strategy (algorithm)
41
+ 1. validates staging using `stg_info`
42
+ 2. generates schema using dialects handler
43
+
44
+ Dialect handler (repository)
45
+ 1. creates DB objects for postgres or MSSQL database
46
+
47
+ ```text
48
+ +----------------------+
49
+ | hub.[entity_name] |
50
+ +----------------------+
51
+ ^
52
+ o 1.define +-------------------+ | 3.create
53
+ /|\ -------> | stg.[entity_name] | # +----------------------+
54
+ / \ +-------------------+ /|\ ---------> | sat.[entity_name] |
55
+ User ---------------------------------------> / \ 3.create +----------------------+
56
+ 2.use Tool
57
+ | 3.create
58
+ v
59
+ +----------------------+
60
+ | dim.[entity_name] |
61
+ +----------------------+
62
+
63
+ ```
64
+
65
+ ### How to define a staging view or table:
66
+ * `bk_` (BusinessKey) - at least one `bk_` column
67
+ * `hk_[entity_name]` (HashKey) - exactly one `hk_[entity_name]` column if you want a `hub` table created
68
+ * `LoadDate` - required by dv2 standard for an auditability
69
+ * `RecordSource` - required by dv2 standard for an auditability
70
+ * `HashDiff` - optional, required if you want to have a scd2 type `dim` table created
71
+ * `IsAvailable` - optional, required if you want to track missing/deleted records
72
+ * all other columns will be considered as business columns and will be included to the `sat` table definition
73
+
74
+
75
+ | staging fields | scd2dim profile | link2fact profile |
76
+ |--------------------|-----------------|-------------------|
77
+ | bk_ | ✅ | |
78
+ | hk_`[entity_name]` | ✅ | |
79
+ | LoadDate | ✅ | |
80
+ | RecordSource | ✅ | |
81
+ | HashDiff | ✅ | |
82
+ | IsAvailable | ✅ | |
83
+
84
+ ```sql
85
+ -- staging view example for the scd2dim profile (mssql)
86
+ create view [stg].[UR_officers] as
87
+ select cast(31 as bigint) [bk_id]
88
+ , core.StringToHash1(cast(31 as bigint)) [hk_UR_officers]
89
+ , sysdatetime() [LoadDate]
90
+ , cast('LobSystem.dbo.officers_daily' as varchar(200)) [RecordSource]
91
+ , core.StringToHash8(
92
+ cast('uri' as nvarchar(100))
93
+ , cast('00000000000000' as varchar(20))
94
+ , cast('NATURAL_PERSON' as varchar(50))
95
+ , cast(null as varchar(20))
96
+ , cast('INDIVIDUALLY' as varchar(50))
97
+ , cast(0 as int)
98
+ , cast('2008-04-07' as date)
99
+ , cast('2008-04-07 18:00:54.000' as datetime)
100
+ ) [HashDiff]
101
+ , cast('uri' as nvarchar(100)) [uri]
102
+ , cast('00000000000000' as varchar(20)) [at_legal_entity_registration_number]
103
+ , cast('NATURAL_PERSON' as varchar(50)) [entity_type]
104
+ , cast(null as varchar(20)) [legal_entity_registration_number]
105
+ , cast('INDIVIDUALLY' as varchar(50)) [rights_of_representation_type]
106
+ , cast(0 as int) [representation_with_at_least]
107
+ , cast('2008-04-07' as date) [registered_on]
108
+ , cast('2008-04-07 18:00:54.000' as datetime) [last_modified_at]
109
+ , cast(1 as bit) [IsAvailable]
110
+ ```
111
+ ### scd2dim profile columns mapping:
112
+ | stg | hub | sat | dim |
113
+ |--------------------|------------------------|----------------------------|--------------------|
114
+ | | | | hk_`[entity_name]` |
115
+ | BKs... | (uk)BKs... | BKs... | (pk)BKs... |
116
+ | hk_`[entity_name]` | (pk)hk_`[entity_name]` | (pk)(fk)hk_`[entity_name]` | |
117
+ | LoadDate | LoadDate | (pk)LoadDate | |
118
+ | RecordSource | RecordSource | RecordSource | |
119
+ | HashDiff | | HashDiff | |
120
+ | FLDs... | | FLDs... | FLDs... |
121
+ | IsAvailable | | IsAvailable | IsAvailable |
122
+ | | | | IsCurrent |
123
+ | | | | (pk)DateFrom |
124
+ | | | | DateTo |
125
+
126
+ ### link2fact profile columns mapping:
127
+ | stg | link | sat | fact |
128
+ |--------------------|--------------------------------|----------------------------|------|
129
+ | HKs... | (uk)(fk)hk_`other_entity_name` | | |
130
+ | hk_`[entity_name]` | (pk)hk_`[entity_name]` | (pk)(fk)hk_`[entity_name]` | |
131
+ | <degenerate_field> | (uk)<degenerate_field> | <degenerate_field> | |
132
+ | LoadDate | LoadDate | LoadDate | |
133
+ | RecordSource | RecordSource | RecordSource | |
134
+ | FLDs... | | FLDs... | |
135
+
136
+
137
+ ### Schemas:
138
+ * `core` - framework-related code
139
+ * `stg` - staging layer for both virtual (views) and materialized (tables)
140
+ * `hub` - hub tables
141
+ * `sat` - satellite tables
142
+ * `dim` - dimension tables (information vault)
143
+ * `fact` - fact tables (information vault)
144
+ * `elt` - ELT procedures
145
+ * `job` - top level ELT procedures
146
+ * `meta` - metadata vault
147
+ * `proxy` - source data for a materialized staging area (meant for wrapping external data sources as SQL views)
148
+
149
+ ### DV2-related schemas layering
150
+ data -> ELT -> report
151
+
152
+ | LoB* data | staging (E) | raw vault (L) | business vault (T) | information vault |
153
+ |-----------|-------------|---------------|--------------------|-------------------|
154
+ | | stg | hub | sal | dim |
155
+ | | proxy | sat | | fact |
156
+ | | pool | link | | |
157
+ _* Line of Business applications_
158
+
159
+ ### Usage diagram
160
+ ```text
161
+ + +-----------+ automation
162
+ +---- + -------> | Dv2Utils | -------+------+
163
+ | + uses +-----------+ |
164
+ | + | uses | creates
165
+ | + v |
166
+ | + uses +-----------+ uses |
167
+ +---- + -------> | Dv2Helper | --------------+
168
+ | + +-----------+ |
169
+ o + | |
170
+ /|\ + | DDL | python
171
+ / \ ==========================================================
172
+ DWH Dev + creates | | database
173
+ | + v V
174
+ | + uses +--------+ uses +---------------+
175
+ +---- + -------> | entity | -----> | core objects |
176
+ + +--------+ +---------------+
177
+ +
178
+
179
+ ```
@@ -0,0 +1,23 @@
1
+ sandwich/__init__.py,sha256=DiQSmvml9OXujAYHILR4jz8UjoxbMvxFgRIlsdRza1E,80
2
+ sandwich/dialects/__init__.py,sha256=zQ4oigT3yqjZyl_IL_Tc-GmyoJar_Oqj_bGyiRVdSjg,415
3
+ sandwich/dialects/base.py,sha256=5wRh4T4e-SJbB-8eYtyQhd01HG-c0-x52tda7HFzSGs,3759
4
+ sandwich/dialects/ddl_mssql.py,sha256=VkwkJ373hDQNe2y9d9M3YJCdeCJmleUzk1hxvJjEhbA,3362
5
+ sandwich/dialects/ddl_postgres.py,sha256=Mdk2dAcSp8Nwc0p98nCnRtQ3vT09lH-cJVa6SdLLuwg,2995
6
+ sandwich/dialects/factory.py,sha256=-mpWGKp8NRmTFCXVlhbTsGhR0oAwOEdm-xnBolwWrQo,911
7
+ sandwich/dialects/mssql.py,sha256=laSPSfZR38aP3DBDHxv0YKwXC60kevVpyqjUmVu1xhk,10226
8
+ sandwich/dialects/postgres.py,sha256=8wVuqKqVxT0Mch6opK81qAyP-UaVDz5OvCuC5LEbe-U,4030
9
+ sandwich/dialects/utils.py,sha256=mdFp5jkJquhnYB3wiRjRunsGcHtmpcbjBzzgONfbM7w,5774
10
+ sandwich/dwh/__init__.py,sha256=e1Pev1TtNBO0rikHY8GrkfjcSdu8ow7xadlqvpiIHwE,4157
11
+ sandwich/errors.py,sha256=kIJmYbUf9wOnshJbFHwhqxZ3qEEdVtOy5Dcb2bSdnAk,872
12
+ sandwich/main.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ sandwich/modeling/__init__.py,sha256=owIplBqXoHBoiQ2D_zmckaFsXcXEl4kgT3HwBqPuLUU,4091
14
+ sandwich/modeling/strategies/__init__.py,sha256=VePgBfvPCLl4_GJIWlbN-VbWjB7iD0ztPjMYuzIsi3U,403
15
+ sandwich/modeling/strategies/base.py,sha256=_5mWrQEmyx5BESIxaZ6eC7GZjCoFQNJ9p0gXqDfGBVA,3583
16
+ sandwich/modeling/strategies/factory.py,sha256=Lc1MugJ-3g335lcXb3H4mVJgD0toDTYR-dmsK6-n1Yw,1598
17
+ sandwich/modeling/strategies/link2fact.py,sha256=KPaccOWqMmpiXA6U9Pb7IAhSQAl-xN3QaiX4jVcWRIY,9229
18
+ sandwich/modeling/strategies/scd2dim.py,sha256=qHlMj800lk6W7ipT9LsM_sND-EqYVttE5qIqEGGHmk8,10194
19
+ sandwich/py.typed,sha256=70pF0eMpuZgOyb0zFSE07ugId_AoU5z6CpLlVfg3pik,34
20
+ sandwich-0.3.0.dist-info/WHEEL,sha256=YUH1mBqsx8Dh2cQG2rlcuRYUhJddG9iClegy4IgnHik,79
21
+ sandwich-0.3.0.dist-info/entry_points.txt,sha256=0GSrDEOq9Qo5CwxppoVq-HNcILK65PchNmI6J0ripq8,44
22
+ sandwich-0.3.0.dist-info/METADATA,sha256=KccsRqwgn-UPVEDAUkmfekTHaYw3SVRlJW-0RByVnAM,9127
23
+ sandwich-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.9.11
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ sandwich = sandwich:main
3
+
@@ -1,5 +0,0 @@
1
- sandwich/py.typed,sha256=70pF0eMpuZgOyb0zFSE07ugId_AoU5z6CpLlVfg3pik,34
2
- sandwich-0.2.1.dist-info/METADATA,sha256=3v9XmGospGdT5N66wOySHQTwVxK94AoxOwig_mF5t9E,8237
3
- sandwich-0.2.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
4
- sandwich-0.2.1.dist-info/licenses/LICENSE,sha256=kyN6iPdQMWMA8kquZpbnZvnPQDi9WMlyyXAPtlevrFQ,1080
5
- sandwich-0.2.1.dist-info/RECORD,,
@@ -1,4 +0,0 @@
1
- Wheel-Version: 1.0
2
- Generator: hatchling 1.28.0
3
- Root-Is-Purelib: true
4
- Tag: py3-none-any
@@ -1,9 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Andrey Morozov
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.