Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GOBBLIN-849] Connect to Oracle using service name, update metadata query #2705

Open
wants to merge 1 commit into
base: master
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -596,6 +596,7 @@ public class ConfigurationKeys {
public static final String SOURCE_CONN_PORT = SOURCE_CONN_PREFIX + "port";
public static final int SOURCE_CONN_DEFAULT_PORT = 22;
public static final String SOURCE_CONN_SID = SOURCE_CONN_PREFIX + "sid";
public static final String SOURCE_CONN_SERVICE_NAME = SOURCE_CONN_PREFIX + "service.name";
public static final String SOURCE_CONN_REFRESH_TOKEN = SOURCE_CONN_PREFIX + "refresh.token";
public static final String SOURCE_CONN_DECRYPT_CLIENT_SECRET = SOURCE_CONN_PREFIX + "decrypt.client.id.secret";

Expand Down
3 changes: 2 additions & 1 deletion gobblin-docs/user-guide/Configuration-Properties-Glossary.md
Expand Up @@ -224,7 +224,8 @@ These properties are common properties that are used among different Source impl
| `source.conn.version` | Version number of communication protocol. This parameter is only used for the Salesforce source. | No | None |
| `source.conn.timeout` | The timeout set for connecting to the source in milliseconds. | No | 500000 |
| `source.conn.port` | The value of the port to connect to. | Required for SftpExtractor, MySQLExtractor, OracleExtractor, SQLServerExtractor and TeradataExtractor. | None |
| `source.conn.sid` | The Oracle System ID (SID) that identifies the database to connect to. | Required for OracleExtractor. | None |
| `source.conn.sid` | The Oracle System ID (SID) that identifies the database to connect to. | Yes, if source.conn.service.name not set for OracleExtractor. | None |
| `source.conn.service.name` | The Oracle Service Name that identifies the database to connect to. | Yes, if source.conn.sid not set for OracleExtractor. | None |
| `extract.table.name` | Table name in Hadoop which is different table name in source. | No | Source table name |
| `extract.is.full` | True if this pull should treat the data as a full dump of table from the source, false otherwise. | No | false |
| `extract.delta.fields` | List of columns that will be used as the delta field for the data. | No | None |
Expand Down
Expand Up @@ -78,8 +78,8 @@ public class OracleExtractor extends JdbcExtractor {
"FROM " +
"all_tab_columns " +
"JOIN all_col_comments USING (owner, table_name, column_name) " +
"WHERE UPPER(owner) = (?) " +
"AND UPPER(table_name) = (?) " +
"WHERE UPPER(owner) = UPPER(?) " +
"AND UPPER(table_name) = UPPER(?) " +
"ORDER BY " +
"column_id, column_name";

Expand Down Expand Up @@ -253,8 +253,14 @@ public Iterator<JsonElement> getRecordSetFromSourceApi(String schema, String ent
public String getConnectionUrl() {
String host = this.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_HOST_NAME);
String port = this.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_PORT);
String sid = this.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_SID).trim();
String url = "jdbc:oracle:thin:@" + host.trim() + (StringUtils.isEmpty(port) ? "" : ":" + port) + ":" + sid;
String sid = this.workUnitState.contains(ConfigurationKeys.SOURCE_CONN_SID) ? this.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_SID).trim() : "";
String serviceName = this.workUnitState.contains(ConfigurationKeys.SOURCE_CONN_SERVICE_NAME) ? this.workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_SERVICE_NAME).trim() : "";
String conn;
if(sid != null && sid.length() > 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with if (!Strings.isNullOrEmpty(sid)) ?

conn = ":" + sid;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace "conn" with "serviceString" or something more meaningful?

else
conn = "/" + serviceName;
String url = "jdbc:oracle:thin:@" + host.trim() + (StringUtils.isEmpty(port) ? "" : ":" + port) + conn;
return url;
}

Expand Down