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 19:18:04 UTC
lucene-solr:branch_6_0: 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_0 4ad0683bc -> a1756f6de
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/a1756f6d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a1756f6d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a1756f6d
Branch: refs/heads/branch_6_0
Commit: a1756f6deb379f99ada6222ddca3dd4a15dad7d3
Parents: 4ad0683
Author: Dennis Gove <dp...@gmail.com>
Authored: Wed Jun 29 15:17:44 2016 -0400
Committer: Dennis Gove <dp...@gmail.com>
Committed: Wed Jun 29 15:17:44 2016 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
.../solr/client/solrj/io/stream/JDBCStream.java | 4 ++++
.../client/solrj/io/stream/JDBCStreamTest.java | 17 +++++++++++++++--
3 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a1756f6d/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 685583c..673b1b4 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -29,6 +29,8 @@ Bug Fixes
* SOLR-8940: Fix group.sort option (hossman)
+* SOLR-9246: If the JDBCStream sees an unknown column type it will now throw a detailed exception. (Dennis Gove)
+
================== 6.0.1 ==================
Upgrade Notes
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a1756f6d/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 a98f2e4..7aa46e9 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
@@ -222,6 +222,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() {
@@ -271,6 +272,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/a1756f6d/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 f330c11..c8a5c7d 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
@@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
-import java.util.Properties;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.LuceneTestCase.Slow;
@@ -79,7 +78,7 @@ public class JDBCStreamTest extends AbstractFullDistribZkTestBase {
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)");
}
@AfterClass
@@ -151,6 +150,20 @@ public class JDBCStreamTest extends AbstractFullDistribZkTestBase {
// done during afterSuperClass(...)
}
+ @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);
+
+ }
+
private void clearData() throws Exception {
// Clear Solr index
del("*:*");