acryl-datahub 1.1.0.4rc3__py3-none-any.whl → 1.1.0.5rc2__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.

Potentially problematic release.


This version of acryl-datahub might be problematic. Click here for more details.

Files changed (41) hide show
  1. {acryl_datahub-1.1.0.4rc3.dist-info → acryl_datahub-1.1.0.5rc2.dist-info}/METADATA +2518 -2518
  2. {acryl_datahub-1.1.0.4rc3.dist-info → acryl_datahub-1.1.0.5rc2.dist-info}/RECORD +41 -36
  3. {acryl_datahub-1.1.0.4rc3.dist-info → acryl_datahub-1.1.0.5rc2.dist-info}/entry_points.txt +1 -0
  4. datahub/_version.py +1 -1
  5. datahub/ingestion/api/decorators.py +1 -0
  6. datahub/ingestion/api/sink.py +3 -0
  7. datahub/ingestion/autogenerated/__init__.py +0 -0
  8. datahub/ingestion/run/pipeline.py +1 -1
  9. datahub/ingestion/sink/datahub_rest.py +12 -0
  10. datahub/ingestion/source/cassandra/cassandra.py +1 -1
  11. datahub/ingestion/source/identity/azure_ad.py +1 -1
  12. datahub/ingestion/source/identity/okta.py +1 -1
  13. datahub/ingestion/source/mock_data/__init__.py +0 -0
  14. datahub/ingestion/source/mock_data/datahub_mock_data.py +389 -0
  15. datahub/ingestion/source/mock_data/datahub_mock_data_report.py +12 -0
  16. datahub/ingestion/source/mock_data/table_naming_helper.py +91 -0
  17. datahub/ingestion/source/preset.py +2 -2
  18. datahub/ingestion/source/snowflake/snowflake_config.py +1 -0
  19. datahub/ingestion/source/snowflake/snowflake_queries.py +42 -31
  20. datahub/ingestion/source/snowflake/snowflake_v2.py +1 -1
  21. datahub/ingestion/source/sql/mssql/source.py +15 -15
  22. datahub/ingestion/source/sql/vertica.py +1 -1
  23. datahub/ingestion/source/state/stateful_ingestion_base.py +1 -1
  24. datahub/ingestion/source/superset.py +1 -1
  25. datahub/ingestion/source/unity/source.py +1 -1
  26. datahub/metadata/_internal_schema_classes.py +3 -0
  27. datahub/metadata/schema.avsc +2 -0
  28. datahub/metadata/schemas/ContainerProperties.avsc +2 -0
  29. datahub/metadata/schemas/DataFlowInfo.avsc +2 -0
  30. datahub/metadata/schemas/DataJobInfo.avsc +2 -0
  31. datahub/metadata/schemas/DataProcessKey.avsc +2 -0
  32. datahub/metadata/schemas/DatasetKey.avsc +2 -0
  33. datahub/metadata/schemas/IcebergWarehouseInfo.avsc +2 -0
  34. datahub/metadata/schemas/MLModelDeploymentKey.avsc +2 -0
  35. datahub/metadata/schemas/MLModelGroupKey.avsc +2 -0
  36. datahub/metadata/schemas/MLModelKey.avsc +2 -0
  37. datahub/metadata/schemas/MetadataChangeEvent.avsc +2 -0
  38. datahub/sql_parsing/sql_parsing_aggregator.py +5 -2
  39. {acryl_datahub-1.1.0.4rc3.dist-info → acryl_datahub-1.1.0.5rc2.dist-info}/WHEEL +0 -0
  40. {acryl_datahub-1.1.0.4rc3.dist-info → acryl_datahub-1.1.0.5rc2.dist-info}/licenses/LICENSE +0 -0
  41. {acryl_datahub-1.1.0.4rc3.dist-info → acryl_datahub-1.1.0.5rc2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,389 @@
1
+ import logging
2
+ from typing import Dict, Iterable, List, Optional, Tuple
3
+
4
+ from pydantic import Field
5
+
6
+ from datahub.configuration.common import ConfigModel
7
+ from datahub.emitter.mce_builder import make_dataset_urn
8
+ from datahub.emitter.mcp import MetadataChangeProposalWrapper
9
+ from datahub.ingestion.api.common import PipelineContext
10
+ from datahub.ingestion.api.decorators import (
11
+ SupportStatus,
12
+ config_class,
13
+ platform_name,
14
+ support_status,
15
+ )
16
+ from datahub.ingestion.api.source import Source, SourceReport
17
+ from datahub.ingestion.api.workunit import MetadataWorkUnit
18
+ from datahub.ingestion.source.mock_data.datahub_mock_data_report import (
19
+ DataHubMockDataReport,
20
+ )
21
+ from datahub.ingestion.source.mock_data.table_naming_helper import TableNamingHelper
22
+ from datahub.metadata.schema_classes import (
23
+ DatasetLineageTypeClass,
24
+ StatusClass,
25
+ SubTypesClass,
26
+ UpstreamClass,
27
+ UpstreamLineageClass,
28
+ )
29
+ from datahub.utilities.str_enum import StrEnum
30
+
31
+ logger = logging.getLogger(__name__)
32
+
33
+
34
+ class SubTypePattern(StrEnum):
35
+ ALTERNATING = "alternating"
36
+ ALL_TABLE = "all_table"
37
+ ALL_VIEW = "all_view"
38
+ LEVEL_BASED = "level_based"
39
+
40
+
41
+ class LineageConfigGen1(ConfigModel):
42
+ """
43
+ Configuration for generating mock lineage data for testing purposes.
44
+
45
+ This configuration controls how the mock data source generates a hierarchical
46
+ lineage graph with multiple levels of upstream/downstream relationships.
47
+
48
+ The lineage graph is structured as follows:
49
+ - Level 0: 1 table (root)
50
+ - Level 1: lineage_fan_out tables (each connected to the root)
51
+ - Level 2+: If lineage_fan_out_after_first_hop is set, uses that value;
52
+ otherwise uses lineage_fan_out^level tables (each connected to a level 1 table)
53
+ - ... and so on for lineage_hops levels
54
+
55
+ Examples:
56
+ - With lineage_fan_out=2, lineage_hops=1: Creates 3 tables total
57
+ (1 root + 2 downstream) with 2 lineage relationships
58
+ - With lineage_fan_out=3, lineage_hops=2: Creates 13 tables total
59
+ (1 + 3 + 9) with 12 lineage relationships
60
+ - With lineage_fan_out=4, lineage_hops=1: Creates 5 tables total
61
+ (1 + 4) with 4 lineage relationships
62
+ - With lineage_fan_out=3, lineage_hops=3, lineage_fan_out_after_first_hop=2:
63
+ Creates 1 + 3 + 6 + 12 = 22 tables total (prevents exponential growth)
64
+
65
+ Table naming convention: "hops_{lineage_hops}_f_{lineage_fan_out}_h{level}_t{table_index}"
66
+ """
67
+
68
+ emit_lineage: bool = Field(
69
+ default=False,
70
+ description="Whether to emit lineage data for testing purposes. When False, no lineage data is generated regardless of other settings.",
71
+ )
72
+
73
+ lineage_fan_out: int = Field(
74
+ default=3,
75
+ description="Number of downstream tables that each upstream table connects to. This controls the 'width' of the lineage graph. Higher values create more parallel downstream tables per level.",
76
+ )
77
+
78
+ lineage_hops: int = Field(
79
+ default=2,
80
+ description="Number of hops (levels) in the lineage graph. This controls the 'depth' of the lineage graph. Level 0 is the root table, and each subsequent level contains downstream tables. Higher values create deeper lineage chains.",
81
+ )
82
+
83
+ lineage_fan_out_after_first_hop: Optional[int] = Field(
84
+ default=None,
85
+ description="Optional limit on fanout for hops after the first hop. When set, prevents exponential growth by limiting the number of downstream tables per upstream table at levels 2 and beyond. When None, uses the standard exponential growth (lineage_fan_out^level).",
86
+ )
87
+
88
+ subtype_pattern: SubTypePattern = Field(
89
+ default=SubTypePattern.ALTERNATING,
90
+ description="Pattern for determining SubTypes. Options: 'alternating', 'all_table', 'all_view', 'level_based'",
91
+ )
92
+
93
+ level_subtypes: Dict[int, str] = Field(
94
+ default={0: "Table", 1: "View", 2: "Table"},
95
+ description="Mapping of level to subtype for level_based pattern",
96
+ )
97
+
98
+
99
+ class DataHubMockDataConfig(ConfigModel):
100
+ enabled: bool = Field(
101
+ default=True,
102
+ description="Whether this source is enabled",
103
+ )
104
+
105
+ gen_1: LineageConfigGen1 = Field(
106
+ default_factory=LineageConfigGen1,
107
+ description="Configuration for lineage data generation",
108
+ )
109
+
110
+
111
+ @platform_name("DataHubMockData")
112
+ @config_class(DataHubMockDataConfig)
113
+ @support_status(SupportStatus.TESTING)
114
+ class DataHubMockDataSource(Source):
115
+ """
116
+ This source is for generating mock data for testing purposes.
117
+ Expect breaking changes as we iterate on the mock data source.
118
+ """
119
+
120
+ def __init__(self, ctx: PipelineContext, config: DataHubMockDataConfig):
121
+ self.ctx = ctx
122
+ self.config = config
123
+ self.report = DataHubMockDataReport()
124
+
125
+ def get_workunits(self) -> Iterable[MetadataWorkUnit]:
126
+ # We don't want any implicit aspects to be produced
127
+ # so we are not using get_workunits_internal
128
+ if self.config.gen_1.emit_lineage:
129
+ for wu in self._data_gen_1():
130
+ if self.report.first_urn_seen is None:
131
+ self.report.first_urn_seen = wu.get_urn()
132
+ self.report.report_workunit(wu)
133
+ yield wu
134
+
135
+ yield from []
136
+
137
+ def _calculate_lineage_tables(
138
+ self, fan_out: int, hops: int, fan_out_after_first: Optional[int] = None
139
+ ) -> Tuple[int, List[int]]:
140
+ """
141
+ Calculate the total number of tables and tables at each level for lineage generation.
142
+
143
+ Args:
144
+ fan_out: Number of downstream tables per upstream table at level 1
145
+ hops: Number of hops (levels) in the lineage graph
146
+ fan_out_after_first: Optional limit on fanout for hops after the first hop
147
+
148
+ Returns:
149
+ Tuple of (total_tables, tables_at_levels) where tables_at_levels is a list
150
+ containing the number of tables at each level (index 0 = level 0, etc.)
151
+ """
152
+ tables_to_be_created = 0
153
+ tables_at_levels: List[int] = []
154
+
155
+ for i in range(hops + 1):
156
+ if i == 0:
157
+ # Level 0: always 1 table
158
+ tables_at_level = 1
159
+ elif i == 1:
160
+ # Level 1: uses lineage_fan_out
161
+ tables_at_level = fan_out
162
+ else:
163
+ # Level 2+: use fan_out_after_first_hop if set, otherwise exponential growth
164
+ if fan_out_after_first is not None:
165
+ # Each table at previous level creates fan_out_after_first tables
166
+ tables_at_level = tables_at_levels[i - 1] * fan_out_after_first
167
+ else:
168
+ # Original exponential behavior
169
+ tables_at_level = fan_out**i
170
+
171
+ tables_at_levels.append(tables_at_level)
172
+ tables_to_be_created += tables_at_level
173
+
174
+ return tables_to_be_created, tables_at_levels
175
+
176
+ def _calculate_fanout_for_level(
177
+ self, level: int, fan_out: int, fan_out_after_first: Optional[int] = None
178
+ ) -> int:
179
+ """
180
+ Calculate the fanout (number of downstream tables) for a specific level.
181
+
182
+ Args:
183
+ level: The current level (0-based)
184
+ fan_out: Number of downstream tables per upstream table at level 1
185
+ fan_out_after_first: Optional limit on fanout for hops after the first hop
186
+
187
+ Returns:
188
+ The number of downstream tables that each table at this level should connect to
189
+ """
190
+ if level == 0:
191
+ # Level 0: uses the standard fan_out
192
+ return fan_out
193
+ else:
194
+ # Level 1+: use fan_out_after_first if set, otherwise use fan_out
195
+ return fan_out_after_first if fan_out_after_first is not None else fan_out
196
+
197
+ def _determine_subtype(
198
+ self, table_name: str, table_level: int, table_index: int
199
+ ) -> str:
200
+ """
201
+ Determine subtype based on configured pattern.
202
+
203
+ Args:
204
+ table_name: Name of the table
205
+ table_level: Level of the table in the lineage graph
206
+ table_index: Index of the table within its level
207
+
208
+ Returns:
209
+ The determined subtype ("Table" or "View")
210
+ """
211
+ pattern = self.config.gen_1.subtype_pattern
212
+
213
+ if pattern == SubTypePattern.ALTERNATING:
214
+ return "Table" if table_index % 2 == 0 else "View"
215
+ elif pattern == SubTypePattern.LEVEL_BASED:
216
+ return self.config.gen_1.level_subtypes.get(table_level, "Table")
217
+ elif pattern == SubTypePattern.ALL_TABLE:
218
+ return "Table"
219
+ elif pattern == SubTypePattern.ALL_VIEW:
220
+ return "View"
221
+ else:
222
+ return "Table" # default
223
+
224
+ def _get_subtypes_aspect(
225
+ self, table_name: str, table_level: int, table_index: int
226
+ ) -> MetadataWorkUnit:
227
+ """
228
+ Create a SubTypes aspect for a table based on deterministic pattern.
229
+
230
+ Args:
231
+ table_name: Name of the table
232
+ table_level: Level of the table in the lineage graph
233
+ table_index: Index of the table within its level
234
+
235
+ Returns:
236
+ MetadataWorkUnit containing the SubTypes aspect
237
+ """
238
+ # Determine subtype based on pattern
239
+ subtype = self._determine_subtype(table_name, table_level, table_index)
240
+
241
+ urn = make_dataset_urn(platform="fake", name=table_name)
242
+ mcp = MetadataChangeProposalWrapper(
243
+ entityUrn=urn,
244
+ entityType="dataset",
245
+ aspect=SubTypesClass(typeNames=[subtype]),
246
+ )
247
+ return mcp.as_workunit()
248
+
249
+ def _data_gen_1(self) -> Iterable[MetadataWorkUnit]:
250
+ """Generate mock lineage data for testing purposes."""
251
+ gen_1 = self.config.gen_1
252
+ fan_out = gen_1.lineage_fan_out
253
+ hops = gen_1.lineage_hops
254
+ fan_out_after_first = gen_1.lineage_fan_out_after_first_hop
255
+
256
+ logger.info(
257
+ f"Generating lineage data with fan_out={fan_out}, hops={hops}, fan_out_after_first={fan_out_after_first}"
258
+ )
259
+
260
+ tables_to_be_created, tables_at_levels = self._calculate_lineage_tables(
261
+ fan_out, hops, fan_out_after_first
262
+ )
263
+
264
+ logger.info(
265
+ f"About to create {tables_to_be_created} tables for lineage testing"
266
+ )
267
+
268
+ current_progress = 0
269
+ for i in range(hops + 1):
270
+ tables_at_level = tables_at_levels[i]
271
+
272
+ for j in range(tables_at_level):
273
+ table_name = TableNamingHelper.generate_table_name(hops, fan_out, i, j)
274
+
275
+ yield self._get_status_aspect(table_name)
276
+
277
+ yield self._get_subtypes_aspect(table_name, i, j)
278
+
279
+ yield from self._generate_lineage_for_table(
280
+ table_name=table_name,
281
+ table_level=i,
282
+ table_index=j,
283
+ hops=hops,
284
+ fan_out=fan_out,
285
+ fan_out_after_first=fan_out_after_first,
286
+ tables_at_levels=tables_at_levels,
287
+ )
288
+
289
+ current_progress += 1
290
+ if current_progress % 1000 == 0:
291
+ logger.info(
292
+ f"Progress: {current_progress}/{tables_to_be_created} tables processed"
293
+ )
294
+
295
+ def _generate_lineage_for_table(
296
+ self,
297
+ table_name: str,
298
+ table_level: int,
299
+ table_index: int,
300
+ hops: int,
301
+ fan_out: int,
302
+ fan_out_after_first: Optional[int],
303
+ tables_at_levels: List[int],
304
+ ) -> Iterable[MetadataWorkUnit]:
305
+ """Generate lineage relationships for a specific table."""
306
+ # Only generate lineage if there are downstream levels
307
+ if table_level + 1 > hops:
308
+ return
309
+
310
+ current_fan_out = self._calculate_fanout_for_level(
311
+ table_level, fan_out, fan_out_after_first
312
+ )
313
+
314
+ yield from self._generate_downstream_lineage(
315
+ upstream_table_name=table_name,
316
+ upstream_table_index=table_index,
317
+ upstream_table_level=table_level,
318
+ current_fan_out=current_fan_out,
319
+ hops=hops,
320
+ fan_out=fan_out,
321
+ tables_at_levels=tables_at_levels,
322
+ )
323
+
324
+ def _generate_downstream_lineage(
325
+ self,
326
+ upstream_table_name: str,
327
+ upstream_table_index: int,
328
+ upstream_table_level: int,
329
+ current_fan_out: int,
330
+ hops: int,
331
+ fan_out: int,
332
+ tables_at_levels: List[int],
333
+ ) -> Iterable[MetadataWorkUnit]:
334
+ """Generate lineage relationships to downstream tables."""
335
+ downstream_level = upstream_table_level + 1
336
+ downstream_tables_count = tables_at_levels[downstream_level]
337
+
338
+ # Calculate range of downstream tables this upstream table connects to
339
+ start_downstream = upstream_table_index * current_fan_out
340
+ end_downstream = min(
341
+ (upstream_table_index + 1) * current_fan_out, downstream_tables_count
342
+ )
343
+
344
+ for downstream_index in range(start_downstream, end_downstream):
345
+ downstream_table_name = TableNamingHelper.generate_table_name(
346
+ hops, fan_out, downstream_level, downstream_index
347
+ )
348
+ yield self._get_upstream_aspect(
349
+ upstream_table=upstream_table_name,
350
+ downstream_table=downstream_table_name,
351
+ )
352
+
353
+ def _get_status_aspect(self, table: str) -> MetadataWorkUnit:
354
+ urn = make_dataset_urn(
355
+ platform="fake",
356
+ name=table,
357
+ )
358
+ mcp = MetadataChangeProposalWrapper(
359
+ entityUrn=urn,
360
+ entityType="dataset",
361
+ aspect=StatusClass(removed=False),
362
+ )
363
+ return mcp.as_workunit()
364
+
365
+ def _get_upstream_aspect(
366
+ self, upstream_table: str, downstream_table: str
367
+ ) -> MetadataWorkUnit:
368
+ mcp = MetadataChangeProposalWrapper(
369
+ entityUrn=make_dataset_urn(
370
+ platform="fake",
371
+ name=downstream_table,
372
+ ),
373
+ entityType="dataset",
374
+ aspect=UpstreamLineageClass(
375
+ upstreams=[
376
+ UpstreamClass(
377
+ dataset=make_dataset_urn(
378
+ platform="fake",
379
+ name=upstream_table,
380
+ ),
381
+ type=DatasetLineageTypeClass.TRANSFORMED,
382
+ )
383
+ ],
384
+ ),
385
+ )
386
+ return mcp.as_workunit()
387
+
388
+ def get_report(self) -> SourceReport:
389
+ return self.report
@@ -0,0 +1,12 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import Optional
3
+
4
+ from datahub.ingestion.api.source import SourceReport
5
+
6
+
7
+ @dataclass
8
+ class DataHubMockDataReport(SourceReport):
9
+ first_urn_seen: Optional[str] = field(
10
+ default=None,
11
+ metadata={"description": "The first URN encountered during ingestion"},
12
+ )
@@ -0,0 +1,91 @@
1
+ from typing import Dict
2
+
3
+
4
+ class TableNamingHelper:
5
+ """
6
+ Helper class for managing table naming conventions in mock data generation.
7
+
8
+ Table naming pattern: "hops_{lineage_hops}_f_{lineage_fan_out}_h{level}_t{table_index}"
9
+ """
10
+
11
+ @staticmethod
12
+ def generate_table_name(
13
+ lineage_hops: int, lineage_fan_out: int, level: int, table_index: int
14
+ ) -> str:
15
+ """
16
+ Generate a table name following the standard naming convention.
17
+
18
+ Args:
19
+ lineage_hops: Total number of hops in the lineage graph
20
+ lineage_fan_out: Number of downstream tables per upstream table
21
+ level: Level of the table in the lineage graph (0-based)
22
+ table_index: Index of the table within its level (0-based)
23
+
24
+ Returns:
25
+ Table name following the pattern: "hops_{lineage_hops}_f_{lineage_fan_out}_h{level}_t{table_index}"
26
+ """
27
+ return f"hops_{lineage_hops}_f_{lineage_fan_out}_h{level}_t{table_index}"
28
+
29
+ @staticmethod
30
+ def parse_table_name(table_name: str) -> Dict[str, int]:
31
+ """
32
+ Parse a table name to extract its components.
33
+
34
+ Args:
35
+ table_name: Table name following the standard naming convention
36
+
37
+ Returns:
38
+ Dictionary containing parsed components:
39
+ - lineage_hops: Total number of hops in the lineage graph
40
+ - lineage_fan_out: Number of downstream tables per upstream table
41
+ - level: Level of the table in the lineage graph (0-based)
42
+ - table_index: Index of the table within its level (0-based)
43
+
44
+ Raises:
45
+ ValueError: If the table name doesn't follow the expected pattern
46
+ """
47
+ try:
48
+ # Expected pattern: "hops_{lineage_hops}_f_{lineage_fan_out}_h{level}_t{table_index}"
49
+ parts = table_name.split("_")
50
+
51
+ if (
52
+ len(parts) != 6
53
+ or parts[0] != "hops"
54
+ or parts[2] != "f"
55
+ or not parts[4].startswith("h")
56
+ or not parts[5].startswith("t")
57
+ ):
58
+ raise ValueError(f"Invalid table name format: {table_name}")
59
+
60
+ lineage_hops = int(parts[1])
61
+ lineage_fan_out = int(parts[3]) # lineage_fan_out is at index 3
62
+ level = int(parts[4][1:]) # Remove 'h' prefix from parts[4]
63
+ table_index = int(parts[5][1:]) # Remove 't' prefix from parts[5]
64
+
65
+ return {
66
+ "lineage_hops": lineage_hops,
67
+ "lineage_fan_out": lineage_fan_out,
68
+ "level": level,
69
+ "table_index": table_index,
70
+ }
71
+ except (ValueError, IndexError) as e:
72
+ raise ValueError(
73
+ f"Failed to parse table name '{table_name}': {str(e)}"
74
+ ) from e
75
+
76
+ @staticmethod
77
+ def is_valid_table_name(table_name: str) -> bool:
78
+ """
79
+ Check if a table name follows the expected naming convention.
80
+
81
+ Args:
82
+ table_name: Table name to validate
83
+
84
+ Returns:
85
+ True if the table name follows the expected pattern, False otherwise
86
+ """
87
+ try:
88
+ TableNamingHelper.parse_table_name(table_name)
89
+ return True
90
+ except ValueError:
91
+ return False
@@ -69,9 +69,9 @@ class PresetConfig(SupersetConfig):
69
69
 
70
70
  @platform_name("Preset")
71
71
  @config_class(PresetConfig)
72
- @support_status(SupportStatus.TESTING)
72
+ @support_status(SupportStatus.CERTIFIED)
73
73
  @capability(
74
- SourceCapability.DELETION_DETECTION, "Optionally enabled via stateful_ingestion"
74
+ SourceCapability.DELETION_DETECTION, "Enabled by default via stateful ingestion"
75
75
  )
76
76
  class PresetSource(SupersetSource):
77
77
  """
@@ -49,6 +49,7 @@ DEFAULT_TEMP_TABLES_PATTERNS = [
49
49
  rf".*\.SEGMENT_{UUID_REGEX}", # segment
50
50
  rf".*\.STAGING_.*_{UUID_REGEX}", # stitch
51
51
  r".*\.(GE_TMP_|GE_TEMP_|GX_TEMP_)[0-9A-F]{8}", # great expectations
52
+ r".*\.SNOWPARK_TEMP_TABLE_.+", # snowpark
52
53
  ]
53
54
 
54
55