From df704fb566e81e3a037301bc82bc3a8c26a326ed Mon Sep 17 00:00:00 2001 From: Vivek Ratnavel Subramanian Date: Wed, 29 Jun 2022 16:27:43 -0700 Subject: [PATCH] Fix #5739 Activity feed bug for tables with similar name (#5760) --- .../openmetadata/catalog/jdbi3/CollectionDAO.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/CollectionDAO.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/CollectionDAO.java index 57b4032133f..0a05dbad791 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/CollectionDAO.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/CollectionDAO.java @@ -679,7 +679,8 @@ public interface CollectionDAO { @SqlQuery( "SELECT json FROM thread_entity WHERE updatedAt > :before AND resolved = :resolved AND (:type IS NULL OR type = :type) AND " + "id in (SELECT fromFQN FROM field_relationship WHERE " - + "toFQN LIKE CONCAT(:fqnPrefix, '%') AND fromType='THREAD' AND toType LIKE CONCAT(:toType, '%') AND relation= :relation) " + + "(toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND " + + "(toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation) " + "ORDER BY updatedAt DESC " + "LIMIT :limit") List listThreadsByEntityLinkBefore( @@ -695,7 +696,8 @@ public interface CollectionDAO { "SELECT json FROM thread_entity WHERE updatedAt < :after AND resolved = :resolved AND " + "(:type IS NULL OR type = :type) AND " + "id in (SELECT fromFQN FROM field_relationship WHERE " - + "toFQN LIKE CONCAT(:fqnPrefix, '%') AND fromType='THREAD' AND toType LIKE CONCAT(:toType, '%') AND relation= :relation) " + + "(toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND " + + "(toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation) " + "ORDER BY updatedAt DESC " + "LIMIT :limit") List listThreadsByEntityLinkAfter( @@ -711,7 +713,8 @@ public interface CollectionDAO { "SELECT count(id) FROM thread_entity WHERE resolved = :resolved AND " + "(:type IS NULL OR type = :type) AND " + "id in (SELECT fromFQN FROM field_relationship WHERE " - + "toFQN LIKE CONCAT(:fqnPrefix, '%') AND fromType='THREAD' AND toType LIKE CONCAT(:toType, '%') AND relation= :relation)") + + "(toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND " + + "(toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation)") int listCountThreadsByEntityLink( @Bind("fqnPrefix") String fqnPrefix, @Bind("toType") String toType, @@ -727,7 +730,8 @@ public interface CollectionDAO { @SqlQuery( "SELECT entityLink, COUNT(id) count FROM field_relationship fr INNER JOIN thread_entity te ON fr.fromFQN=te.id " - + "WHERE fr.toFQN LIKE CONCAT(:fqnPrefix, '%') AND fr.toType like concat(:toType, '%') AND fr.fromType = :fromType " + + "WHERE (fr.toFQN LIKE CONCAT(:fqnPrefix, '.%') OR fr.toFQN=:fqnPrefix) AND " + + "(fr.toType like concat(:toType, '.%') OR fr.toType=:toType)AND fr.fromType = :fromType " + "AND fr.relation = :relation AND te.resolved= :isResolved AND (:type IS NULL OR te.type = :type) " + "GROUP BY entityLink") @RegisterRowMapper(CountFieldMapper.class)