[atlas] branch branch-2.0 updated: ATLAS-4332 : DSL Query : query with like operator and / in search text throws 500
This is an automated email from the ASF dual-hosted git repository. pinal pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/atlas.git The following commit(s) were added to refs/heads/branch-2.0 by this push: new 37d3c6d ATLAS-4332 : DSL Query : query with like operator and / in search text throws 500 37d3c6d is described below commit 37d3c6d99c7db347280a8d9098fa5327f7dd4dd1 Author: Pinal AuthorDate: Wed Jun 9 19:36:06 2021 +0530 ATLAS-4332 : DSL Query : query with like operator and / in search text throws 500 Signed-off-by: Pinal --- .../apache/atlas/query/GremlinQueryComposer.java | 3 ++- .../org/apache/atlas/query/IdentifierHelper.java | 23 ++ .../test/java/org/apache/atlas/BasicTestSetup.java | 9 + .../org/apache/atlas/query/BaseDSLComposer.java| 2 ++ .../org/apache/atlas/query/DSLQueriesTest.java | 6 ++ .../atlas/query/GremlinQueryComposerTest.java | 3 +++ 6 files changed, 41 insertions(+), 5 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java b/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java index 320acbe..cff7aff 100644 --- a/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java +++ b/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java @@ -218,7 +218,8 @@ public class GremlinQueryComposer { final AtlasStructDef.AtlasAttributeDef.IndexType indexType = attribute.getAttributeDef().getIndexType(); if (indexType == AtlasStructDef.AtlasAttributeDef.IndexType.STRING || !containsNumberAndLettersOnly(rhs)) { -add(GremlinClause.STRING_CONTAINS, getPropertyForClause(lhsI), IdentifierHelper.getFixedRegEx(rhs)); +String escapeRhs = IdentifierHelper.escapeCharacters(IdentifierHelper.getFixedRegEx(rhs)); +add(GremlinClause.STRING_CONTAINS, getPropertyForClause(lhsI), escapeRhs); } else { add(GremlinClause.TEXT_CONTAINS, getPropertyForClause(lhsI), IdentifierHelper.getFixedRegEx(rhs)); } diff --git a/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java b/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java index c53a324..d2906ea 100644 --- a/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java +++ b/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java @@ -25,6 +25,9 @@ import org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdg import org.apache.atlas.type.AtlasType; import org.apache.commons.lang.StringUtils; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -33,6 +36,8 @@ public class IdentifierHelper { private static final Pattern SINGLE_QUOTED_IDENTIFIER = Pattern.compile("'(\\w[\\w\\d\\.\\s]*)'"); private static final Pattern DOUBLE_QUOTED_IDENTIFIER = Pattern.compile("\"(\\w[\\w\\d\\.\\s]*)\""); private static final Pattern BACKTICK_QUOTED_IDENTIFIER = Pattern.compile("`(\\w[\\w\\d\\.\\s]*)`"); +private static final Character[]ESCAPE_CHARS = new Character[] {'+', '@', '#', '&', '|', '(', ')', '{', '}', '[', ']', '~', '\\', '/'}; +private static final Set ESCAPE_CHARACTERS_SET = new HashSet<>(Arrays.asList(ESCAPE_CHARS)); public static String get(String quotedIdentifier) { String ret; @@ -116,6 +121,24 @@ public class IdentifierHelper { return s.replace("*", ".*").replace('?', '.'); } +public static String escapeCharacters(String value) { +if (StringUtils.isEmpty(value)) { +return value; +} + +StringBuilder sb = new StringBuilder(); +for (int i = 0; i < value.length(); i++) { +char c = value.charAt(i); + +if (c != '*' && ESCAPE_CHARACTERS_SET.contains(c)) { +sb.append('\\'); +} +sb.append(c); +} + +return sb.toString(); +} + public static String removeWildcards(String s) { return removeQuotes(s).replace("*", "").replace("?", ""); } diff --git a/repository/src/test/java/org/apache/atlas/BasicTestSetup.java b/repository/src/test/java/org/apache/atlas/BasicTestSetup.java index 99e075a..a821b25 100644 --- a/repository/src/test/java/org/apache/atlas/BasicTestSetup.java +++ b/repository/src/test/java/org/apache/atlas/BasicTestSetup.java @@ -153,7 +153,7 @@ public abstract class BasicTestSetup extends AtlasTestBase { createClassificationTypes(); -AtlasEntity salesDB = database("Sales", "Sales Database", "John ETL", "hdfs://host:8000/apps/warehouse/sales"); +AtlasEntity salesDB = database("Sales", "/apps/warehouse/Sales Database", "John ETL",
[atlas] branch master updated: ATLAS-4332 : DSL Query : query with like operator and / in search text throws 500
This is an automated email from the ASF dual-hosted git repository. pinal pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/atlas.git The following commit(s) were added to refs/heads/master by this push: new 2afbf4d ATLAS-4332 : DSL Query : query with like operator and / in search text throws 500 2afbf4d is described below commit 2afbf4daa650f49674ca1c7481697b852cb6a446 Author: Pinal AuthorDate: Wed Jun 9 19:36:06 2021 +0530 ATLAS-4332 : DSL Query : query with like operator and / in search text throws 500 Signed-off-by: Pinal --- .../apache/atlas/query/GremlinQueryComposer.java | 3 ++- .../org/apache/atlas/query/IdentifierHelper.java | 23 ++ .../test/java/org/apache/atlas/BasicTestSetup.java | 9 + .../org/apache/atlas/query/BaseDSLComposer.java| 2 ++ .../org/apache/atlas/query/DSLQueriesTest.java | 6 ++ .../atlas/query/GremlinQueryComposerTest.java | 3 +++ 6 files changed, 41 insertions(+), 5 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java b/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java index 320acbe..cff7aff 100644 --- a/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java +++ b/repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java @@ -218,7 +218,8 @@ public class GremlinQueryComposer { final AtlasStructDef.AtlasAttributeDef.IndexType indexType = attribute.getAttributeDef().getIndexType(); if (indexType == AtlasStructDef.AtlasAttributeDef.IndexType.STRING || !containsNumberAndLettersOnly(rhs)) { -add(GremlinClause.STRING_CONTAINS, getPropertyForClause(lhsI), IdentifierHelper.getFixedRegEx(rhs)); +String escapeRhs = IdentifierHelper.escapeCharacters(IdentifierHelper.getFixedRegEx(rhs)); +add(GremlinClause.STRING_CONTAINS, getPropertyForClause(lhsI), escapeRhs); } else { add(GremlinClause.TEXT_CONTAINS, getPropertyForClause(lhsI), IdentifierHelper.getFixedRegEx(rhs)); } diff --git a/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java b/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java index c53a324..d2906ea 100644 --- a/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java +++ b/repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java @@ -25,6 +25,9 @@ import org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdg import org.apache.atlas.type.AtlasType; import org.apache.commons.lang.StringUtils; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -33,6 +36,8 @@ public class IdentifierHelper { private static final Pattern SINGLE_QUOTED_IDENTIFIER = Pattern.compile("'(\\w[\\w\\d\\.\\s]*)'"); private static final Pattern DOUBLE_QUOTED_IDENTIFIER = Pattern.compile("\"(\\w[\\w\\d\\.\\s]*)\""); private static final Pattern BACKTICK_QUOTED_IDENTIFIER = Pattern.compile("`(\\w[\\w\\d\\.\\s]*)`"); +private static final Character[]ESCAPE_CHARS = new Character[] {'+', '@', '#', '&', '|', '(', ')', '{', '}', '[', ']', '~', '\\', '/'}; +private static final Set ESCAPE_CHARACTERS_SET = new HashSet<>(Arrays.asList(ESCAPE_CHARS)); public static String get(String quotedIdentifier) { String ret; @@ -116,6 +121,24 @@ public class IdentifierHelper { return s.replace("*", ".*").replace('?', '.'); } +public static String escapeCharacters(String value) { +if (StringUtils.isEmpty(value)) { +return value; +} + +StringBuilder sb = new StringBuilder(); +for (int i = 0; i < value.length(); i++) { +char c = value.charAt(i); + +if (c != '*' && ESCAPE_CHARACTERS_SET.contains(c)) { +sb.append('\\'); +} +sb.append(c); +} + +return sb.toString(); +} + public static String removeWildcards(String s) { return removeQuotes(s).replace("*", "").replace("?", ""); } diff --git a/repository/src/test/java/org/apache/atlas/BasicTestSetup.java b/repository/src/test/java/org/apache/atlas/BasicTestSetup.java index 99e075a..a821b25 100644 --- a/repository/src/test/java/org/apache/atlas/BasicTestSetup.java +++ b/repository/src/test/java/org/apache/atlas/BasicTestSetup.java @@ -153,7 +153,7 @@ public abstract class BasicTestSetup extends AtlasTestBase { createClassificationTypes(); -AtlasEntity salesDB = database("Sales", "Sales Database", "John ETL", "hdfs://host:8000/apps/warehouse/sales"); +AtlasEntity salesDB = database("Sales", "/apps/warehouse/Sales Database", "John ETL",
[atlas] branch branch-2.0 updated: ATLAS-4333: [MATERIALIZED VIEW]Column Lineage and hive_process missing in case of CREATE MATERIALIZED VIEW query at Hive
This is an automated email from the ASF dual-hosted git repository. amestry pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/atlas.git The following commit(s) were added to refs/heads/branch-2.0 by this push: new 62c7024 ATLAS-4333: [MATERIALIZED VIEW]Column Lineage and hive_process missing in case of CREATE MATERIALIZED VIEW query at Hive 62c7024 is described below commit 62c702422f7523b662743a5e2de15ecef6a27c3c Author: Radhika Kundam AuthorDate: Thu Jun 10 09:49:05 2021 -0700 ATLAS-4333: [MATERIALIZED VIEW]Column Lineage and hive_process missing in case of CREATE MATERIALIZED VIEW query at Hive --- .../main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java index 659417d..e5295f4 100644 --- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java +++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java @@ -292,6 +292,7 @@ public class CreateHiveProcess extends BaseHiveEvent { return entity != null && !context.isMetastoreHook() && (context.getHiveOperation().equals(HiveOperation.CREATETABLE_AS_SELECT) || context.getHiveOperation().equals(HiveOperation.CREATEVIEW) - || context.getHiveOperation().equals(HiveOperation.ALTERVIEW_AS)); + || context.getHiveOperation().equals(HiveOperation.ALTERVIEW_AS) + || context.getHiveOperation().equals(HiveOperation.CREATE_MATERIALIZED_VIEW)); } }
[atlas] branch master updated: ATLAS-4333: [MATERIALIZED VIEW]Column Lineage and hive_process missing in case of CREATE MATERIALIZED VIEW query at Hive
This is an automated email from the ASF dual-hosted git repository. amestry pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/atlas.git The following commit(s) were added to refs/heads/master by this push: new 01f5eea ATLAS-4333: [MATERIALIZED VIEW]Column Lineage and hive_process missing in case of CREATE MATERIALIZED VIEW query at Hive 01f5eea is described below commit 01f5eea5c60b710e16370b7e09a60a5353f8d17d Author: Radhika Kundam AuthorDate: Thu Jun 10 09:49:05 2021 -0700 ATLAS-4333: [MATERIALIZED VIEW]Column Lineage and hive_process missing in case of CREATE MATERIALIZED VIEW query at Hive --- .../main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java index 659417d..e5295f4 100644 --- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java +++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateHiveProcess.java @@ -292,6 +292,7 @@ public class CreateHiveProcess extends BaseHiveEvent { return entity != null && !context.isMetastoreHook() && (context.getHiveOperation().equals(HiveOperation.CREATETABLE_AS_SELECT) || context.getHiveOperation().equals(HiveOperation.CREATEVIEW) - || context.getHiveOperation().equals(HiveOperation.ALTERVIEW_AS)); + || context.getHiveOperation().equals(HiveOperation.ALTERVIEW_AS) + || context.getHiveOperation().equals(HiveOperation.CREATE_MATERIALIZED_VIEW)); } }
[atlas] branch branch-2.0 updated: Revert "ATLAS-4058: UI: Fix Entity detail page Hive Column Position with 0 is set to NA."
This is an automated email from the ASF dual-hosted git repository. nixon pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/atlas.git The following commit(s) were added to refs/heads/branch-2.0 by this push: new 55cb081 Revert "ATLAS-4058: UI: Fix Entity detail page Hive Column Position with 0 is set to NA." 55cb081 is described below commit 55cb08102214c8095fb0241d19ee792b035a58c2 Author: nixonrodrigues AuthorDate: Thu Jun 10 19:34:50 2021 +0530 Revert "ATLAS-4058: UI: Fix Entity detail page Hive Column Position with 0 is set to NA." This reverts commit de87800c19ea06f53904a2948fcde29a57d2f051. (cherry picked from commit 1078f25e90134be4a7e9f35f9774c113909aba97) --- .../public/js/views/audit/CreateAuditTableLayoutView.js| 3 --- .../public/js/views/entity/EntityDetailTableLayoutView.js | 10 +- .../public/js/views/audit/CreateAuditTableLayoutView.js| 3 --- .../public/js/views/entity/EntityDetailTableLayoutView.js | 10 +- 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js index e107a2d..20eac06 100644 --- a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js +++ b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js @@ -95,9 +95,6 @@ define(['require', getValue: function(val, key) { if (key && key.toLowerCase().indexOf("time") > 0) { return Utils.formatDate({ date: val }); -} else if (key && key.toLowerCase().indexOf("position") === 0 && val === 0) { -//if position value is 0 we are showing N/A -return "N/A"; } else { return val; } diff --git a/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js b/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js index a47e075..a5b5262 100644 --- a/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js +++ b/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js @@ -81,15 +81,7 @@ define(['require', scope: this, valueObject: _.extend({ "isIncomplete": this.entity.isIncomplete }, this.entity.attributes), attributeDefs: this.attributeDefs, -highlightString: highlightString, -getValue: function(val, key) { -if (key && key.toLowerCase().indexOf("position") === 0 && val === 0) { -//if position value is 0 we are showing N/A -return "N/A"; -} else { -return val; -} -} +highlightString: highlightString }); this.ui.detailValue.append(table); Utils.togglePropertyRelationshipTableEmptyValues({ diff --git a/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js b/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js index 7758821..0e2ade3 100644 --- a/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js +++ b/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js @@ -96,9 +96,6 @@ define(['require', getValue: function(val, key) { if (key && key.toLowerCase().indexOf("time") > 0) { return Utils.formatDate({ date: val }); -} else if (key && key.toLowerCase().indexOf("position") === 0 && val === 0) { -//if position value is 0 we are showing N/A -return "N/A"; } else { return val; } diff --git a/dashboardv3/public/js/views/entity/EntityDetailTableLayoutView.js b/dashboardv3/public/js/views/entity/EntityDetailTableLayoutView.js index a47e075..a5b5262 100644 --- a/dashboardv3/public/js/views/entity/EntityDetailTableLayoutView.js +++ b/dashboardv3/public/js/views/entity/EntityDetailTableLayoutView.js @@ -81,15 +81,7 @@ define(['require', scope: this, valueObject: _.extend({ "isIncomplete": this.entity.isIncomplete }, this.entity.attributes), attributeDefs: this.attributeDefs, -highlightString: highlightString, -getValue: function(val, key) { -if (key && key.toLowerCase().indexOf("position") === 0 && val === 0) { -//if position value is 0 we are showing N/A -
[atlas] branch master updated: Revert "ATLAS-4058: UI: Fix Entity detail page Hive Column Position with 0 is set to NA."
This is an automated email from the ASF dual-hosted git repository. nixon pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/atlas.git The following commit(s) were added to refs/heads/master by this push: new 1078f25 Revert "ATLAS-4058: UI: Fix Entity detail page Hive Column Position with 0 is set to NA." 1078f25 is described below commit 1078f25e90134be4a7e9f35f9774c113909aba97 Author: nixonrodrigues AuthorDate: Thu Jun 10 19:34:50 2021 +0530 Revert "ATLAS-4058: UI: Fix Entity detail page Hive Column Position with 0 is set to NA." This reverts commit de87800c19ea06f53904a2948fcde29a57d2f051. --- .../public/js/views/audit/CreateAuditTableLayoutView.js| 3 --- .../public/js/views/entity/EntityDetailTableLayoutView.js | 10 +- .../public/js/views/audit/CreateAuditTableLayoutView.js| 3 --- .../public/js/views/entity/EntityDetailTableLayoutView.js | 10 +- 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js index e107a2d..20eac06 100644 --- a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js +++ b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js @@ -95,9 +95,6 @@ define(['require', getValue: function(val, key) { if (key && key.toLowerCase().indexOf("time") > 0) { return Utils.formatDate({ date: val }); -} else if (key && key.toLowerCase().indexOf("position") === 0 && val === 0) { -//if position value is 0 we are showing N/A -return "N/A"; } else { return val; } diff --git a/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js b/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js index a47e075..a5b5262 100644 --- a/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js +++ b/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js @@ -81,15 +81,7 @@ define(['require', scope: this, valueObject: _.extend({ "isIncomplete": this.entity.isIncomplete }, this.entity.attributes), attributeDefs: this.attributeDefs, -highlightString: highlightString, -getValue: function(val, key) { -if (key && key.toLowerCase().indexOf("position") === 0 && val === 0) { -//if position value is 0 we are showing N/A -return "N/A"; -} else { -return val; -} -} +highlightString: highlightString }); this.ui.detailValue.append(table); Utils.togglePropertyRelationshipTableEmptyValues({ diff --git a/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js b/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js index 7758821..0e2ade3 100644 --- a/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js +++ b/dashboardv3/public/js/views/audit/CreateAuditTableLayoutView.js @@ -96,9 +96,6 @@ define(['require', getValue: function(val, key) { if (key && key.toLowerCase().indexOf("time") > 0) { return Utils.formatDate({ date: val }); -} else if (key && key.toLowerCase().indexOf("position") === 0 && val === 0) { -//if position value is 0 we are showing N/A -return "N/A"; } else { return val; } diff --git a/dashboardv3/public/js/views/entity/EntityDetailTableLayoutView.js b/dashboardv3/public/js/views/entity/EntityDetailTableLayoutView.js index a47e075..a5b5262 100644 --- a/dashboardv3/public/js/views/entity/EntityDetailTableLayoutView.js +++ b/dashboardv3/public/js/views/entity/EntityDetailTableLayoutView.js @@ -81,15 +81,7 @@ define(['require', scope: this, valueObject: _.extend({ "isIncomplete": this.entity.isIncomplete }, this.entity.attributes), attributeDefs: this.attributeDefs, -highlightString: highlightString, -getValue: function(val, key) { -if (key && key.toLowerCase().indexOf("position") === 0 && val === 0) { -//if position value is 0 we are showing N/A -return "N/A"; -} else { -