MAPREDUCE-6012. DBInputSplit creates invalid ranges on Oracle. (Wei Yan via kasha)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1618694 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Karthik Kambatla 2014-08-18 18:25:50 +00:00
parent d51f81c3b6
commit 73325f23f6
3 changed files with 7 additions and 5 deletions

View File

@ -233,6 +233,9 @@ Release 2.6.0 - UNRELEASED
MAPREDUCE-6036. TestJobEndNotifier fails intermittently in branch-2 (chang MAPREDUCE-6036. TestJobEndNotifier fails intermittently in branch-2 (chang
li via jlowe) li via jlowe)
MAPREDUCE-6012. DBInputSplit creates invalid ranges on Oracle.
(Wei Yan via kasha)
Release 2.5.0 - UNRELEASED Release 2.5.0 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -81,15 +81,14 @@ public class OracleDBRecordReader<T extends DBWritable> extends DBRecordReader<T
try { try {
DBInputFormat.DBInputSplit split = getSplit(); DBInputFormat.DBInputSplit split = getSplit();
if (split.getLength() > 0 && split.getStart() > 0){ if (split.getLength() > 0){
String querystring = query.toString(); String querystring = query.toString();
query = new StringBuilder(); query = new StringBuilder();
query.append("SELECT * FROM (SELECT a.*,ROWNUM dbif_rno FROM ( "); query.append("SELECT * FROM (SELECT a.*,ROWNUM dbif_rno FROM ( ");
query.append(querystring); query.append(querystring);
query.append(" ) a WHERE rownum <= ").append(split.getStart()); query.append(" ) a WHERE rownum <= ").append(split.getEnd());
query.append(" + ").append(split.getLength()); query.append(" ) WHERE dbif_rno > ").append(split.getStart());
query.append(" ) WHERE dbif_rno >= ").append(split.getStart());
} }
} catch (IOException ex) { } catch (IOException ex) {
// ignore, will not throw. // ignore, will not throw.

View File

@ -110,7 +110,7 @@ public class TestDbClasses {
splitter, NullDBWritable.class, configuration, connect, splitter, NullDBWritable.class, configuration, connect,
dbConfiguration, "condition", fields, "table"); dbConfiguration, "condition", fields, "table");
assertEquals( assertEquals(
"SELECT * FROM (SELECT a.*,ROWNUM dbif_rno FROM ( SELECT f1, f2 FROM table WHERE condition ORDER BY Order ) a WHERE rownum <= 1 + 9 ) WHERE dbif_rno >= 1", "SELECT * FROM (SELECT a.*,ROWNUM dbif_rno FROM ( SELECT f1, f2 FROM table WHERE condition ORDER BY Order ) a WHERE rownum <= 10 ) WHERE dbif_rno > 1",
recorder.getSelectQuery()); recorder.getSelectQuery());
} }