Skip to content
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

fix(ingest/lookml): emit all views with same name and different file path #9279

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1982,9 +1982,16 @@ def get_internal_workunits(self) -> Iterable[MetadataWorkUnit]: # noqa: C901
self.reporter,
)

# some views can be mentioned by multiple 'include' statements and can be included via different connections.
# So this set is used to prevent creating duplicate events
# Some views can be mentioned by multiple 'include' statements and can be included via different connections.

# This map is used to keep track of which views files have already been processed
# for a connection in order to prevent creating duplicate events.
# Key: connection name, Value: view file paths
processed_view_map: Dict[str, Set[str]] = {}

# This map is used to keep track of the connection that a view is processed with.
# Key: view unique identifier - determined by variables present in config `view_naming_pattern`
# Value: Tuple(model file name, connection name)
view_connection_map: Dict[str, Tuple[str, str]] = {}

# The ** means "this directory and all subdirectories", and hence should
Expand Down Expand Up @@ -2148,13 +2155,17 @@ def get_internal_workunits(self) -> Iterable[MetadataWorkUnit]: # noqa: C901
if self.source_config.view_pattern.allowed(
maybe_looker_view.id.view_name
):
view_urn = maybe_looker_view.id.get_urn(
self.source_config
)
view_connection_mapping = view_connection_map.get(
maybe_looker_view.id.view_name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a comment explaining what we expect the keys of view_connection_map to be?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

view_urn
)
if not view_connection_mapping:
view_connection_map[
maybe_looker_view.id.view_name
] = (model_name, model.connection)
view_connection_map[view_urn] = (
model_name,
model.connection,
)
# first time we are discovering this view
logger.debug(
f"Generating MCP for view {raw_view['name']}"
Expand Down
@@ -0,0 +1,7 @@
connection: "my_connection"

include: "path1/foo.view.lkml"

explore: aliased_explore {
from: my_view
}
@@ -0,0 +1,6 @@
connection: "my_connection"
include: "path2/foo.view.lkml"

explore: duplicate_explore {
from: my_view
}
@@ -0,0 +1,47 @@
view: my_view {
derived_table: {
sql:
SELECT
is_latest,
country,
city,
timestamp,
measurement
FROM
my_table ;;
}

dimension: country {
type: string
description: "The country"
sql: ${TABLE}.country ;;
}

dimension: city {
type: string
description: "City"
sql: ${TABLE}.city ;;
}

dimension: is_latest {
type: yesno
description: "Is latest data"
sql: ${TABLE}.is_latest ;;
}

dimension_group: timestamp {
group_label: "Timestamp"
type: time
description: "Timestamp of measurement"
sql: ${TABLE}.timestamp ;;
timeframes: [hour, date, week, day_of_week]
}

measure: average_measurement {
group_label: "Measurement"
type: average
description: "My measurement"
sql: ${TABLE}.measurement ;;
}

}
@@ -0,0 +1,41 @@
view: my_view {
derived_table: {
sql:
SELECT
is_latest,
country,
city,
timestamp,
measurement
FROM
my_table ;;
}

dimension: city {
type: string
description: "City"
sql: ${TABLE}.city ;;
}

dimension: is_latest {
type: yesno
description: "Is latest data"
sql: ${TABLE}.is_latest ;;
}

dimension_group: timestamp {
group_label: "Timestamp"
type: time
description: "Timestamp of measurement"
sql: ${TABLE}.timestamp ;;
timeframes: [hour, date, week, day_of_week]
}

measure: average_measurement {
group_label: "Measurement"
type: average
description: "My measurement"
sql: ${TABLE}.measurement ;;
}

}