mirror of
https://github.com/apache/sqoop.git
synced 2025-05-20 10:51:21 +08:00
SQOOP-1046: Sqoop2: Importing single row using decimal splitter will not import anything
(Jarek Jarcec Cecho via Kate Ting)
This commit is contained in:
parent
c0a43d436f
commit
2941fa666c
@ -169,7 +169,7 @@ protected List<Partition> partitionFloatingPointColumn() {
|
|||||||
protected List<Partition> partitionNumericColumn() {
|
protected List<Partition> partitionNumericColumn() {
|
||||||
List<Partition> partitions = new LinkedList<Partition>();
|
List<Partition> partitions = new LinkedList<Partition>();
|
||||||
|
|
||||||
// All null valeus will result in single partition
|
// All null values will result in single partition
|
||||||
if (partitionMinValue == null && partitionMaxValue == null) {
|
if (partitionMinValue == null && partitionMaxValue == null) {
|
||||||
GenericJdbcImportPartition partition = new GenericJdbcImportPartition();
|
GenericJdbcImportPartition partition = new GenericJdbcImportPartition();
|
||||||
partition.setConditions(partitionColumnName + "IS NULL");
|
partition.setConditions(partitionColumnName + "IS NULL");
|
||||||
@ -185,6 +185,13 @@ protected List<Partition> partitionNumericColumn() {
|
|||||||
BigDecimal minValue = new BigDecimal(partitionMinValue);
|
BigDecimal minValue = new BigDecimal(partitionMinValue);
|
||||||
BigDecimal maxValue = new BigDecimal(partitionMaxValue);
|
BigDecimal maxValue = new BigDecimal(partitionMaxValue);
|
||||||
|
|
||||||
|
// Having one single value means that we can create only one single split
|
||||||
|
if(minValue.equals(maxValue)) {
|
||||||
|
GenericJdbcImportPartition partition = new GenericJdbcImportPartition();
|
||||||
|
partition.setConditions(constructConditions(minValue));
|
||||||
|
partitions.add(partition);
|
||||||
|
}
|
||||||
|
|
||||||
// Get all the split points together.
|
// Get all the split points together.
|
||||||
List<BigDecimal> splitPoints = new LinkedList<BigDecimal>();
|
List<BigDecimal> splitPoints = new LinkedList<BigDecimal>();
|
||||||
|
|
||||||
@ -240,4 +247,13 @@ protected String constructConditions(
|
|||||||
conditions.append(upperBound);
|
conditions.append(upperBound);
|
||||||
return conditions.toString();
|
return conditions.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String constructConditions(Object value) {
|
||||||
|
return new StringBuilder()
|
||||||
|
.append(partitionColumnName)
|
||||||
|
.append(" = ")
|
||||||
|
.append(value)
|
||||||
|
.toString()
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,6 +238,25 @@ public void testNumericUnevenPartition() throws Exception {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNumericSinglePartition() throws Exception {
|
||||||
|
MutableContext context = new MutableMapContext();
|
||||||
|
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_COLUMNNAME, "DCOL");
|
||||||
|
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_COLUMNTYPE, String.valueOf(Types.NUMERIC));
|
||||||
|
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MINVALUE, String.valueOf(new BigDecimal(START)));
|
||||||
|
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MAXVALUE, String.valueOf(new BigDecimal(START)));
|
||||||
|
|
||||||
|
ConnectionConfiguration connConf = new ConnectionConfiguration();
|
||||||
|
ImportJobConfiguration jobConf = new ImportJobConfiguration();
|
||||||
|
|
||||||
|
Partitioner partitioner = new GenericJdbcImportPartitioner();
|
||||||
|
PartitionerContext partitionerContext = new PartitionerContext(context, 3);
|
||||||
|
List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
|
||||||
|
|
||||||
|
verifyResult(partitions, new String[]{
|
||||||
|
"DCOL = -5",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyResult(List<Partition> partitions,
|
private void verifyResult(List<Partition> partitions,
|
||||||
String[] expected) {
|
String[] expected) {
|
||||||
assertEquals(expected.length, partitions.size());
|
assertEquals(expected.length, partitions.size());
|
||||||
|
Loading…
Reference in New Issue
Block a user