ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbhowm...@apache.org
Subject ambari git commit: AMBARI-20199. HiveView2.0 query fails if we have an additional newline after the last query statement ending with '; '. (dipayanb)
Date Wed, 01 Mar 2017 06:39:57 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 da9669763 -> e9475c479


AMBARI-20199. HiveView2.0 query fails if we have an additional newline after the last query
statement ending with ';'. (dipayanb)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e9475c47
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e9475c47
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e9475c47

Branch: refs/heads/branch-2.5
Commit: e9475c4795aca8040c69c61b46d8d0406ce5dcaa
Parents: da96697
Author: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Authored: Wed Mar 1 12:09:42 2017 +0530
Committer: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Committed: Wed Mar 1 12:09:42 2017 +0530

----------------------------------------------------------------------
 .../jobs/viewJobs/JobControllerImpl.java        | 28 +++++++++++++++----
 .../jobs/viewJobs/JobControllerImpl.java        | 29 ++++++++++++++++----
 2 files changed, 45 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e9475c47/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/viewJobs/JobControllerImpl.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/viewJobs/JobControllerImpl.java
b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/viewJobs/JobControllerImpl.java
index 66b8334..f1afc0f 100644
--- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/viewJobs/JobControllerImpl.java
+++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/jobs/viewJobs/JobControllerImpl.java
@@ -39,7 +39,7 @@ import org.apache.ambari.view.hive2.utils.ServiceFormattedException;
 import org.apache.ambari.view.utils.hdfs.HdfsApi;
 import org.apache.ambari.view.utils.hdfs.HdfsApiException;
 import org.apache.ambari.view.utils.hdfs.HdfsUtil;
-import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,6 +47,13 @@ import java.io.IOException;
 import java.lang.reflect.Proxy;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.List;
+import javax.annotation.Nullable;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.Lists;
 
 public class JobControllerImpl implements JobController, ModifyNotificationDelegate {
     private final static Logger LOG =
@@ -113,11 +120,20 @@ public class JobControllerImpl implements JobController, ModifyNotificationDeleg
     }
 
     private String[] getStatements(String jobDatabase, String query) {
-      String[] queries = query.split(";");
-
-
-      String[] strings = {"use " + jobDatabase};
-      return ArrayUtils.addAll(strings, queries);
+        List<String> queries = Lists.asList("use " + jobDatabase, query.split(";"));
+        List<String> cleansedQueries = FluentIterable.from(queries).transform(new Function<String,
String>() {
+            @Nullable
+            @Override
+            public String apply(@Nullable String s) {
+                return s.trim();
+            }
+        }).filter(new Predicate<String>() {
+            @Override
+            public boolean apply(@Nullable String s) {
+                return !StringUtils.isEmpty(s);
+            }
+        }).toList();
+        return cleansedQueries.toArray(new String[0]);
     }
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e9475c47/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/jobs/viewJobs/JobControllerImpl.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/jobs/viewJobs/JobControllerImpl.java
b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/jobs/viewJobs/JobControllerImpl.java
index 1511e5b..2886e65 100644
--- a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/jobs/viewJobs/JobControllerImpl.java
+++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/jobs/viewJobs/JobControllerImpl.java
@@ -39,7 +39,7 @@ import org.apache.ambari.view.hive20.utils.ServiceFormattedException;
 import org.apache.ambari.view.utils.hdfs.HdfsApi;
 import org.apache.ambari.view.utils.hdfs.HdfsApiException;
 import org.apache.ambari.view.utils.hdfs.HdfsUtil;
-import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,6 +47,14 @@ import java.io.IOException;
 import java.lang.reflect.Proxy;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.Lists;
 
 public class JobControllerImpl implements JobController, ModifyNotificationDelegate {
     private final static Logger LOG =
@@ -113,11 +121,20 @@ public class JobControllerImpl implements JobController, ModifyNotificationDeleg
     }
 
     private String[] getStatements(String jobDatabase, String query) {
-      String[] queries = query.split(";");
-
-
-      String[] strings = {"use " + jobDatabase};
-      return ArrayUtils.addAll(strings, queries);
+      List<String> queries = Lists.asList("use " + jobDatabase, query.split(";"));
+      List<String> cleansedQueries = FluentIterable.from(queries).transform(new Function<String,
String>() {
+          @Nullable
+          @Override
+          public String apply(@Nullable String s) {
+              return s.trim();
+          }
+      }).filter(new Predicate<String>() {
+          @Override
+          public boolean apply(@Nullable String s) {
+              return !StringUtils.isEmpty(s);
+          }
+      }).toList();
+      return cleansedQueries.toArray(new String[0]);
     }
 
 


Mime
View raw message