Skip to content
This repository was archived by the owner on Jul 9, 2021. It is now read-only.

[SQOOP-2916] #19

Open
wants to merge 2 commits into
base: branch-1.99.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,23 @@ private void configureTableProperties(MutableContext context, LinkConfiguration
String tableSql = toJobConfig.toJobConfig.sql;
String tableColumns = toJobConfig.toJobConfig.columns;

if (tableName != null && tableSql != null) {
// when both fromTable name and fromTable sql are specified:
throw new SqoopException(
GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0007);
if (tableSql != null) {
// when toTable sql is specified:
if (tableSql.indexOf(
GenericJdbcConnectorConstants.SQL_PARAMETER_MARKER) == -1) {
// make sure parameter marker is in the specified sql
throw new SqoopException(
GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0013);
}

} else if (tableName != null) {
// when fromTable name is specified:
if (tableColumns == null) {
dataSql = tableSql;
} else {
throw new SqoopException(
GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0014);
}
}else if (tableName != null) {
// when toTable name is specified:
if(stageEnabled) {
LOG.info("Stage has been enabled.");
LOG.info("Use stageTable: " + stageTableName +
Expand Down Expand Up @@ -179,23 +189,7 @@ private void configureTableProperties(MutableContext context, LinkConfiguration
builder.append(")");
dataSql = builder.toString();
}
} else if (tableSql != null) {
// when fromTable sql is specified:

if (tableSql.indexOf(
GenericJdbcConnectorConstants.SQL_PARAMETER_MARKER) == -1) {
// make sure parameter marker is in the specified sql
throw new SqoopException(
GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0013);
}

if (tableColumns == null) {
dataSql = tableSql;
} else {
throw new SqoopException(
GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0014);
}
} else {
} else {
// when neither are specified:
throw new SqoopException(
GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0008);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ public class ToJobConfig {

@Input
public Boolean shouldClearStageTable;

public static class ConfigValidator extends AbstractValidator<ToJobConfig> {
@Override
public void validate(ToJobConfig config) {
if (config.tableName == null && config.sql == null) {
addMessage(Status.ERROR, "Either table name or SQL must be specified");
}
if (config.tableName != null && config.sql != null) {
addMessage(Status.ERROR, "Both table name and SQL cannot be specified");
}
if (config.tableName == null && config.stageTableName != null) {
addMessage(Status.ERROR,
"Stage table name cannot be specified without specifying table name");
Expand Down