sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gwens...@apache.org
Subject sqoop git commit: SQOOP-2152: Sqoop2: Kite connector always assumes that FixedPoint is long regardless of the configured size
Date Sun, 01 Mar 2015 04:55:57 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 a021b7cdb -> b9d70d077


SQOOP-2152: Sqoop2: Kite connector always assumes that FixedPoint is long regardless of the
configured size

(Jarek Jarcec Cecho via Gwen Shapira)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/b9d70d07
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/b9d70d07
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/b9d70d07

Branch: refs/heads/sqoop2
Commit: b9d70d077a2359493611a56d2a49eb987532eb15
Parents: a021b7c
Author: Gwen Shapira <cshapi@gmail.com>
Authored: Sat Feb 28 20:53:50 2015 -0800
Committer: Gwen Shapira <cshapi@gmail.com>
Committed: Sat Feb 28 20:53:50 2015 -0800

----------------------------------------------------------------------
 .../connector/kite/util/KiteDataTypeUtil.java   | 23 +++++++++++++-------
 1 file changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/b9d70d07/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/util/KiteDataTypeUtil.java
----------------------------------------------------------------------
diff --git a/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/util/KiteDataTypeUtil.java
b/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/util/KiteDataTypeUtil.java
index f4f30fb..2851459 100644
--- a/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/util/KiteDataTypeUtil.java
+++ b/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/util/KiteDataTypeUtil.java
@@ -24,6 +24,7 @@ import org.apache.avro.generic.GenericRecord;
 import org.apache.sqoop.connector.common.FileFormat;
 import org.apache.sqoop.schema.type.Column;
 import org.apache.sqoop.schema.type.ColumnType;
+import org.apache.sqoop.schema.type.FixedPoint;
 import org.joda.time.LocalDate;
 import org.joda.time.LocalDateTime;
 import org.kitesdk.data.Format;
@@ -70,7 +71,7 @@ public class KiteDataTypeUtil {
   }
 
   private static Schema createAvroFieldSchema(Column column) {
-    Schema.Type type = toAvroType(column.getType());
+    Schema.Type type = toAvroType(column);
     if (!column.isNullable()) {
       return Schema.create(type);
     } else {
@@ -81,9 +82,8 @@ public class KiteDataTypeUtil {
     }
   }
 
-  private static Schema.Type toAvroType(ColumnType type)
-      throws IllegalArgumentException {
-    switch (type) {
+  private static Schema.Type toAvroType(Column column) throws IllegalArgumentException {
+    switch (column.getType()) {
       case ARRAY:
         return Schema.Type.ARRAY;
       case BINARY:
@@ -101,8 +101,16 @@ public class KiteDataTypeUtil {
       case ENUM:
       case SET:
         return Schema.Type.ENUM;
-      case FIXED_POINT:
-        return Schema.Type.LONG;
+      case FIXED_POINT: {
+        FixedPoint fp = (FixedPoint)column;
+        if(fp.getByteSize() <= 4L) {
+          return Schema.Type.INT;
+        } else if(fp.getByteSize() <= 8L) {
+          return Schema.Type.LONG;
+        } else {
+          throw new IllegalArgumentException("Unsupported size of FixedType column " + fp.getByteSize());
+        }
+      }
       case FLOATING_POINT:
         return Schema.Type.DOUBLE;
       case MAP:
@@ -112,8 +120,7 @@ public class KiteDataTypeUtil {
       case UNKNOWN:
         return Schema.Type.NULL;
       default:
-        throw new IllegalArgumentException(
-            "Unsupported Sqoop Data Type " + type);
+        throw new IllegalArgumentException("Unsupported Sqoop Data Type " + column.getType());
     }
   }
 


Mime
View raw message