-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exposure updated format #175
Merged
gouline
merged 4 commits into
gouline:exposure-updated-format
from
elementary-data:exposure-updated-format
Oct 5, 2023
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -645,7 +645,6 @@ def increase_indent(self, flow=False, indentless=False): | |
parsed_exposures = [] | ||
|
||
for collection in self.collections: | ||
|
||
# Exclude collections by name | ||
if collection["name"] in collection_excludes: | ||
continue | ||
|
@@ -657,7 +656,6 @@ def increase_indent(self, flow=False, indentless=False): | |
# Iter through collection | ||
logger().info(":sparkles: Exploring collection %s", collection["name"]) | ||
for item in self.api("get", f"/api/collection/{collection['id']}/items"): | ||
|
||
# Ensure collection item is of parsable type | ||
exposure_type = item["model"] | ||
exposure_id = item["id"] | ||
|
@@ -678,7 +676,6 @@ def increase_indent(self, flow=False, indentless=False): | |
|
||
# Process exposure | ||
if exposure_type == "card": | ||
|
||
# Build header for card and extract models to self.models_exposed | ||
header = "### Visualization: {}\n\n".format( | ||
exposure.get("display", "Unknown").title() | ||
|
@@ -689,7 +686,6 @@ def increase_indent(self, flow=False, indentless=False): | |
native_query = self.native_query | ||
|
||
elif exposure_type == "dashboard": | ||
|
||
# We expect this dict key in order to iter through questions | ||
if "ordered_cards" not in exposure: | ||
continue | ||
|
@@ -730,8 +726,8 @@ def increase_indent(self, flow=False, indentless=False): | |
creator_name = creator.get("common_name") | ||
|
||
exposure_label = exposure_name | ||
# Only letters, numbers, underscores and hyphens allowed in model names in dbt docs DAG / No duplicate model names | ||
exposure_name = re.sub(r"[^\w-]", "_", exposure_name) | ||
# Only letters, numbers, underscores are allowed in model names in dbt docs DAG / No duplicate model names | ||
exposure_name = re.sub(r"[^\w]", "_", exposure_name).lower() | ||
enumer = 1 | ||
while exposure_name in documented_exposure_names: | ||
exposure_name = f"{exposure_name}_{enumer}" | ||
|
@@ -824,7 +820,6 @@ def _extract_card_exposures( | |
|
||
# Find models exposed through joins | ||
for query_join in query.get("query", {}).get("joins", []): | ||
|
||
# Handle questions based on other question in virtual db | ||
if str(query_join.get("source-table", "")).startswith("card__"): | ||
self._extract_card_exposures( | ||
|
@@ -853,7 +848,6 @@ def _extract_card_exposures( | |
|
||
# Parse SQL for exposures through FROM or JOIN clauses | ||
for sql_ref in re.findall(self.exposure_parser, native_query): | ||
|
||
# Grab just the table / model name | ||
clean_exposure = sql_ref.split(".")[-1].strip('"').upper() | ||
|
||
|
@@ -951,11 +945,15 @@ def _build_exposure( | |
"name": creator_name, | ||
"email": creator_email or "", | ||
}, | ||
"depends_on": [ | ||
refable_models[exposure.upper()] | ||
for exposure in list({m for m in self.models_exposed}) | ||
if exposure.upper() in refable_models | ||
], | ||
"depends_on": list( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deduping in case a dashboard has two views on the same table. |
||
set( | ||
[ | ||
refable_models[exposure.upper()] | ||
for exposure in list({m for m in self.models_exposed}) | ||
if exposure.upper() in refable_models | ||
] | ||
) | ||
), | ||
} | ||
|
||
def api( | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert irrelevant changes.