Skip to content

Commit e627cb7

Browse files
fixing up.
1 parent 7058fc3 commit e627cb7

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

amazon-redshift-plugin/docs/Redshift-batchsource.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ contain the '$CONDITIONS' string. For example, 'SELECT * FROM table WHERE $CONDI
3131
The '$CONDITIONS' string will be replaced by 'splitBy' field limits specified by the bounding query.
3232
The '$CONDITIONS' string is not required if numSplits is set to one.
3333

34+
**ImportQueryType** - determines how data is extracted—either by using a Table Name or a custom Import Query.
35+
36+
* **TableName**: Extracts data directly from a specified database table.
37+
3438
**Bounding Query:** Bounding Query should return the min and max of the values of the 'splitBy' field.
3539
For example, 'SELECT MIN(id),MAX(id) FROM table'. Not required if numSplits is set to one.
3640

database-commons/src/main/java/io/cdap/plugin/db/source/AbstractDBSource.java

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import io.cdap.plugin.db.DBRecord;
5050
import io.cdap.plugin.db.SchemaReader;
5151
import io.cdap.plugin.db.TransactionIsolationLevel;
52+
import io.cdap.plugin.db.config.AbstractDBSpecificSourceConfig;
5253
import io.cdap.plugin.db.config.DatabaseSourceConfig;
5354
import io.cdap.plugin.util.DBUtils;
5455
import io.cdap.plugin.util.DriverCleanup;
@@ -164,9 +165,9 @@ public Schema getSchema() throws SQLException {
164165
try (Connection connection = getConnection()) {
165166
executeInitQueries(connection, sourceConfig.getInitQueries());
166167
String query = sourceConfig.getImportQuery();
167-
if ("importQuery".equalsIgnoreCase(sourceConfig.getImportQueryType())) {
168+
if (AbstractDBSpecificSourceConfig.IMPORT_QUERY.equalsIgnoreCase(sourceConfig.getImportQueryType())) {
168169
return loadSchemaFromDBwithQuery(connection, query);
169-
} else if ("tableName".equalsIgnoreCase(sourceConfig.getImportQueryType())) {
170+
} else if (AbstractDBSpecificSourceConfig.TABLE_NAME.equalsIgnoreCase(sourceConfig.getImportQueryType())) {
170171
List<Schema.Field> fields = getSchemaReader().getSchemaFields(connection, sourceConfig.getTableName());
171172
return Schema.recordOf("schema", fields);
172173
} else {
@@ -210,7 +211,7 @@ private Schema loadSchemaFromDB(Class<? extends Driver> driverClass)
210211
executeInitQueries(connection, sourceConfig.getInitQueries());
211212
String importQuery = sourceConfig.getImportQuery();
212213
String tableName = sourceConfig.getTableName();
213-
if ("importQuery".equalsIgnoreCase(sourceConfig.getImportQueryType())) {
214+
if (AbstractDBSpecificSourceConfig.IMPORT_QUERY.equalsIgnoreCase(sourceConfig.getImportQueryType())) {
214215
return loadSchemaFromDBwithQuery(connection, importQuery);
215216
} else {
216217
return loadSchemaFromDBwithTableName(connection, tableName);
@@ -429,25 +430,6 @@ private String getJDBCPluginId() {
429430
return String.format("%s.%s.%s", "source", ConnectionConfig.JDBC_PLUGIN_TYPE, sourceConfig.getJdbcPluginName());
430431
}
431432

432-
private Schema.Type mapSqlTypeToSchemaType(int sqlType) {
433-
switch (sqlType) {
434-
case Types.INTEGER: return Schema.Type.INT;
435-
case Types.BIGINT: return Schema.Type.LONG;
436-
case Types.FLOAT:
437-
case Types.REAL:
438-
case Types.DOUBLE: return Schema.Type.DOUBLE;
439-
case Types.VARCHAR:
440-
case Types.CHAR:
441-
case Types.LONGVARCHAR: return Schema.Type.STRING;
442-
case Types.BOOLEAN:
443-
case Types.BIT: return Schema.Type.BOOLEAN;
444-
case Types.DATE:
445-
case Types.TIMESTAMP:
446-
default: return Schema.Type.STRING;
447-
}
448-
}
449-
450-
451433
protected abstract String createConnectionString();
452434

453435
/**

postgresql-plugin/docs/Postgres-batchsource.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ contain the '$CONDITIONS' string. For example, 'SELECT * FROM table WHERE $CONDI
3838
The '$CONDITIONS' string will be replaced by 'splitBy' field limits specified by the bounding query.
3939
The '$CONDITIONS' string is not required if numSplits is set to one.
4040

41+
**ImportQueryType** - determines how data is extracted—either by using a Table Name or a custom Import Query.
42+
43+
* **TableName**: Extracts data directly from a specified database table.
44+
4145
**Bounding Query:** Bounding Query should return the min and max of the values of the 'splitBy' field.
4246
For example, 'SELECT MIN(id),MAX(id) FROM table'. Not required if numSplits is set to one.
4347

0 commit comments

Comments
 (0)