mirror of
https://github.com/apache/sqoop.git
synced 2025-05-02 11:11:18 +08:00
SQOOP-571. Revert SQOOP-519 and SQOOP-524.
(Cheolsoo Park via Jarek Jarcec Cecho) git-svn-id: https://svn.apache.org/repos/asf/sqoop/trunk@1372828 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
317562642f
commit
7d775935b6
@ -113,14 +113,6 @@ if [ ! -z "$SQOOP_USER_CLASSPATH" ]; then
|
||||
export HADOOP_CLASSPATH="${SQOOP_USER_CLASSPATH}:${HADOOP_CLASSPATH}"
|
||||
fi
|
||||
|
||||
#Sqoop execution faces Class loading issue due to conflicting hsqldb
|
||||
#jar versions in Sqoop(hsqldb-2.2.8) and Hadoop(hsqldb-1.8.0.10).
|
||||
#Setting HADOOP_USER_CLASSPATH_FIRST to true adds Sqoop's classpath
|
||||
#(consequently, hsqldb-2.2.8.jar) before Hadoop's and resolves the issue.
|
||||
#Refer SQOOP-524 JIRA for more details.
|
||||
HADOOP_USER_CLASSPATH_FIRST=true
|
||||
|
||||
export HADOOP_USER_CLASSPATH_FIRST
|
||||
export SQOOP_CLASSPATH
|
||||
export SQOOP_CONF_DIR
|
||||
export SQOOP_JAR_DIR
|
||||
|
3
ivy.xml
3
ivy.xml
@ -124,7 +124,7 @@ under the License.
|
||||
conf="common->master" />
|
||||
<dependency org="junit" name="junit" rev="${junit.version}"
|
||||
conf="test->default"/>
|
||||
<dependency org="org.hsqldb" name="hsqldb" rev="${hsqldb.version}"
|
||||
<dependency org="hsqldb" name="hsqldb" rev="${hsqldb.version}"
|
||||
conf="common->default;redist->default"/>
|
||||
<dependency org="commons-io" name="commons-io" rev="${commons-io.version}"
|
||||
conf="common->default;redist->default"/>
|
||||
@ -167,7 +167,6 @@ under the License.
|
||||
<exclude org="com.cloudera.cdh" module="zookeeper-ant" />
|
||||
</dependency>
|
||||
|
||||
<exclude org="hsqldb" module="hsqldb"/>
|
||||
<exclude org="org.apache.hadoop" module="avro"/>
|
||||
<exclude org="commons-daemon" module="commons-daemon" />
|
||||
|
||||
|
@ -28,7 +28,7 @@ commons-io.version=1.4
|
||||
commons-lang.version=2.4
|
||||
commons-logging.version=1.0.4
|
||||
|
||||
hsqldb.version=2.2.8
|
||||
hsqldb.version=1.8.0.10
|
||||
|
||||
ivy.version=2.1.0
|
||||
|
||||
|
@ -47,7 +47,7 @@ under the License.
|
||||
rev="${hadoop-core.cloudera.version}" conf="common->default"/>
|
||||
<dependency org="junit" name="junit" rev="${junit.version}"
|
||||
conf="common->default"/>
|
||||
<dependency org="org.hsqldb" name="hsqldb" rev="${hsqldb.version}"
|
||||
<dependency org="hsqldb" name="hsqldb" rev="${hsqldb.version}"
|
||||
conf="common->default"/>
|
||||
</dependencies>
|
||||
</ivy-module>
|
||||
|
@ -42,7 +42,7 @@ under the License.
|
||||
<dependencies>
|
||||
<dependency org="org.apache.hadoop" name="hadoop-core"
|
||||
rev="${hadoop.version}" conf="common->default"/>
|
||||
<dependency org="org.hsqldb" name="hsqldb" rev="${hsqldb.version}"
|
||||
<dependency org="hsqldb" name="hsqldb" rev="${hsqldb.version}"
|
||||
conf="common->default"/>
|
||||
<dependency org="commons-io" name="commons-io" rev="${commons-io.version}"
|
||||
conf="common->default"/>
|
||||
|
@ -177,7 +177,7 @@ protected void init() throws IOException {
|
||||
metastoreUser, metastorePassword);
|
||||
}
|
||||
|
||||
connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
|
||||
connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
|
||||
connection.setAutoCommit(false);
|
||||
|
||||
// Initialize the root schema.
|
||||
@ -596,18 +596,11 @@ private void setRootProperty(String propertyName, Integer version,
|
||||
PreparedStatement s;
|
||||
String curVal = getRootProperty(propertyName, version);
|
||||
if (null == curVal) {
|
||||
if (null == version) {
|
||||
// INSERT the row with a null version.
|
||||
s = connection.prepareStatement("INSERT INTO " + getRootTableName()
|
||||
+ " (propval, propname, version) VALUES ( ? , ? , NULL )");
|
||||
} else {
|
||||
// INSERT the row with a non-null version.
|
||||
// INSERT the row.
|
||||
s = connection.prepareStatement("INSERT INTO " + getRootTableName()
|
||||
+ " (propval, propname, version) VALUES ( ? , ? , ? )");
|
||||
}
|
||||
} else {
|
||||
if (null == version) {
|
||||
// UPDATE an existing row with a null version.
|
||||
} else if (version == null) {
|
||||
// UPDATE an existing row with a null version
|
||||
s = connection.prepareStatement("UPDATE " + getRootTableName()
|
||||
+ " SET propval = ? WHERE propname = ? AND version IS NULL");
|
||||
} else {
|
||||
@ -615,7 +608,6 @@ private void setRootProperty(String propertyName, Integer version,
|
||||
s = connection.prepareStatement("UPDATE " + getRootTableName()
|
||||
+ " SET propval = ? WHERE propname = ? AND version = ?");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
s.setString(1, val);
|
||||
|
@ -30,7 +30,7 @@
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
|
||||
import org.hsqldb.Server;
|
||||
import org.hsqldb.server.ServerConstants;
|
||||
import org.hsqldb.ServerConstants;
|
||||
|
||||
import com.cloudera.sqoop.SqoopOptions;
|
||||
|
||||
|
@ -315,7 +315,7 @@ public void testSupportedAvroTypes() throws IOException, SQLException {
|
||||
colGenerator(100, Schema.create(Schema.Type.INT), 100, "INTEGER"),
|
||||
colGenerator(200L, Schema.create(Schema.Type.LONG), 200L, "BIGINT"),
|
||||
// HSQLDB maps REAL to double, not float:
|
||||
colGenerator(1.0d, Schema.create(Schema.Type.DOUBLE), 1.0d, "REAL"),
|
||||
colGenerator(1.0f, Schema.create(Schema.Type.FLOAT), 1.0d, "REAL"),
|
||||
colGenerator(2.0d, Schema.create(Schema.Type.DOUBLE), 2.0d, "DOUBLE"),
|
||||
colGenerator("s", Schema.create(Schema.Type.STRING), "s", "VARCHAR(8)"),
|
||||
colGenerator(ByteBuffer.wrap(b), Schema.create(Schema.Type.BYTES),
|
||||
|
@ -136,7 +136,7 @@ private void avroImportTestHelper(String[] extraArgs, String codec)
|
||||
checkField(fields.get(0), "DATA_COL0", Schema.Type.BOOLEAN);
|
||||
checkField(fields.get(1), "DATA_COL1", Schema.Type.INT);
|
||||
checkField(fields.get(2), "DATA_COL2", Schema.Type.LONG);
|
||||
checkField(fields.get(3), "DATA_COL3", Schema.Type.DOUBLE);
|
||||
checkField(fields.get(3), "DATA_COL3", Schema.Type.FLOAT);
|
||||
checkField(fields.get(4), "DATA_COL4", Schema.Type.DOUBLE);
|
||||
checkField(fields.get(5), "DATA_COL5", Schema.Type.STRING);
|
||||
checkField(fields.get(6), "DATA_COL6", Schema.Type.BYTES);
|
||||
@ -145,7 +145,7 @@ private void avroImportTestHelper(String[] extraArgs, String codec)
|
||||
assertEquals("DATA_COL0", true, record1.get("DATA_COL0"));
|
||||
assertEquals("DATA_COL1", 100, record1.get("DATA_COL1"));
|
||||
assertEquals("DATA_COL2", 200L, record1.get("DATA_COL2"));
|
||||
assertEquals("DATA_COL3", 1.0d, record1.get("DATA_COL3"));
|
||||
assertEquals("DATA_COL3", 1.0f, record1.get("DATA_COL3"));
|
||||
assertEquals("DATA_COL4", 2.0, record1.get("DATA_COL4"));
|
||||
assertEquals("DATA_COL5", new Utf8("s"), record1.get("DATA_COL5"));
|
||||
Object object = record1.get("DATA_COL6");
|
||||
|
@ -751,11 +751,6 @@ public void testDatesAndTimes() throws IOException, SQLException {
|
||||
assertColMinAndMax(forIdx(1), genTime);
|
||||
}
|
||||
|
||||
/** @return the text representation of double */
|
||||
protected String getDoubleTextOut(double v) {
|
||||
return Double.toString(v) + "E0";
|
||||
}
|
||||
|
||||
public void testNumericTypes() throws IOException, SQLException {
|
||||
final int TOTAL_RECORDS = 9;
|
||||
|
||||
@ -763,11 +758,11 @@ public void testNumericTypes() throws IOException, SQLException {
|
||||
ColumnGenerator genFloat = new ColumnGenerator() {
|
||||
public String getExportText(int rowNum) {
|
||||
double v = 3.141 * (double) (rowNum + 1);
|
||||
return Double.toString(v);
|
||||
return "" + v;
|
||||
}
|
||||
public String getVerifyText(int rowNum) {
|
||||
double v = 3.141 * (double) (rowNum + 1);
|
||||
return getDoubleTextOut(v);
|
||||
return "" + v;
|
||||
}
|
||||
public String getType() {
|
||||
return "FLOAT";
|
||||
|
@ -134,7 +134,7 @@ public void testMixed3() {
|
||||
public void testMixed4() {
|
||||
String [] types = { "NUMERIC", "INTEGER", "NUMERIC" };
|
||||
String [] insertVals = { "-42", "17", "33333333333333333333333.1714" };
|
||||
String validateLine = "-42,17,33333333333333333333333";
|
||||
String validateLine = "-42,17,33333333333333333333333.1714";
|
||||
|
||||
verifyTypes(types, insertVals, validateLine);
|
||||
}
|
||||
@ -142,7 +142,7 @@ public void testMixed4() {
|
||||
public void testMixed5() {
|
||||
String [] types = { "NUMERIC", "INTEGER", "NUMERIC" };
|
||||
String [] insertVals = { "null", "17", "33333333333333333333333.0" };
|
||||
String validateLine = "null,17,33333333333333333333333";
|
||||
String validateLine = "null,17,33333333333333333333333.0";
|
||||
|
||||
verifyTypes(types, insertVals, validateLine);
|
||||
}
|
||||
|
@ -373,9 +373,8 @@ public void testFieldWithHiveDelims() throws IOException,
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
try {
|
||||
// verify the output
|
||||
assertEquals("test with new lines " + '\01' + "42" + '\01'
|
||||
+ "oh no field delims ",
|
||||
br.readLine());
|
||||
assertEquals(br.readLine(), "test with new lines " + '\01' + "42"
|
||||
+ '\01' + "oh no field delims ");
|
||||
assertEquals(br.readLine(), null); // should only be one line
|
||||
} catch (IOException ioe) {
|
||||
fail("Unable to read files generated from hive");
|
||||
@ -424,9 +423,8 @@ public void testFieldWithHiveDelimsReplacement() throws IOException,
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
try {
|
||||
// verify the output
|
||||
assertEquals("test with new lines " + '\01' + "42" + '\01'
|
||||
+ "oh no field delims ",
|
||||
br.readLine());
|
||||
assertEquals(br.readLine(), "test with new lines " + '\01' + "42"
|
||||
+ '\01' + "oh no field delims ");
|
||||
assertEquals(br.readLine(), null); // should only be one line
|
||||
} catch (IOException ioe) {
|
||||
fail("Unable to read files generated from hive");
|
||||
|
@ -77,11 +77,6 @@ protected String getDropTableStatement(String tableName) {
|
||||
return "DROP TABLE IF EXISTS " + tableName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDoubleTextOut(double v) {
|
||||
return Double.toString(v);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
super.setUp();
|
||||
|
@ -78,11 +78,6 @@ protected String getDropTableStatement(String tableName) {
|
||||
return "DROP TABLE IF EXISTS " + tableName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDoubleTextOut(double v) {
|
||||
return Double.toString(v);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
super.setUp();
|
||||
|
@ -162,11 +162,6 @@ protected String getDecimalSeqOutput(String numAsInserted) {
|
||||
return getNumericSeqOutput(numAsInserted);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFixedCharSeqOut(int fieldWidth, String asInserted) {
|
||||
return asInserted;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testYear() {
|
||||
verifyType("YEAR", "2012", "2012");
|
||||
|
@ -163,16 +163,6 @@ protected String getVarBinarySeqOutput(String asInserted) {
|
||||
return toLowerHexString(asInserted);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNumericSeqOutput(String numAsInserted) {
|
||||
return numAsInserted;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDecimalSeqOutput(String numAsInserted) {
|
||||
return numAsInserted;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBlobInsertStr(String blobData) {
|
||||
// Oracle wants blob data encoded as hex (e.g. '01fca3b5').
|
||||
|
@ -264,11 +264,6 @@ public void testDatesAndTimes() throws IOException, SQLException {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDoubleTextOut(double v) {
|
||||
return Double.toString(v);
|
||||
}
|
||||
|
||||
/** Make sure mixed update/insert export work correctly. */
|
||||
public void testUpsertTextExport() throws IOException, SQLException {
|
||||
final int TOTAL_RECORDS = 10;
|
||||
|
@ -181,14 +181,10 @@ public void testDateSplits() throws Exception {
|
||||
|
||||
// Create the table.
|
||||
s.executeUpdate("CREATE TABLE " + DATE_TABLE + "(" + COL + " TIMESTAMP)");
|
||||
s.executeUpdate("INSERT INTO " + DATE_TABLE
|
||||
+ " VALUES('2010-04-01 00:00:00')");
|
||||
s.executeUpdate("INSERT INTO " + DATE_TABLE
|
||||
+ " VALUES('2010-04-02 00:00:00')");
|
||||
s.executeUpdate("INSERT INTO " + DATE_TABLE
|
||||
+ " VALUES('2010-05-01 00:00:00')");
|
||||
s.executeUpdate("INSERT INTO " + DATE_TABLE
|
||||
+ " VALUES('2011-04-01 00:00:00')");
|
||||
s.executeUpdate("INSERT INTO " + DATE_TABLE + " VALUES('2010-04-01')");
|
||||
s.executeUpdate("INSERT INTO " + DATE_TABLE + " VALUES('2010-04-02')");
|
||||
s.executeUpdate("INSERT INTO " + DATE_TABLE + " VALUES('2010-05-01')");
|
||||
s.executeUpdate("INSERT INTO " + DATE_TABLE + " VALUES('2011-04-01')");
|
||||
|
||||
// commit this tx.
|
||||
connection.commit();
|
||||
|
@ -390,35 +390,19 @@ protected String getTimestampSeqOutput(String tsAsInserted) {
|
||||
}
|
||||
|
||||
protected String getNumericSeqOutput(String numAsInserted) {
|
||||
int dotPos = numAsInserted.indexOf(".");
|
||||
if (-1 == dotPos) {
|
||||
// No dot in the original string; expand to add zeros after the
|
||||
// dot.
|
||||
return numAsInserted + ".00000";
|
||||
} else {
|
||||
// all other strings return as-is.
|
||||
return numAsInserted;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getDecimalSeqOutput(String numAsInserted) {
|
||||
int dotPos = numAsInserted.indexOf(".");
|
||||
if (-1 == dotPos) {
|
||||
// No dot in the original string; expand to add zeros after the
|
||||
// dot.
|
||||
return numAsInserted + ".00000";
|
||||
} else {
|
||||
// all other strings return as-is.
|
||||
return numAsInserted;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return how a CHAR(fieldWidth) field is represented in an imported
|
||||
* sequence file
|
||||
*/
|
||||
protected String getFixedCharSeqOut(int fieldWidth, String asInserted) {
|
||||
return padString(fieldWidth, asInserted);
|
||||
return asInserted;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user