vdiravka commented on a change in pull request #1642: DRILL-6734: JDBC storage
plugin returns null for fields without aliases
URL: https://github.com/apache/drill/pull/1642#discussion_r259081091
##########
File path:
contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java
##########
@@ -180,22 +182,34 @@ private static String nameFromType(int javaSqlType) {
}
@Override
- public void setup(OperatorContext operatorContext, OutputMutator output)
throws ExecutionSetupException {
+ public void setup(OperatorContext operatorContext, OutputMutator output) {
try {
connection = source.getConnection();
statement = connection.createStatement();
resultSet = statement.executeQuery(sql);
- final ResultSetMetaData meta = resultSet.getMetaData();
- final int columns = meta.getColumnCount();
+ ResultSetMetaData meta = resultSet.getMetaData();
+ int columnsCount = meta.getColumnCount();
+ if (columns.size() != columnsCount) {
+ throw UserException
+ .validationError()
+ .message(
+ "Expected columns count differs from the returned one.\n" +
+ "Expected columns: %s\n" +
+ "Returned columns count: %s",
+ columns, columnsCount)
+ .addContext("sql", sql)
+ .addContext("plugin", storagePluginName)
+ .build(logger);
+ }
ImmutableList.Builder<ValueVector> vectorBuilder =
ImmutableList.builder();
ImmutableList.Builder<Copier<?>> copierBuilder = ImmutableList.builder();
- for (int i = 1; i <= columns; i++) {
- final String name = meta.getColumnLabel(i);
- final int jdbcType = meta.getColumnType(i);
- final int width = meta.getPrecision(i);
- final int scale = meta.getScale(i);
+ for (int i = 1; i <= columnsCount; i++) {
+ String name = columns.get(i - 1);
+ int jdbcType = meta.getColumnType(i);
Review comment:
Please put the comment here that column index in `ResultSetMetaData` starts
from 1
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services