Remove CostAnalysisWorkflow dependency on Service Connection (#17732)

Connection is not a required attribute for a DatabaseService.
In order to avoid errors we are removing the dependency on this
attribute and checking that the DatabaseServiceType belongs to either
Snowflake, Redshift or BigQuery, which are the supported databases for
this feature.
This commit is contained in:
IceS2 2024-09-06 10:18:07 +02:00 committed by Pablo Takara
parent f9dd7b53cb
commit acd0cfec8c
No known key found for this signature in database
GPG Key ID: 63381DDFBB2BF725

View File

@ -15,6 +15,7 @@ import org.openmetadata.schema.analytics.AggregatedCostAnalysisReportData;
import org.openmetadata.schema.analytics.DataAssetMetrics; import org.openmetadata.schema.analytics.DataAssetMetrics;
import org.openmetadata.schema.analytics.RawCostAnalysisReportData; import org.openmetadata.schema.analytics.RawCostAnalysisReportData;
import org.openmetadata.schema.analytics.ReportData; import org.openmetadata.schema.analytics.ReportData;
import org.openmetadata.schema.api.services.CreateDatabaseService;
import org.openmetadata.schema.entity.data.Table; import org.openmetadata.schema.entity.data.Table;
import org.openmetadata.schema.entity.services.DatabaseService; import org.openmetadata.schema.entity.services.DatabaseService;
import org.openmetadata.schema.system.StepStats; import org.openmetadata.schema.system.StepStats;
@ -33,7 +34,6 @@ import org.openmetadata.service.exception.SearchIndexException;
import org.openmetadata.service.jdbi3.ListFilter; import org.openmetadata.service.jdbi3.ListFilter;
import org.openmetadata.service.jdbi3.ReportDataRepository; import org.openmetadata.service.jdbi3.ReportDataRepository;
import org.openmetadata.service.jdbi3.TableRepository; import org.openmetadata.service.jdbi3.TableRepository;
import org.openmetadata.service.util.JsonUtils;
import org.openmetadata.service.util.ResultList; import org.openmetadata.service.util.ResultList;
import org.openmetadata.service.workflows.searchIndex.PaginatedEntitiesSource; import org.openmetadata.service.workflows.searchIndex.PaginatedEntitiesSource;
@ -330,8 +330,11 @@ public class CostAnalysisWorkflow {
} }
private boolean databaseServiceSupportsProfilerAndUsage(DatabaseService databaseService) { private boolean databaseServiceSupportsProfilerAndUsage(DatabaseService databaseService) {
Map<String, Object> config = JsonUtils.getMap(databaseService.getConnection().getConfig()); return List.of(
return config.containsKey("supportsProfiler") && config.containsKey("supportsUsageExtraction"); CreateDatabaseService.DatabaseServiceType.BigQuery,
CreateDatabaseService.DatabaseServiceType.Redshift,
CreateDatabaseService.DatabaseServiceType.Snowflake)
.contains(databaseService.getServiceType());
} }
private void deleteReportDataRecordsAtDate( private void deleteReportDataRecordsAtDate(