mirror of
https://github.com/apache/sqoop.git
synced 2025-05-06 05:59:55 +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.Time;
|
||||
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.JSONObject;
|
||||
|
||||
@ -131,8 +131,8 @@ private static JSONObject extractColumn(Column column) {
|
||||
case TIME:
|
||||
ret.put(FRACTION, ((Time)column).getFraction());
|
||||
break;
|
||||
case UNSUPPORTED:
|
||||
ret.put(JDBC_TYPE, ((Unsupported) column).getJdbcType());
|
||||
case UNKNOWN:
|
||||
ret.put(JDBC_TYPE, ((Unknown) column).getJdbcType());
|
||||
break;
|
||||
case DATE:
|
||||
case BIT:
|
||||
@ -208,8 +208,8 @@ private static Column restoreColumn(JSONObject obj) {
|
||||
case TIME:
|
||||
output = new Time().setFraction(fraction);
|
||||
break;
|
||||
case UNSUPPORTED:
|
||||
output = new Unsupported().setJdbcType(jdbcType);
|
||||
case UNKNOWN:
|
||||
output = new Unknown().setJdbcType(jdbcType);
|
||||
break;
|
||||
default:
|
||||
// TODO(Jarcec): Throw an exception of unsupported type?
|
||||
|
@ -34,6 +34,6 @@ public enum ColumnType {
|
||||
SET,
|
||||
TEXT,
|
||||
TIME,
|
||||
UNSUPPORTED,
|
||||
UNKNOWN,
|
||||
;
|
||||
}
|
||||
|
@ -18,9 +18,10 @@
|
||||
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.
|
||||
@ -29,39 +30,39 @@ public class Unsupported extends Binary {
|
||||
|
||||
@Override
|
||||
public ColumnType getType() {
|
||||
return ColumnType.UNSUPPORTED;
|
||||
return ColumnType.UNKNOWN;
|
||||
}
|
||||
|
||||
public Long getJdbcType() {
|
||||
return jdbcType;
|
||||
}
|
||||
|
||||
public Unsupported setJdbcType(Long jdbcType) {
|
||||
public Unknown setJdbcType(Long jdbcType) {
|
||||
this.jdbcType = jdbcType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Unsupported() {
|
||||
public Unknown() {
|
||||
}
|
||||
|
||||
public Unsupported(Long jdbcType) {
|
||||
public Unknown(Long jdbcType) {
|
||||
setJdbcType(jdbcType);
|
||||
}
|
||||
|
||||
public Unsupported(String name) {
|
||||
public Unknown(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public Unsupported(String name, Long jdbcType) {
|
||||
public Unknown(String name, Long jdbcType) {
|
||||
super(name);
|
||||
setJdbcType(jdbcType);
|
||||
}
|
||||
|
||||
public Unsupported(String name, Boolean nullable) {
|
||||
public Unknown(String name, Boolean nullable) {
|
||||
super(name, nullable);
|
||||
}
|
||||
|
||||
public Unsupported(String name, Boolean nullable, Long jdbcType) {
|
||||
public Unknown(String name, Boolean nullable, Long jdbcType) {
|
||||
super(name, nullable);
|
||||
setJdbcType(jdbcType);
|
||||
}
|
@ -31,7 +31,7 @@
|
||||
import org.apache.sqoop.schema.type.Set;
|
||||
import org.apache.sqoop.schema.type.Text;
|
||||
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.JSONValue;
|
||||
import org.junit.Test;
|
||||
@ -123,7 +123,7 @@ public void testTime() {
|
||||
|
||||
@Test
|
||||
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);
|
||||
}
|
||||
@Test
|
||||
@ -148,7 +148,7 @@ public void testAllTypes() {
|
||||
.addColumn(new Set("k", new Text()))
|
||||
.addColumn(new Text("l"))
|
||||
.addColumn(new Time("m"))
|
||||
.addColumn(new Unsupported("u"))
|
||||
.addColumn(new Unknown("u"))
|
||||
;
|
||||
transferAndAssert(allTypes);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
import org.apache.sqoop.schema.type.FloatingPoint;
|
||||
import org.apache.sqoop.schema.type.Text;
|
||||
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;
|
||||
|
||||
@ -88,7 +88,7 @@ public static Column sqlTypeToAbstractType(int sqlType) {
|
||||
return new Binary();
|
||||
|
||||
default:
|
||||
return new Unsupported((long)sqlType);
|
||||
return new Unknown((long)sqlType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,6 +202,8 @@ public Object[] getObjectData() {
|
||||
out[i] = unescapeStrings(fields[i]);
|
||||
break;
|
||||
case BINARY:
|
||||
// Unknown is treated as a binary type
|
||||
case UNKNOWN:
|
||||
out[i] = unescapeByteArray(fields[i]);
|
||||
break;
|
||||
case FIXED_POINT:
|
||||
|
Loading…
Reference in New Issue
Block a user