You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dp...@apache.org on 2016/06/29 18:48:33 UTC

lucene-solr:branch_6_1: SOLR-9246: If the JDBCStream sees an unknown column type it will now throw a detailed exception

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6_1 4dfaaa21a -> 86a19829d


SOLR-9246: If the JDBCStream sees an unknown column type it will now throw a detailed exception


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/86a19829
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/86a19829
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/86a19829

Branch: refs/heads/branch_6_1
Commit: 86a19829dbd18d7fe38c0d89d7e23c25419bc935
Parents: 4dfaaa2
Author: Dennis Gove <dp...@gmail.com>
Authored: Wed Jun 29 14:48:24 2016 -0400
Committer: Dennis Gove <dp...@gmail.com>
Committed: Wed Jun 29 14:48:24 2016 -0400

----------------------------------------------------------------------
 solr/CHANGES.txt                                    |  2 ++
 .../solr/client/solrj/io/stream/JDBCStream.java     |  4 ++++
 .../solr/client/solrj/io/stream/JDBCStreamTest.java | 16 ++++++++++++++++
 3 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/86a19829/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 03a6d3d..7f4d3b9 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -185,6 +185,8 @@ Bug Fixes
 * SOLR-9176: facet method ENUM was sometimes unnecessarily being rewritten to
   FCS, causing slowdowns (Alessandro Benedetti, Jesse McLaughlin, Alan Woodward)
 
+* SOLR-9246: If the JDBCStream sees an unknown column type it will now throw a detailed exception. (Dennis Gove)
+
 Optimizations
 ----------------------
 * SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/86a19829/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/JDBCStream.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/JDBCStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/JDBCStream.java
index d1a301e..f57beac 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/JDBCStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/JDBCStream.java
@@ -225,6 +225,7 @@ public class JDBCStream extends TupleStream implements Expressible {
       final int columnNumber = columnIdx + 1; // cause it starts at 1        
       final String columnName = metadata.getColumnName(columnNumber);
       String className = metadata.getColumnClassName(columnNumber);
+      String typeName = metadata.getColumnTypeName(columnNumber);
             
       if(directSupportedTypes.contains(className)){
         valueSelectors[columnIdx] = new ResultSetValueSelector() {
@@ -274,6 +275,9 @@ public class JDBCStream extends TupleStream implements Expressible {
           }
         };
       }
+      else{
+        throw new SQLException(String.format(Locale.ROOT, "Unable to determine the valueSelector for column '%s' (col #%d) of java class '%s' and type '%s'", columnName, columnNumber, className, typeName));
+      }
     }
     
     return valueSelectors;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/86a19829/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/JDBCStreamTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/JDBCStreamTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/JDBCStreamTest.java
index 0315cfe..980d0e7 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/JDBCStreamTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/JDBCStreamTest.java
@@ -84,6 +84,7 @@ public class JDBCStreamTest extends SolrCloudTestCase {
     statement.executeUpdate("create table COUNTRIES(CODE varchar(3) not null primary key, COUNTRY_NAME varchar(50), DELETED char(1) default 'N')");
     statement.executeUpdate("create table PEOPLE(ID int not null primary key, NAME varchar(50), COUNTRY_CODE char(2), DELETED char(1) default 'N')");
     statement.executeUpdate("create table PEOPLE_SPORTS(ID int not null primary key, PERSON_ID int, SPORT_NAME varchar(50), DELETED char(1) default 'N')");
+    statement.executeUpdate("create table UNSUPPORTED_COLUMNS(ID int not null primary key, UNSP binary)");
     
   }
 
@@ -109,6 +110,7 @@ public class JDBCStreamTest extends SolrCloudTestCase {
       statement.executeUpdate("delete from COUNTRIES WHERE 1=1");
       statement.executeUpdate("delete from PEOPLE WHERE 1=1");
       statement.executeUpdate("delete from PEOPLE_SPORTS WHERE 1=1");
+      statement.executeUpdate("delete from UNSUPPORTED_COLUMNS WHERE 1=1");
     }
   }
 
@@ -497,6 +499,20 @@ public class JDBCStreamTest extends SolrCloudTestCase {
     
   }
   
+  @Test(expected=IOException.class)
+  public void testUnsupportedColumns() throws Exception {
+
+    // No need to load table with any data
+    
+    TupleStream stream;
+    
+    // Simple 1
+    stream = new JDBCStream("jdbc:hsqldb:mem:.", "select ID,UNSP from UNSUPPORTED_COLUMNS",
+        new FieldComparator("CODE", ComparatorOrder.ASCENDING));
+    getTuples(stream);
+        
+  }
+  
   protected List<Tuple> getTuples(TupleStream tupleStream) throws IOException {
     tupleStream.open();
     List<Tuple> tuples = new ArrayList<Tuple>();