From ac2264e9c7fc9daa3e3e7a49218c3c93a3506dbe Mon Sep 17 00:00:00 2001 From: Mayur Singal <39544459+ulixius9@users.noreply.github.com> Date: Tue, 13 Aug 2024 17:42:46 +0530 Subject: [PATCH] MINOR: DI Simplify Formulas (#17382) * MINOR: DI Similify Formulas * checkstyle --- .../jdbi3/DataInsightSystemChartRepository.java | 2 +- ...icSearchDynamicChartAggregatorInterface.java | 17 +++++++++++------ ...enSearchDynamicChartAggregatorInterface.java | 17 +++++++++++------ ...ElasticSearchDynamicChartAggregatorTest.java | 11 +++++++++++ .../OpenSearchDynamicChartAggregatorTest.java | 11 +++++++++++ 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataInsightSystemChartRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataInsightSystemChartRepository.java index 48102c18501..e2d826c653d 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataInsightSystemChartRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataInsightSystemChartRepository.java @@ -21,7 +21,7 @@ public class DataInsightSystemChartRepository extends EntityRepository summaryCard1 = new LinkedHashMap<>(); + summaryCard1.put("type", "SummaryCard"); + summaryCard1.put("formula", "count()"); + assertTrue(compareRequest(cardString, summaryCard1)); + String lineString = "{\"query\":{\"range\":{\"@timestamp\":{\"from\":\"2024-07-16T03:54:31Z\",\"to\":\"2024-07-23T01:34:31Z\",\"include_lower\":true,\"include_upper\":true,\"boost\":1.0}}},\"aggregations\":{\"1\":{\"date_histogram\":{\"field\":\"@timestamp\",\"calendar_interval\":\"1d\",\"offset\":0,\"order\":{\"_key\":\"asc\"},\"keyed\":false,\"min_doc_count\":0},\"aggregations\":{\"id.keyword0\":{\"value_count\":{\"field\":\"id.keyword\"}}}}}}"; Map lineChart = new LinkedHashMap<>(); @@ -169,6 +174,12 @@ public class ElasticSearchDynamicChartAggregatorTest extends OpenMetadataApplica lineChart4.put("groupBy", "entityType.keyword"); assertTrue(compareRequest(lineString4, lineChart4)); + Map lineChart41 = new LinkedHashMap<>(); + lineChart41.put("type", "LineChart"); + lineChart41.put("formula", "count(q='hasDescription: 1')+count(q='owner.name.keyword: *')"); + lineChart41.put("groupBy", "entityType.keyword"); + assertTrue(compareRequest(lineString4, lineChart41)); + String lineString5 = "{\"size\":0,\"query\":{\"range\":{\"@timestamp\":{\"from\":\"2024-07-16T03:54:31Z\",\"to\":\"2024-07-23T01:34:31Z\",\"include_lower\":true,\"include_upper\":true,\"boost\":1.0}}},\"aggregations\":{\"0\":{\"terms\":{\"field\":\"entityType.keyword\",\"size\":20,\"min_doc_count\":1,\"shard_min_doc_count\":0,\"show_term_doc_count_error\":false,\"order\":[{\"_count\":\"desc\"},{\"_key\":\"asc\"}]},\"aggregations\":{\"1\":{\"date_histogram\":{\"field\":\"@timestamp\",\"calendar_interval\":\"1d\",\"offset\":0,\"order\":{\"_key\":\"asc\"},\"keyed\":false,\"min_doc_count\":0},\"aggregations\":{\"filer0\":{\"filter\":{\"bool\":{\"must\":[{\"query_string\":{\"query\":\"hasDescription: 1\",\"fields\":[],\"type\":\"best_fields\",\"default_operator\":\"or\",\"max_determinized_states\":10000,\"enable_position_increments\":true,\"fuzziness\":\"AUTO\",\"fuzzy_prefix_length\":0,\"fuzzy_max_expansions\":50,\"phrase_slop\":0,\"escape\":false,\"auto_generate_synonyms_phrase_query\":true,\"fuzzy_transpositions\":true,\"boost\":1.0}},{\"bool\":{\"must\":[{\"bool\":{\"should\":[{\"term\":{\"owners.displayName.keyword\":{\"value\":\"admin\",\"boost\":1.0}}}],\"adjust_pure_negative\":true,\"boost\":1.0}}],\"adjust_pure_negative\":true,\"boost\":1.0}}],\"adjust_pure_negative\":true,\"boost\":1.0}},\"aggregations\":{\"id.keyword0\":{\"value_count\":{\"field\":\"id.keyword\"}}}},\"filer1\":{\"filter\":{\"bool\":{\"must\":[{\"query_string\":{\"query\":\"owner.name.keyword: *\",\"fields\":[],\"type\":\"best_fields\",\"default_operator\":\"or\",\"max_determinized_states\":10000,\"enable_position_increments\":true,\"fuzziness\":\"AUTO\",\"fuzzy_prefix_length\":0,\"fuzzy_max_expansions\":50,\"phrase_slop\":0,\"escape\":false,\"auto_generate_synonyms_phrase_query\":true,\"fuzzy_transpositions\":true,\"boost\":1.0}},{\"bool\":{\"must\":[{\"bool\":{\"should\":[{\"term\":{\"owners.displayName.keyword\":{\"value\":\"admin\",\"boost\":1.0}}}],\"adjust_pure_negative\":true,\"boost\":1.0}}],\"adjust_pure_negative\":true,\"boost\":1.0}}],\"adjust_pure_negative\":true,\"boost\":1.0}},\"aggregations\":{\"id.keyword1\":{\"value_count\":{\"field\":\"id.keyword\"}}}}}}}}}}"; Map lineChart5 = new LinkedHashMap<>(); diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/OpenSearchDynamicChartAggregatorTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/OpenSearchDynamicChartAggregatorTest.java index d5a133705fc..6dcdfe8848a 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/OpenSearchDynamicChartAggregatorTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/OpenSearchDynamicChartAggregatorTest.java @@ -129,6 +129,11 @@ public class OpenSearchDynamicChartAggregatorTest extends OpenMetadataApplicatio summaryCard.put("formula", "count(k='id.keyword')"); assertTrue(compareRequest(cardString, summaryCard)); + Map summaryCard1 = new LinkedHashMap<>(); + summaryCard1.put("type", "SummaryCard"); + summaryCard1.put("formula", "count()"); + assertTrue(compareRequest(cardString, summaryCard1)); + String lineString = "{\"query\":{\"range\":{\"@timestamp\":{\"from\":\"2024-07-16T03:54:31Z\",\"to\":\"2024-07-23T01:34:31Z\",\"include_lower\":true,\"include_upper\":true,\"boost\":1.0}}},\"aggregations\":{\"1\":{\"date_histogram\":{\"field\":\"@timestamp\",\"calendar_interval\":\"1d\",\"offset\":0,\"order\":{\"_key\":\"asc\"},\"keyed\":false,\"min_doc_count\":0},\"aggregations\":{\"id.keyword0\":{\"value_count\":{\"field\":\"id.keyword\"}}}}}}"; Map lineChart = new LinkedHashMap<>(); @@ -168,6 +173,12 @@ public class OpenSearchDynamicChartAggregatorTest extends OpenMetadataApplicatio lineChart4.put("groupBy", "entityType.keyword"); assertTrue(compareRequest(lineString4, lineChart4)); + Map lineChart41 = new LinkedHashMap<>(); + lineChart41.put("type", "LineChart"); + lineChart41.put("formula", "count(q='hasDescription: 1')+count(q='owner.name.keyword: *')"); + lineChart41.put("groupBy", "entityType.keyword"); + assertTrue(compareRequest(lineString4, lineChart41)); + String lineString5 = "{\"size\":0,\"query\":{\"range\":{\"@timestamp\":{\"from\":\"2024-07-16T03:54:31Z\",\"to\":\"2024-07-23T01:34:31Z\",\"include_lower\":true,\"include_upper\":true,\"boost\":1.0}}},\"aggregations\":{\"0\":{\"terms\":{\"field\":\"entityType.keyword\",\"size\":20,\"min_doc_count\":1,\"shard_min_doc_count\":0,\"show_term_doc_count_error\":false,\"order\":[{\"_count\":\"desc\"},{\"_key\":\"asc\"}]},\"aggregations\":{\"1\":{\"date_histogram\":{\"field\":\"@timestamp\",\"calendar_interval\":\"1d\",\"offset\":0,\"order\":{\"_key\":\"asc\"},\"keyed\":false,\"min_doc_count\":0},\"aggregations\":{\"filer0\":{\"filter\":{\"bool\":{\"must\":[{\"query_string\":{\"query\":\"hasDescription: 1\",\"fields\":[],\"type\":\"best_fields\",\"default_operator\":\"or\",\"max_determinized_states\":10000,\"enable_position_increments\":true,\"fuzziness\":\"AUTO\",\"fuzzy_prefix_length\":0,\"fuzzy_max_expansions\":50,\"phrase_slop\":0,\"escape\":false,\"auto_generate_synonyms_phrase_query\":true,\"fuzzy_transpositions\":true,\"boost\":1.0}},{\"bool\":{\"must\":[{\"bool\":{\"should\":[{\"term\":{\"owners.displayName.keyword\":{\"value\":\"admin\",\"boost\":1.0}}}],\"adjust_pure_negative\":true,\"boost\":1.0}}],\"adjust_pure_negative\":true,\"boost\":1.0}}],\"adjust_pure_negative\":true,\"boost\":1.0}},\"aggregations\":{\"id.keyword0\":{\"value_count\":{\"field\":\"id.keyword\"}}}},\"filer1\":{\"filter\":{\"bool\":{\"must\":[{\"query_string\":{\"query\":\"owner.name.keyword: *\",\"fields\":[],\"type\":\"best_fields\",\"default_operator\":\"or\",\"max_determinized_states\":10000,\"enable_position_increments\":true,\"fuzziness\":\"AUTO\",\"fuzzy_prefix_length\":0,\"fuzzy_max_expansions\":50,\"phrase_slop\":0,\"escape\":false,\"auto_generate_synonyms_phrase_query\":true,\"fuzzy_transpositions\":true,\"boost\":1.0}},{\"bool\":{\"must\":[{\"bool\":{\"should\":[{\"term\":{\"owners.displayName.keyword\":{\"value\":\"admin\",\"boost\":1.0}}}],\"adjust_pure_negative\":true,\"boost\":1.0}}],\"adjust_pure_negative\":true,\"boost\":1.0}}],\"adjust_pure_negative\":true,\"boost\":1.0}},\"aggregations\":{\"id.keyword1\":{\"value_count\":{\"field\":\"id.keyword\"}}}}}}}}}}"; Map lineChart5 = new LinkedHashMap<>();