mirror of
https://github.com/apache/sqoop.git
synced 2025-05-08 10:41:11 +08:00
SQOOP-1708: Rename Unsupported Column type to Unknown and add java doc
(Veena Basavaraj via Jarek Jarcec Cecho)
This commit is contained in:
parent
816aa03896
commit
4fd8dec145
@ -35,7 +35,7 @@
|
|||||||
import org.apache.sqoop.schema.type.Text;
|
import org.apache.sqoop.schema.type.Text;
|
||||||
import org.apache.sqoop.schema.type.Time;
|
import org.apache.sqoop.schema.type.Time;
|
||||||
import org.apache.sqoop.schema.type.ColumnType;
|
import org.apache.sqoop.schema.type.ColumnType;
|
||||||
import org.apache.sqoop.schema.type.Unsupported;
|
import org.apache.sqoop.schema.type.Unknown;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
@ -131,8 +131,8 @@ private static JSONObject extractColumn(Column column) {
|
|||||||
case TIME:
|
case TIME:
|
||||||
ret.put(FRACTION, ((Time)column).getFraction());
|
ret.put(FRACTION, ((Time)column).getFraction());
|
||||||
break;
|
break;
|
||||||
case UNSUPPORTED:
|
case UNKNOWN:
|
||||||
ret.put(JDBC_TYPE, ((Unsupported) column).getJdbcType());
|
ret.put(JDBC_TYPE, ((Unknown) column).getJdbcType());
|
||||||
break;
|
break;
|
||||||
case DATE:
|
case DATE:
|
||||||
case BIT:
|
case BIT:
|
||||||
@ -208,8 +208,8 @@ private static Column restoreColumn(JSONObject obj) {
|
|||||||
case TIME:
|
case TIME:
|
||||||
output = new Time().setFraction(fraction);
|
output = new Time().setFraction(fraction);
|
||||||
break;
|
break;
|
||||||
case UNSUPPORTED:
|
case UNKNOWN:
|
||||||
output = new Unsupported().setJdbcType(jdbcType);
|
output = new Unknown().setJdbcType(jdbcType);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO(Jarcec): Throw an exception of unsupported type?
|
// TODO(Jarcec): Throw an exception of unsupported type?
|
||||||
|
@ -34,6 +34,6 @@ public enum ColumnType {
|
|||||||
SET,
|
SET,
|
||||||
TEXT,
|
TEXT,
|
||||||
TIME,
|
TIME,
|
||||||
UNSUPPORTED,
|
UNKNOWN,
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
package org.apache.sqoop.schema.type;
|
package org.apache.sqoop.schema.type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsupported data type (internally encoded as binary).
|
* Unknown column type (internally encoded as binary)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class Unsupported extends Binary {
|
public class Unknown extends Binary {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional JDBC type that is unknown.
|
* Optional JDBC type that is unknown.
|
||||||
@ -29,39 +30,39 @@ public class Unsupported extends Binary {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ColumnType getType() {
|
public ColumnType getType() {
|
||||||
return ColumnType.UNSUPPORTED;
|
return ColumnType.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getJdbcType() {
|
public Long getJdbcType() {
|
||||||
return jdbcType;
|
return jdbcType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Unsupported setJdbcType(Long jdbcType) {
|
public Unknown setJdbcType(Long jdbcType) {
|
||||||
this.jdbcType = jdbcType;
|
this.jdbcType = jdbcType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Unsupported() {
|
public Unknown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Unsupported(Long jdbcType) {
|
public Unknown(Long jdbcType) {
|
||||||
setJdbcType(jdbcType);
|
setJdbcType(jdbcType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Unsupported(String name) {
|
public Unknown(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Unsupported(String name, Long jdbcType) {
|
public Unknown(String name, Long jdbcType) {
|
||||||
super(name);
|
super(name);
|
||||||
setJdbcType(jdbcType);
|
setJdbcType(jdbcType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Unsupported(String name, Boolean nullable) {
|
public Unknown(String name, Boolean nullable) {
|
||||||
super(name, nullable);
|
super(name, nullable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Unsupported(String name, Boolean nullable, Long jdbcType) {
|
public Unknown(String name, Boolean nullable, Long jdbcType) {
|
||||||
super(name, nullable);
|
super(name, nullable);
|
||||||
setJdbcType(jdbcType);
|
setJdbcType(jdbcType);
|
||||||
}
|
}
|
@ -31,7 +31,7 @@
|
|||||||
import org.apache.sqoop.schema.type.Set;
|
import org.apache.sqoop.schema.type.Set;
|
||||||
import org.apache.sqoop.schema.type.Text;
|
import org.apache.sqoop.schema.type.Text;
|
||||||
import org.apache.sqoop.schema.type.Time;
|
import org.apache.sqoop.schema.type.Time;
|
||||||
import org.apache.sqoop.schema.type.Unsupported;
|
import org.apache.sqoop.schema.type.Unknown;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.JSONValue;
|
import org.json.simple.JSONValue;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -123,7 +123,7 @@ public void testTime() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnsupported() {
|
public void testUnsupported() {
|
||||||
Schema t = new Schema("t").addColumn(new Unsupported("u", 4L));
|
Schema t = new Schema("t").addColumn(new Unknown("u", 4L));
|
||||||
transferAndAssert(t);
|
transferAndAssert(t);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
@ -148,7 +148,7 @@ public void testAllTypes() {
|
|||||||
.addColumn(new Set("k", new Text()))
|
.addColumn(new Set("k", new Text()))
|
||||||
.addColumn(new Text("l"))
|
.addColumn(new Text("l"))
|
||||||
.addColumn(new Time("m"))
|
.addColumn(new Time("m"))
|
||||||
.addColumn(new Unsupported("u"))
|
.addColumn(new Unknown("u"))
|
||||||
;
|
;
|
||||||
transferAndAssert(allTypes);
|
transferAndAssert(allTypes);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
import org.apache.sqoop.schema.type.FloatingPoint;
|
import org.apache.sqoop.schema.type.FloatingPoint;
|
||||||
import org.apache.sqoop.schema.type.Text;
|
import org.apache.sqoop.schema.type.Text;
|
||||||
import org.apache.sqoop.schema.type.Time;
|
import org.apache.sqoop.schema.type.Time;
|
||||||
import org.apache.sqoop.schema.type.Unsupported;
|
import org.apache.sqoop.schema.type.Unknown;
|
||||||
|
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ public static Column sqlTypeToAbstractType(int sqlType) {
|
|||||||
return new Binary();
|
return new Binary();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new Unsupported((long)sqlType);
|
return new Unknown((long)sqlType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +202,8 @@ public Object[] getObjectData() {
|
|||||||
out[i] = unescapeStrings(fields[i]);
|
out[i] = unescapeStrings(fields[i]);
|
||||||
break;
|
break;
|
||||||
case BINARY:
|
case BINARY:
|
||||||
|
// Unknown is treated as a binary type
|
||||||
|
case UNKNOWN:
|
||||||
out[i] = unescapeByteArray(fields[i]);
|
out[i] = unescapeByteArray(fields[i]);
|
||||||
break;
|
break;
|
||||||
case FIXED_POINT:
|
case FIXED_POINT:
|
||||||
|
Loading…
Reference in New Issue
Block a user