sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-1715: Make name for column required ( fix the corr tests)
Date Thu, 13 Nov 2014 06:28:29 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 3edf9cad6 -> 0ace9710e


SQOOP-1715: Make name for column required ( fix the corr tests)

(Veena Basavaraj via Jarek Jarcec Cecho)


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

Branch: refs/heads/sqoop2
Commit: 0ace9710ebeb5ed330a7ebfd19e9245563b7d349
Parents: 3edf9ca
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Wed Nov 12 22:28:08 2014 -0800
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Wed Nov 12 22:28:08 2014 -0800

----------------------------------------------------------------------
 .../sqoop/json/util/SchemaSerialization.java    | 30 +++++++++-----------
 .../schema/type/AbstractComplexListType.java    |  8 +++---
 .../sqoop/schema/type/AbstractComplexType.java  |  4 ---
 .../sqoop/schema/type/AbstractDateTime.java     |  4 ---
 .../sqoop/schema/type/AbstractNumber.java       |  4 ---
 .../schema/type/AbstractPrimitiveType.java      |  7 ++---
 .../sqoop/schema/type/AbstractString.java       |  4 ---
 .../org/apache/sqoop/schema/type/Array.java     |  4 ---
 .../org/apache/sqoop/schema/type/Binary.java    |  4 ---
 .../java/org/apache/sqoop/schema/type/Bit.java  |  4 ---
 .../org/apache/sqoop/schema/type/Column.java    | 18 ++++--------
 .../java/org/apache/sqoop/schema/type/Date.java |  4 ---
 .../org/apache/sqoop/schema/type/DateTime.java  |  9 ------
 .../org/apache/sqoop/schema/type/Decimal.java   |  9 ------
 .../java/org/apache/sqoop/schema/type/Enum.java |  4 +--
 .../apache/sqoop/schema/type/FixedPoint.java    |  9 ------
 .../apache/sqoop/schema/type/FloatingPoint.java |  9 ------
 .../java/org/apache/sqoop/schema/type/Map.java  |  5 ----
 .../java/org/apache/sqoop/schema/type/Set.java  |  4 +--
 .../java/org/apache/sqoop/schema/type/Text.java |  4 ---
 .../java/org/apache/sqoop/schema/type/Time.java |  8 ------
 .../org/apache/sqoop/schema/type/Unknown.java   |  8 ------
 .../json/util/TestSchemaSerialization.java      | 18 ++++++------
 .../jdbc/GenericJdbcFromInitializer.java        | 13 +++------
 .../jdbc/GenericJdbcToInitializer.java          |  9 +++---
 .../connector/jdbc/util/SqlTypesUtils.java      | 24 +++++++++-------
 26 files changed, 60 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/json/util/SchemaSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/util/SchemaSerialization.java b/common/src/main/java/org/apache/sqoop/json/util/SchemaSerialization.java
index 6dc93d5..dec8c0e 100644
--- a/common/src/main/java/org/apache/sqoop/json/util/SchemaSerialization.java
+++ b/common/src/main/java/org/apache/sqoop/json/util/SchemaSerialization.java
@@ -202,63 +202,61 @@ public class SchemaSerialization {
     Column output = null;
     switch (type) {
     case ARRAY:
-      output = new Array(listType).setSize(arraySize);
+      output = new Array(name, listType).setSize(arraySize);
       break;
     case BINARY:
       Long charSize = (Long) obj.get(CHAR_SIZE);
-      output = new Binary().setCharSize(charSize);
+      output = new Binary(name).setCharSize(charSize);
       break;
     case BIT:
-      output = new Bit();
+      output = new Bit(name);
       break;
     case DATE:
-      output = new Date();
+      output = new Date(name);
       break;
     case DATE_TIME:
       Boolean fraction = (Boolean) obj.get(FRACTION);
       Boolean timezone = (Boolean) obj.get(TIMEZONE);
-      output = new DateTime().setFraction(fraction).setTimezone(timezone);
+      output = new DateTime(name).setFraction(fraction).setTimezone(timezone);
       break;
     case DECIMAL:
       Long precision = (Long) obj.get(PRECISION);
       Long scale = (Long) obj.get(SCALE);
-      output = new Decimal().setPrecision(precision).setScale(scale);
+      output = new Decimal(name).setPrecision(precision).setScale(scale);
       break;
     case ENUM:
-      output = new Enum(listType);
+      output = new Enum(name).setListType(listType);
       break;
     case FIXED_POINT:
       Boolean unsigned = (Boolean) obj.get(UNSIGNED);
       Long fixedPointByteSize = (Long) obj.get(BYTE_SIZE);
-      output = new FixedPoint().setByteSize(fixedPointByteSize).setUnsigned(unsigned);
+      output = new FixedPoint(name).setByteSize(fixedPointByteSize).setUnsigned(unsigned);
       break;
     case FLOATING_POINT:
       Long floatingPointByteSize = (Long) obj.get(BYTE_SIZE);
-      output = new FloatingPoint().setByteSize(floatingPointByteSize);
+      output = new FloatingPoint(name).setByteSize(floatingPointByteSize);
       break;
     case MAP:
-      output = new Map(key, value);
+      output = new Map(name, key, value);
       break;
     case SET:
-      output = new Set(listType);
+      output = new Set(name).setListType(listType);
       break;
     case TEXT:
       charSize = (Long) obj.get(CHAR_SIZE);
-      output = new Text().setCharSize(charSize);
+      output = new Text(name).setCharSize(charSize);
       break;
     case TIME:
       Boolean timeFraction = (Boolean) obj.get(FRACTION);
-      output = new Time().setFraction(timeFraction);
+      output = new Time(name).setFraction(timeFraction);
       break;
     case UNKNOWN:
       Long jdbcType = (Long) obj.get(JDBC_TYPE);
-      output = new Unknown().setJdbcType(jdbcType);
+      output = new Unknown(name).setJdbcType(jdbcType);
       break;
     default:
       // TODO(Jarcec): Throw an exception of unsupported type?
     }
-
-    output.setName(name);
     output.setNullable(nullable);
 
     return output;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/AbstractComplexListType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/AbstractComplexListType.java
b/common/src/main/java/org/apache/sqoop/schema/type/AbstractComplexListType.java
index 326fe1d..5d8f28b 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/AbstractComplexListType.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/AbstractComplexListType.java
@@ -25,9 +25,8 @@ public abstract class AbstractComplexListType extends AbstractComplexType
{
   // represents the type of the list elements
   Column listType;
 
-  public AbstractComplexListType(Column listType) {
-    super();
-    setListType(listType);
+  public AbstractComplexListType(String name) {
+    super(name);
   }
 
   public AbstractComplexListType(String name, Column listType) {
@@ -40,9 +39,10 @@ public abstract class AbstractComplexListType extends AbstractComplexType
{
     setListType(listType);
   }
 
-  private void setListType(Column listType) {
+  public AbstractComplexListType setListType(Column listType) {
     assert listType != null;
     this.listType = listType;
+    return this;
   }
 
   public Column getListType() {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/AbstractComplexType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/AbstractComplexType.java b/common/src/main/java/org/apache/sqoop/schema/type/AbstractComplexType.java
index 880cb27..7c4200a 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/AbstractComplexType.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/AbstractComplexType.java
@@ -22,10 +22,6 @@ package org.apache.sqoop.schema.type;
  */
 public abstract class AbstractComplexType extends Column {
 
-  public AbstractComplexType() {
-    super();
-  }
-
   public AbstractComplexType(String name) {
     super(name);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/AbstractDateTime.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/AbstractDateTime.java b/common/src/main/java/org/apache/sqoop/schema/type/AbstractDateTime.java
index 76b0542..413eb37 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/AbstractDateTime.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/AbstractDateTime.java
@@ -22,10 +22,6 @@ package org.apache.sqoop.schema.type;
  */
 public abstract class AbstractDateTime extends Column {
 
-  protected AbstractDateTime() {
-    super();
-  }
-
   protected AbstractDateTime(String name) {
     super(name);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/AbstractNumber.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/AbstractNumber.java b/common/src/main/java/org/apache/sqoop/schema/type/AbstractNumber.java
index 1418aed..3fccf5a 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/AbstractNumber.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/AbstractNumber.java
@@ -22,10 +22,6 @@ package org.apache.sqoop.schema.type;
  */
 public abstract class AbstractNumber extends AbstractPrimitiveType {
 
-  protected AbstractNumber() {
-    super();
-  }
-
   protected AbstractNumber(String name) {
     super(name);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/AbstractPrimitiveType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/AbstractPrimitiveType.java
b/common/src/main/java/org/apache/sqoop/schema/type/AbstractPrimitiveType.java
index b8c39e5..24acdf1 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/AbstractPrimitiveType.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/AbstractPrimitiveType.java
@@ -21,15 +21,12 @@ package org.apache.sqoop.schema.type;
  * Primitive type for column
  */
 public abstract class AbstractPrimitiveType extends Column {
-  protected AbstractPrimitiveType() {
-    super();
-  }
 
-  protected AbstractPrimitiveType(String name) {
+  public AbstractPrimitiveType(String name) {
     super(name);
   }
 
-  protected AbstractPrimitiveType(String name, Boolean nullable) {
+  public AbstractPrimitiveType(String name, Boolean nullable) {
     super(name, nullable);
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/AbstractString.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/AbstractString.java b/common/src/main/java/org/apache/sqoop/schema/type/AbstractString.java
index 9600c15..bc1c80b 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/AbstractString.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/AbstractString.java
@@ -29,10 +29,6 @@ public abstract class AbstractString extends AbstractPrimitiveType {
    */
   private Long charSize;
 
-  protected AbstractString() {
-    super();
-  }
-
   protected AbstractString(String name) {
     super(name);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Array.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Array.java b/common/src/main/java/org/apache/sqoop/schema/type/Array.java
index 7f8fda4..af13eb7 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Array.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Array.java
@@ -32,10 +32,6 @@ public class Array extends AbstractComplexListType {
    */
   private Long size;
 
-  public Array(Column listType) {
-    super(listType);
-  }
-
   public Array(String name, Column listType) {
     super(name, listType);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Binary.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Binary.java b/common/src/main/java/org/apache/sqoop/schema/type/Binary.java
index 5c805ae..b9622ac 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Binary.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Binary.java
@@ -24,10 +24,6 @@ package org.apache.sqoop.schema.type;
  */
 public class Binary extends AbstractString {
 
-  public Binary() {
-    super();
-  }
-
   public Binary(String name) {
     super(name);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Bit.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Bit.java b/common/src/main/java/org/apache/sqoop/schema/type/Bit.java
index dfd7a2f..d5d5b67 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Bit.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Bit.java
@@ -24,10 +24,6 @@ package org.apache.sqoop.schema.type;
  */
 public class Bit extends Column {
 
-  public Bit() {
-    super();
-  }
-
   public Bit(String name) {
     super(name);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Column.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Column.java b/common/src/main/java/org/apache/sqoop/schema/type/Column.java
index 466eeea..2d7eac2 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Column.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Column.java
@@ -17,6 +17,8 @@
  */
 package org.apache.sqoop.schema.type;
 
+import org.apache.commons.lang.StringUtils;
+
 /**
  * Base class for all the supported types in the Sqoop {@link #Schema}
  */
@@ -33,18 +35,15 @@ public abstract class Column {
   Boolean nullable;
 
   /**
-   * By default a column has empty name and is nullable
+   * By default a column is nullable
    */
-  public Column() {
-    this("", true);
-  }
-
-  public Column(String name) {
+   public Column(String name) {
     this(name, true);
   }
 
   public Column(String name, Boolean nullable) {
-    setName(name);
+    assert !StringUtils.isEmpty(name);
+    this.name = name;
     setNullable(nullable);
   }
 
@@ -55,11 +54,6 @@ public abstract class Column {
    */
   public abstract ColumnType getType();
 
-  public Column setName(String name) {
-    this.name = name;
-    return this;
-  }
-
   public Column setNullable(Boolean nullable) {
     this.nullable = nullable;
     return this;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Date.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Date.java b/common/src/main/java/org/apache/sqoop/schema/type/Date.java
index e0e85e5..2bb72bb 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Date.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Date.java
@@ -24,10 +24,6 @@ package org.apache.sqoop.schema.type;
  */
 public class Date extends AbstractDateTime {
 
-  public Date() {
-    super();
-  }
-
   public Date(String name) {
     super(name);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/DateTime.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/DateTime.java b/common/src/main/java/org/apache/sqoop/schema/type/DateTime.java
index 246e424..791542a 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/DateTime.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/DateTime.java
@@ -34,19 +34,10 @@ public class DateTime extends AbstractDateTime {
    */
   private Boolean timezone;
 
-  public DateTime() {
-    super();
-  }
-
   public DateTime(String name) {
     super(name);
   }
 
-  public DateTime(Boolean fraction, Boolean timezone) {
-    this.fraction = fraction;
-    this.timezone = timezone;
-  }
-
   public DateTime(String name, Boolean fraction, Boolean timezone) {
     super(name);
     this.fraction = fraction;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Decimal.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Decimal.java b/common/src/main/java/org/apache/sqoop/schema/type/Decimal.java
index 66c368e..e669700 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Decimal.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Decimal.java
@@ -34,19 +34,10 @@ public class Decimal extends AbstractNumber {
    */
   private Long scale;
 
-  public Decimal() {
-    super();
-  }
-
   public Decimal(String name) {
     super(name);
   }
 
-  public Decimal(Long precision, Long scale) {
-    this.precision = precision;
-    this.scale = scale;
-  }
-
   public Decimal(String name, Long precision, Long scale) {
     super(name);
     this.precision = precision;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Enum.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Enum.java b/common/src/main/java/org/apache/sqoop/schema/type/Enum.java
index f2a60d9..1388d49 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Enum.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Enum.java
@@ -25,8 +25,8 @@ package org.apache.sqoop.schema.type;
 
 public class Enum extends AbstractComplexListType {
 
-  public Enum(Column listType) {
-    super(listType);
+  public Enum(String name) {
+    super(name);
   }
 
   public Enum(String name, Column listType) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/FixedPoint.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/FixedPoint.java b/common/src/main/java/org/apache/sqoop/schema/type/FixedPoint.java
index a8442bb..836e4ad 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/FixedPoint.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/FixedPoint.java
@@ -38,19 +38,10 @@ public class FixedPoint extends AbstractNumber {
 
   private Boolean unsigned;
 
-  public FixedPoint() {
-    super();
-  }
-
   public FixedPoint(String name) {
     super(name);
   }
 
-  public FixedPoint(Long byteSize, Boolean unsigned) {
-    this.byteSize = byteSize;
-    this.unsigned = unsigned;
-  }
-
   public FixedPoint(String name, Long byteSize, Boolean unsigned) {
     super(name);
     this.byteSize = byteSize;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/FloatingPoint.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/FloatingPoint.java b/common/src/main/java/org/apache/sqoop/schema/type/FloatingPoint.java
index 23679dc..7dcc753 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/FloatingPoint.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/FloatingPoint.java
@@ -31,18 +31,9 @@ public class FloatingPoint extends AbstractNumber {
   */
   private Long byteSize;
 
-  public FloatingPoint() {
-    super();
-  }
-
   public FloatingPoint(String name) {
     super(name);
   }
-
-  public FloatingPoint(Long byteSize) {
-    this.byteSize = byteSize;
-  }
-
   public FloatingPoint(String name, Long byteSize) {
     super(name);
     this.byteSize = byteSize;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Map.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Map.java b/common/src/main/java/org/apache/sqoop/schema/type/Map.java
index c85e70b..5a0b18e 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Map.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Map.java
@@ -29,11 +29,6 @@ public class Map extends AbstractComplexType {
   // The value inside the map can be either a primitive or a complex column type
   private Column value;
 
-  public Map(AbstractPrimitiveType key, Column value) {
-    super();
-    setKeyValue(key, value);
-  }
-
   public Map(String name, AbstractPrimitiveType key, Column value) {
     super(name);
     setKeyValue(key, value);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Set.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Set.java b/common/src/main/java/org/apache/sqoop/schema/type/Set.java
index aa796a3..5585847 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Set.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Set.java
@@ -24,8 +24,8 @@ package org.apache.sqoop.schema.type;
  */
 public class Set extends AbstractComplexListType {
 
-  public Set(Column listType) {
-    super(listType);
+  public Set(String name) {
+    super(name);
   }
 
   public Set(String name, Column listType) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Text.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Text.java b/common/src/main/java/org/apache/sqoop/schema/type/Text.java
index d6582c0..9dde1de 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Text.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Text.java
@@ -24,10 +24,6 @@ package org.apache.sqoop.schema.type;
  */
 public class Text extends AbstractString {
 
-  public Text() {
-    super();
-  }
-
   public Text(String name) {
     super(name);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Time.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Time.java b/common/src/main/java/org/apache/sqoop/schema/type/Time.java
index d5774a1..9765eab 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Time.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Time.java
@@ -26,18 +26,10 @@ public class Time extends AbstractDateTime {
 
   private Boolean fraction;
 
-  public Time() {
-    super();
-  }
-
   public Time(String name) {
     super(name);
   }
 
-  public Time(Boolean fraction) {
-    this.fraction = fraction;
-  }
-
   public Time(String name, Boolean fraction) {
     super(name);
     this.fraction = fraction;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/main/java/org/apache/sqoop/schema/type/Unknown.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/schema/type/Unknown.java b/common/src/main/java/org/apache/sqoop/schema/type/Unknown.java
index df4061b..90fb0f0 100644
--- a/common/src/main/java/org/apache/sqoop/schema/type/Unknown.java
+++ b/common/src/main/java/org/apache/sqoop/schema/type/Unknown.java
@@ -42,14 +42,6 @@ public class Unknown extends Binary {
     return this;
   }
 
-  public Unknown() {
-    super();
-  }
-
-  public Unknown(Long jdbcType) {
-    setJdbcType(jdbcType);
-  }
-
   public Unknown(String name) {
     super(name);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
b/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
index aca67d1..9f8ee3e 100644
--- a/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
+++ b/common/src/test/java/org/apache/sqoop/json/util/TestSchemaSerialization.java
@@ -60,7 +60,7 @@ public class TestSchemaSerialization {
   @Test
   public void testArray() {
     // create an array type containing decimals
-    Schema array = new Schema("array").addColumn(new Array("a", new Decimal()).setSize(1L));
+    Schema array = new Schema("array").addColumn(new Array("a", new Decimal("a1")).setSize(1L));
     transferAndAssert(array);
   }
 
@@ -96,7 +96,7 @@ public class TestSchemaSerialization {
 
   @Test
   public void testEnum() {
-    Schema e = new Schema("e").addColumn(new Enum("e", new Text()));
+    Schema e = new Schema("e").addColumn(new Enum("e", new Text("e1")));
     transferAndAssert(e);
   }
 
@@ -114,13 +114,13 @@ public class TestSchemaSerialization {
 
   @Test
   public void testMap() {
-    Schema m = new Schema("m").addColumn(new Map("m", new Text(), new Decimal()));
+    Schema m = new Schema("m").addColumn(new Map("m", new Text("m1"), new Decimal("m2")));
     transferAndAssert(m);
   }
 
   @Test
   public void testSet() {
-    Schema s = new Schema("s").addColumn(new Set("b", new Binary()));
+    Schema s = new Schema("s").addColumn(new Set("b", new Binary("b1")));
     transferAndAssert(s);
   }
 
@@ -150,17 +150,17 @@ public class TestSchemaSerialization {
   @Test
   public void testAllTypes() {
     Schema allTypes = new Schema("all-types")
-      .addColumn(new Array("a", new Text()))
+      .addColumn(new Array("a", new Text("a1")))
       .addColumn(new Binary("b"))
       .addColumn(new Bit("c"))
       .addColumn(new Date("d"))
       .addColumn(new DateTime("e"))
       .addColumn(new Decimal("f"))
-      .addColumn(new Enum("g", new Text()))
+      .addColumn(new Enum("g", new Text("g1")))
       .addColumn(new FixedPoint("h"))
       .addColumn(new FloatingPoint("i"))
-      .addColumn(new Map("j", new Text(), new Text()))
-      .addColumn(new Set("k", new Text()))
+      .addColumn(new Map("j", new Text("j1"), new Text("j2")))
+      .addColumn(new Set("k", new Text("k1")))
       .addColumn(new Text("l"))
       .addColumn(new Time("m"))
       .addColumn(new Unknown("u"))
@@ -171,7 +171,7 @@ public class TestSchemaSerialization {
   @Test
   public void testComplex() {
     Schema complex = new Schema("complex")
-      .addColumn(new Map(new Text(), new Set(new Array(new Text()))).setName("a"));
+      .addColumn(new Map("a", new Text("a1"), new Set("a2", new Array("a3", new Text("a4")))));
     transferAndAssert(complex);
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromInitializer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromInitializer.java
b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromInitializer.java
index ef4ecc4..adf03d9 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromInitializer.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromInitializer.java
@@ -27,8 +27,8 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.sqoop.common.MutableContext;
 import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.connector.jdbc.configuration.LinkConfiguration;
 import org.apache.sqoop.connector.jdbc.configuration.FromJobConfiguration;
+import org.apache.sqoop.connector.jdbc.configuration.LinkConfiguration;
 import org.apache.sqoop.connector.jdbc.util.SqlTypesUtils;
 import org.apache.sqoop.job.Constants;
 import org.apache.sqoop.job.etl.Initializer;
@@ -58,9 +58,7 @@ public class GenericJdbcFromInitializer extends Initializer<LinkConfiguration,
F
   @Override
   public List<String> getJars(InitializerContext context, LinkConfiguration linkConfig,
FromJobConfiguration fromJobConfig) {
     List<String> jars = new LinkedList<String>();
-
     jars.add(ClassUtils.jarForClass(linkConfig.linkConfig.jdbcDriver));
-
     return jars;
   }
 
@@ -86,17 +84,14 @@ public class GenericJdbcFromInitializer extends Initializer<LinkConfiguration,
F
 
       rsmt = rs.getMetaData();
       for (int i = 1 ; i <= rsmt.getColumnCount(); i++) {
-        Column column = SqlTypesUtils.sqlTypeToAbstractType(rsmt.getColumnType(i));
-
         String columnName = rsmt.getColumnName(i);
-        if (columnName == null || columnName.equals("")) {
+        if (StringUtils.isEmpty(columnName)) {
           columnName = rsmt.getColumnLabel(i);
-          if (null == columnName) {
+          if (StringUtils.isEmpty(columnName)) {
             columnName = "Column " + i;
           }
         }
-
-        column.setName(columnName);
+        Column column = SqlTypesUtils.sqlTypeToSchemaType(rsmt.getColumnType(i), columnName);
         schema.addColumn(column);
       }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToInitializer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToInitializer.java
b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToInitializer.java
index 953497f..930cfec 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToInitializer.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToInitializer.java
@@ -82,17 +82,16 @@ public class GenericJdbcToInitializer extends Initializer<LinkConfiguration,
ToJ
 
       rsmt = rs.getMetaData();
       for (int i = 1 ; i <= rsmt.getColumnCount(); i++) {
-        Column column = SqlTypesUtils.sqlTypeToAbstractType(rsmt.getColumnType(i));
-
         String columnName = rsmt.getColumnName(i);
-        if (columnName == null || columnName.equals("")) {
+
+        if (StringUtils.isEmpty(columnName)) {
           columnName = rsmt.getColumnLabel(i);
-          if (null == columnName) {
+          if (StringUtils.isEmpty(columnName)) {
             columnName = "Column " + i;
           }
         }
 
-        column.setName(columnName);
+        Column column = SqlTypesUtils.sqlTypeToSchemaType(rsmt.getColumnType(i), columnName);
         schema.addColumn(column);
       }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ace9710/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/util/SqlTypesUtils.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/util/SqlTypesUtils.java
b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/util/SqlTypesUtils.java
index 572f0ec..9d50dc3 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/util/SqlTypesUtils.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/util/SqlTypesUtils.java
@@ -40,14 +40,16 @@ public class SqlTypesUtils {
    * Convert given java.sql.Types number into internal data type.
    *
    * @param sqlType java.sql.Types constant
+   * @param columnName column name
+   *
    * @return Concrete Column implementation
    */
-  public static Column sqlTypeToAbstractType(int sqlType) {
+  public static Column sqlTypeToSchemaType(int sqlType, String columnName) {
     switch (sqlType) {
       case Types.SMALLINT:
       case Types.TINYINT:
       case Types.INTEGER:
-        return new FixedPoint();
+        return new FixedPoint(columnName);
 
       case Types.CLOB:
       case Types.VARCHAR:
@@ -56,39 +58,39 @@ public class SqlTypesUtils {
       case Types.NVARCHAR:
       case Types.NCHAR:
       case Types.LONGNVARCHAR:
-        return new Text();
+        return new Text(columnName);
 
       case Types.DATE:
-        return new Date();
+        return new Date(columnName);
 
       case Types.TIME:
-        return new Time();
+        return new Time(columnName);
 
       case Types.TIMESTAMP:
-        return new DateTime();
+        return new DateTime(columnName);
 
       case Types.FLOAT:
       case Types.REAL:
       case Types.DOUBLE:
-        return new FloatingPoint();
+        return new FloatingPoint(columnName);
 
       case Types.NUMERIC:
       case Types.DECIMAL:
       case Types.BIGINT:
-        return new Decimal();
+        return new Decimal(columnName);
 
       case Types.BIT:
       case Types.BOOLEAN:
-        return new Bit();
+        return new Bit(columnName);
 
       case Types.BINARY:
       case Types.VARBINARY:
       case Types.BLOB:
       case Types.LONGVARBINARY:
-        return new Binary();
+        return new Binary(columnName);
 
       default:
-        return new Unknown((long)sqlType);
+        return new Unknown(columnName,(long)sqlType);
     }
   }
 


Mime
View raw message