diff --git a/ingestion/src/metadata/ingestion/source/database/common_db_source.py b/ingestion/src/metadata/ingestion/source/database/common_db_source.py index 08cddc27835..024c59b9efd 100644 --- a/ingestion/src/metadata/ingestion/source/database/common_db_source.py +++ b/ingestion/src/metadata/ingestion/source/database/common_db_source.py @@ -478,6 +478,12 @@ class CommonDbSourceService( """Not Implemented""" yield from [] + def get_location_path(self, table_name: str, schema_name: str) -> Optional[str]: + """ + Method to fetch the location path of the table + by default there will be no location path + """ + @calculate_execution_time_generator() def yield_table( self, table_name_and_type: Tuple[str, TableType] @@ -553,6 +559,9 @@ class CommonDbSourceService( table_type=table_type, ), owners=self.get_owner_ref(table_name=table_name), + locationPath=self.get_location_path( + table_name=table_name, schema_name=schema_name + ), ) is_partitioned, partition_details = self.get_table_partition_details( diff --git a/ingestion/src/metadata/ingestion/source/database/databricks/metadata.py b/ingestion/src/metadata/ingestion/source/database/databricks/metadata.py index 6f142931c83..a0d748f1e08 100644 --- a/ingestion/src/metadata/ingestion/source/database/databricks/metadata.py +++ b/ingestion/src/metadata/ingestion/source/database/databricks/metadata.py @@ -705,6 +705,14 @@ class DatabricksSource(ExternalTableLineageMixin, CommonDbSourceService, MultiDB ) return description + def get_location_path(self, table_name: str, schema_name: str) -> Optional[str]: + """ + Method to fetch the location path of the table + """ + return self.external_location_map.get( + (self.context.get().database, schema_name, table_name) + ) + def _filter_owner_name(self, owner_name: str) -> str: """remove unnecessary keyword from name""" pattern = r"\(Unknown\)" diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java index 31a58599e32..f490c355a66 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java @@ -1114,6 +1114,7 @@ public class TableRepository extends EntityRepository { recordChange("sourceUrl", original.getSourceUrl(), updated.getSourceUrl()); recordChange("retentionPeriod", original.getRetentionPeriod(), updated.getRetentionPeriod()); recordChange("sourceHash", original.getSourceHash(), updated.getSourceHash()); + recordChange("locationPath", original.getLocationPath(), updated.getLocationPath()); } private void updateConstraints(Table origTable, Table updatedTable) { diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/TableResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/TableResource.java index 60b0e55aa3b..8c3a827261c 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/TableResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/TableResource.java @@ -1232,6 +1232,7 @@ public class TableResource extends EntityResource { .copy(new Table(), create, user) .withColumns(create.getColumns()) .withSourceUrl(create.getSourceUrl()) + .withLocationPath(create.getLocationPath()) .withTableConstraints(create.getTableConstraints()) .withTablePartition(create.getTablePartition()) .withTableType(create.getTableType()) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TableIndex.java b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TableIndex.java index 3815f0b3f3b..3f38ce6189f 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TableIndex.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TableIndex.java @@ -98,6 +98,7 @@ public record TableIndex(Table table) implements ColumnIndex { doc.put("schema_suggest", schemaSuggest); doc.put("database_suggest", databaseSuggest); doc.put("serviceType", table.getServiceType()); + doc.put("locationPath", table.getLocationPath()); doc.put("service", getEntityWithDisplayName(table.getService())); doc.put("database", getEntityWithDisplayName(table.getDatabase())); doc.put("lineage", SearchIndex.getLineageData(table.getEntityReference())); diff --git a/openmetadata-service/src/main/resources/elasticsearch/en/table_index_mapping.json b/openmetadata-service/src/main/resources/elasticsearch/en/table_index_mapping.json index a2205a4bb36..490f6e27773 100644 --- a/openmetadata-service/src/main/resources/elasticsearch/en/table_index_mapping.json +++ b/openmetadata-service/src/main/resources/elasticsearch/en/table_index_mapping.json @@ -499,6 +499,9 @@ } } }, + "locationPath": { + "type": "text" + }, "usageSummary": { "properties": { "dailyStats": { diff --git a/openmetadata-service/src/main/resources/elasticsearch/jp/table_index_mapping.json b/openmetadata-service/src/main/resources/elasticsearch/jp/table_index_mapping.json index e79282e1597..73887f3253c 100644 --- a/openmetadata-service/src/main/resources/elasticsearch/jp/table_index_mapping.json +++ b/openmetadata-service/src/main/resources/elasticsearch/jp/table_index_mapping.json @@ -477,6 +477,9 @@ } } }, + "locationPath": { + "type": "text" + }, "usageSummary": { "properties": { "dailyStats": { diff --git a/openmetadata-service/src/main/resources/elasticsearch/zh/table_index_mapping.json b/openmetadata-service/src/main/resources/elasticsearch/zh/table_index_mapping.json index 24d23992917..bb98b74f580 100644 --- a/openmetadata-service/src/main/resources/elasticsearch/zh/table_index_mapping.json +++ b/openmetadata-service/src/main/resources/elasticsearch/zh/table_index_mapping.json @@ -452,6 +452,9 @@ } } }, + "locationPath": { + "type": "text" + }, "usageSummary": { "properties": { "dailyStats": { diff --git a/openmetadata-spec/src/main/resources/json/schema/api/data/createTable.json b/openmetadata-spec/src/main/resources/json/schema/api/data/createTable.json index d59f6463a46..da1b2f30043 100644 --- a/openmetadata-spec/src/main/resources/json/schema/api/data/createTable.json +++ b/openmetadata-spec/src/main/resources/json/schema/api/data/createTable.json @@ -34,6 +34,11 @@ "dataModel": { "$ref": "../../entity/data/table.json#/definitions/dataModel" }, + "locationPath": { + "description": "Full storage path in case of external and managed tables.", + "type": "string", + "default": null + }, "tableConstraints": { "type": "array", "items": { diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/data/table.json b/openmetadata-spec/src/main/resources/json/schema/entity/data/table.json index 1f8a77c2e7a..46eba06fc22 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/data/table.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/data/table.json @@ -996,6 +996,11 @@ "description": "Reference to the Location that contains this table.", "$ref": "../../type/entityReference.json" }, + "locationPath": { + "description": "Full storage path in case of external and managed tables.", + "type": "string", + "default": null + }, "schemaDefinition": { "description": "DDL for Tables and Views", "$ref": "../../type/basic.json#/definitions/sqlQuery"