mirror of
https://github.com/apache/sqoop.git
synced 2025-05-03 20:40:58 +08:00
SQOOP-2911: Fix failing HCatalogExportTest caused by SQOOP-2863
(Abraham Fine via Jarek Jarcec Cecho)
This commit is contained in:
parent
db4a8fc2fe
commit
83f0c1a40b
@ -280,7 +280,7 @@ public void createTable(ColumnGenerator... extraColumns) throws SQLException {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("CREATE TABLE ");
|
sb.append("CREATE TABLE ");
|
||||||
sb.append(getTableName());
|
sb.append(getTableName());
|
||||||
sb.append(" (\"id\" INT NOT NULL PRIMARY KEY, \"msg\" VARCHAR(64)");
|
sb.append(" (\"ID\" INT NOT NULL PRIMARY KEY, \"MSG\" VARCHAR(64)");
|
||||||
int colNum = 0;
|
int colNum = 0;
|
||||||
for (ColumnGenerator gen : extraColumns) {
|
for (ColumnGenerator gen : extraColumns) {
|
||||||
sb.append(", \"" + forIdx(colNum++) + "\" " + gen.getType());
|
sb.append(", \"" + forIdx(colNum++) + "\" " + gen.getType());
|
||||||
@ -326,7 +326,7 @@ public void createStagingTable(ColumnGenerator... extraColumns)
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("CREATE TABLE ");
|
sb.append("CREATE TABLE ");
|
||||||
sb.append(stageTableName);
|
sb.append(stageTableName);
|
||||||
sb.append(" (\"id\" INT NOT NULL PRIMARY KEY, \"msg\" VARCHAR(64)");
|
sb.append(" (\"ID\" INT NOT NULL PRIMARY KEY, \"MSG\" VARCHAR(64)");
|
||||||
int colNum = 0;
|
int colNum = 0;
|
||||||
for (ColumnGenerator gen : extraColumns) {
|
for (ColumnGenerator gen : extraColumns) {
|
||||||
sb.append(", \"" + forIdx(colNum++) + "\" " + gen.getType());
|
sb.append(", \"" + forIdx(colNum++) + "\" " + gen.getType());
|
||||||
@ -363,7 +363,7 @@ private void assertColValForRowId(int id, String colName, String expectedVal)
|
|||||||
LOG.info("Verifying column " + colName + " has value " + expectedVal);
|
LOG.info("Verifying column " + colName + " has value " + expectedVal);
|
||||||
|
|
||||||
PreparedStatement statement = conn.prepareStatement(
|
PreparedStatement statement = conn.prepareStatement(
|
||||||
"SELECT \"" + colName + "\" FROM " + getTableName() + " WHERE \"id\" = " + id,
|
"SELECT \"" + colName + "\" FROM " + getTableName() + " WHERE \"ID\" = " + id,
|
||||||
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
||||||
String actualVal = null;
|
String actualVal = null;
|
||||||
try {
|
try {
|
||||||
@ -796,7 +796,7 @@ public String getType() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testColumnsExport() throws IOException, SQLException {
|
public void testColumnsExport() throws IOException, SQLException {
|
||||||
testColumnsExport("id,msg," + forIdx(0) + "," + forIdx(2));
|
testColumnsExport("ID,MSG," + forIdx(0) + "," + forIdx(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,7 +173,7 @@ protected String getMsgPrefix() {
|
|||||||
/** @return the minimum 'id' value in the table */
|
/** @return the minimum 'id' value in the table */
|
||||||
protected int getMinRowId(Connection conn) throws SQLException {
|
protected int getMinRowId(Connection conn) throws SQLException {
|
||||||
PreparedStatement statement = conn.prepareStatement(
|
PreparedStatement statement = conn.prepareStatement(
|
||||||
"SELECT MIN(\"id\") FROM " + getTableName(),
|
"SELECT MIN(\"ID\") FROM " + getTableName(),
|
||||||
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
||||||
int minVal = 0;
|
int minVal = 0;
|
||||||
try {
|
try {
|
||||||
@ -194,7 +194,7 @@ protected int getMinRowId(Connection conn) throws SQLException {
|
|||||||
/** @return the maximum 'id' value in the table */
|
/** @return the maximum 'id' value in the table */
|
||||||
protected int getMaxRowId(Connection conn) throws SQLException {
|
protected int getMaxRowId(Connection conn) throws SQLException {
|
||||||
PreparedStatement statement = conn.prepareStatement(
|
PreparedStatement statement = conn.prepareStatement(
|
||||||
"SELECT MAX(\"id\") FROM " + getTableName(),
|
"SELECT MAX(\"ID\") FROM " + getTableName(),
|
||||||
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
||||||
int maxVal = 0;
|
int maxVal = 0;
|
||||||
try {
|
try {
|
||||||
@ -266,8 +266,8 @@ protected void verifyExport(int expectedNumRecords, Connection conn)
|
|||||||
assertEquals("Maximum row had invalid id", expectedNumRecords - 1, maxVal);
|
assertEquals("Maximum row had invalid id", expectedNumRecords - 1, maxVal);
|
||||||
|
|
||||||
// Check that the string values associated with these points match up.
|
// Check that the string values associated with these points match up.
|
||||||
statement = conn.prepareStatement("SELECT \"msg\" FROM " + getTableName()
|
statement = conn.prepareStatement("SELECT \"MSG\" FROM " + getTableName()
|
||||||
+ " WHERE \"id\" = " + minVal,
|
+ " WHERE \"ID\" = " + minVal,
|
||||||
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
||||||
String minMsg = "";
|
String minMsg = "";
|
||||||
try {
|
try {
|
||||||
@ -285,8 +285,8 @@ protected void verifyExport(int expectedNumRecords, Connection conn)
|
|||||||
assertEquals("Invalid msg field for min value", getMsgPrefix() + minVal,
|
assertEquals("Invalid msg field for min value", getMsgPrefix() + minVal,
|
||||||
minMsg);
|
minMsg);
|
||||||
|
|
||||||
statement = conn.prepareStatement("SELECT \"msg\" FROM " + getTableName()
|
statement = conn.prepareStatement("SELECT \"MSG\" FROM " + getTableName()
|
||||||
+ " WHERE \"id\" = " + maxVal,
|
+ " WHERE \"ID\" = " + maxVal,
|
||||||
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
||||||
String maxMsg = "";
|
String maxMsg = "";
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user