5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-17 09:20:43 +08:00

SQOOP-1112: Sqoop2: Date splitter might return splits omitting some boundaries

(Venkat Ranganathan via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2013-07-02 16:29:27 -07:00
parent 8c74223b59
commit d4b2d61653
2 changed files with 11 additions and 8 deletions

View File

@ -128,10 +128,9 @@ protected List<Partition> partitionDateTimeColumn() {
break; break;
} }
long tzOffset = TimeZone.getDefault().getRawOffset();
minDateValue += tzOffset; minDateValue += TimeZone.getDefault().getOffset(minDateValue);
maxDateValue += tzOffset; maxDateValue += TimeZone.getDefault().getOffset(maxDateValue);
sdf.setTimeZone(TimeZone.getTimeZone("GMT")); sdf.setTimeZone(TimeZone.getTimeZone("GMT"));

View File

@ -268,9 +268,10 @@ public void testDatePartition() throws Exception {
context.setString(GenericJdbcConnectorConstants context.setString(GenericJdbcConnectorConstants
.CONNECTOR_JDBC_PARTITION_COLUMNTYPE, String.valueOf(Types.DATE)); .CONNECTOR_JDBC_PARTITION_COLUMNTYPE, String.valueOf(Types.DATE));
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MINVALUE, context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MINVALUE,
Date.valueOf("2013-01-01").toString()); Date.valueOf("2004-10-20").toString());
context.setString(GenericJdbcConnectorConstants context.setString(GenericJdbcConnectorConstants
.CONNECTOR_JDBC_PARTITION_MAXVALUE, Date.valueOf("2013-12-31").toString()); .CONNECTOR_JDBC_PARTITION_MAXVALUE, Date.valueOf("2013-10-17")
.toString());
ConnectionConfiguration connConf = new ConnectionConfiguration(); ConnectionConfiguration connConf = new ConnectionConfiguration();
@ -280,10 +281,12 @@ public void testDatePartition() throws Exception {
PartitionerContext partitionerContext = new PartitionerContext(context, PartitionerContext partitionerContext = new PartitionerContext(context,
3); 3);
List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf); List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
verifyResult(partitions, new String[]{ verifyResult(partitions, new String[]{
"'2013-01-01' <= DCOL AND DCOL < '2013-05-02'", "'2004-10-20' <= DCOL AND DCOL < '2007-10-19'",
"'2013-05-02' <= DCOL AND DCOL < '2013-08-31'", "'2007-10-19' <= DCOL AND DCOL < '2010-10-18'",
"'2013-08-31' <= DCOL AND DCOL <= '2013-12-31'", "'2010-10-18' <= DCOL AND DCOL <= '2013-10-17'",
}); });
} }
@ -307,6 +310,7 @@ public void testTimePartition() throws Exception {
PartitionerContext partitionerContext = new PartitionerContext(context, PartitionerContext partitionerContext = new PartitionerContext(context,
3); 3);
List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf); List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
verifyResult(partitions, new String[]{ verifyResult(partitions, new String[]{
"'01:01:01' <= TCOL AND TCOL < '04:14:17'", "'01:01:01' <= TCOL AND TCOL < '04:14:17'",
"'04:14:17' <= TCOL AND TCOL < '07:27:33'", "'04:14:17' <= TCOL AND TCOL < '07:27:33'",