Skip to content

Commit

Permalink
fix(ingest/lookml): emit all views with same name and different file …
Browse files Browse the repository at this point in the history
…path (#9279)
  • Loading branch information
mayurinehate authored Nov 24, 2023
1 parent 298b9be commit a34fdfd
Show file tree
Hide file tree
Showing 7 changed files with 755 additions and 6 deletions.
Original file line number Diff line number Diff line change
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
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
connection: "my_connection"

include: "path1/foo.view.lkml"

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

explore: duplicate_explore {
from: my_view
}
Original file line number Diff line number Diff line change
@@ -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 ;;
}

}
Original file line number Diff line number Diff line change
@@ -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 ;;
}

}
Loading

0 comments on commit a34fdfd

Please sign in to comment.