apex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sand...@apache.org
Subject apex-malhar git commit: APEXMALHAR-2117 Generate default queryStmt even if its set to empty string. Also added missing hsqldb mavne dependency for test scope.
Date Tue, 14 Jun 2016 07:02:49 GMT
Repository: apex-malhar
Updated Branches:
  refs/heads/master d2f0586c9 -> 882e4568a


APEXMALHAR-2117 Generate default queryStmt even if its set to empty string.
Also added missing hsqldb mavne dependency for test scope.


Project: http://git-wip-us.apache.org/repos/asf/apex-malhar/repo
Commit: http://git-wip-us.apache.org/repos/asf/apex-malhar/commit/882e4568
Tree: http://git-wip-us.apache.org/repos/asf/apex-malhar/tree/882e4568
Diff: http://git-wip-us.apache.org/repos/asf/apex-malhar/diff/882e4568

Branch: refs/heads/master
Commit: 882e4568a0176723cdc31de4eef021f6376b2c6c
Parents: d2f0586
Author: Chinmay Kolhatkar <chinmay@datatorrent.com>
Authored: Mon Jun 13 15:02:01 2016 -0700
Committer: Chinmay Kolhatkar <chinmay@datatorrent.com>
Committed: Mon Jun 13 15:02:01 2016 -0700

----------------------------------------------------------------------
 contrib/pom.xml                                 |  6 ++++
 .../datatorrent/contrib/enrich/JDBCLoader.java  |  2 +-
 .../contrib/enrich/JDBCLoaderTest.java          | 32 ++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/882e4568/contrib/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/pom.xml b/contrib/pom.xml
index cf98feb..80a8478 100755
--- a/contrib/pom.xml
+++ b/contrib/pom.xml
@@ -652,5 +652,11 @@
       <version>2.0.1</version>
       <optional>true</optional>
     </dependency>
+    <dependency>
+      <groupId>hsqldb</groupId>
+      <artifactId>hsqldb</artifactId>
+      <version>1.8.0.7</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/882e4568/contrib/src/main/java/com/datatorrent/contrib/enrich/JDBCLoader.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/com/datatorrent/contrib/enrich/JDBCLoader.java b/contrib/src/main/java/com/datatorrent/contrib/enrich/JDBCLoader.java
index 54a2024..ce02c08 100644
--- a/contrib/src/main/java/com/datatorrent/contrib/enrich/JDBCLoader.java
+++ b/contrib/src/main/java/com/datatorrent/contrib/enrich/JDBCLoader.java
@@ -156,7 +156,7 @@ public class JDBCLoader extends JdbcStore implements BackendLoader
   {
     this.lookupFieldInfo = lookupFieldInfo;
     this.includeFieldInfo = includeFieldInfo;
-    if (queryStmt == null) {
+    if ((queryStmt == null) || (queryStmt.length() == 0)) {
       queryStmt = generateQueryStmt();
     }
   }

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/882e4568/contrib/src/test/java/com/datatorrent/contrib/enrich/JDBCLoaderTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/com/datatorrent/contrib/enrich/JDBCLoaderTest.java b/contrib/src/test/java/com/datatorrent/contrib/enrich/JDBCLoaderTest.java
index f450736..708f151 100644
--- a/contrib/src/test/java/com/datatorrent/contrib/enrich/JDBCLoaderTest.java
+++ b/contrib/src/test/java/com/datatorrent/contrib/enrich/JDBCLoaderTest.java
@@ -182,6 +182,38 @@ public class JDBCLoaderTest
   }
 
   @Test
+  public void testMysqlDBLookupIncludeAllKeysEmptyQuery() throws Exception
+  {
+    CountDownLatch latch = new CountDownLatch(1);
+
+    ArrayList<FieldInfo> lookupKeys = new ArrayList<>();
+    lookupKeys.add(new FieldInfo("ID", "ID", FieldInfo.SupportType.INTEGER));
+
+    ArrayList<FieldInfo> includeKeys = new ArrayList<>();
+    includeKeys.add(new FieldInfo("ID", "ID", FieldInfo.SupportType.INTEGER));
+    includeKeys.add(new FieldInfo("NAME", "NAME", FieldInfo.SupportType.STRING));
+    includeKeys.add(new FieldInfo("AGE", "AGE", FieldInfo.SupportType.INTEGER));
+    includeKeys.add(new FieldInfo("ADDRESS", "ADDRESS", FieldInfo.SupportType.STRING));
+    includeKeys.add(new FieldInfo("SALARY", "SALARY", FieldInfo.SupportType.DOUBLE));
+
+    testMeta.dbloader.setQueryStmt("");
+    testMeta.dbloader.setFieldInfo(lookupKeys, includeKeys);
+
+    latch.await(1000, TimeUnit.MILLISECONDS);
+
+    ArrayList<Object> keys = new ArrayList<Object>();
+    keys.add(4);
+
+    ArrayList<Object> columnInfo = (ArrayList<Object>)testMeta.dbloader.get(keys);
+
+    Assert.assertEquals("ID", 4, columnInfo.get(0));
+    Assert.assertEquals("NAME", "Mark", columnInfo.get(1).toString().trim());
+    Assert.assertEquals("AGE", 25, columnInfo.get(2));
+    Assert.assertEquals("ADDRESS", "Rich-Mond", columnInfo.get(3).toString().trim());
+    Assert.assertEquals("SALARY", 65000.0, columnInfo.get(4));
+  }
+
+  @Test
   public void testMysqlDBQuery() throws Exception
   {
     CountDownLatch latch = new CountDownLatch(1);


Mime
View raw message