SociopathicPixel commented on a change in pull request #230: dev/add datatypes
to excel columns
URL: https://github.com/apache/metamodel/pull/230#discussion_r334790056
##########
File path:
excel/src/main/java/org/apache/metamodel/excel/DefaultSpreadsheetReaderDelegate.java
##########
@@ -148,8 +151,16 @@ private MutableTable createTable(final Workbook wb, final
Sheet sheet) {
for (int j = offset; j < row.getLastCellNum(); j++) {
final ColumnNamingContext namingContext = new
ColumnNamingContextImpl(table, null, j);
- final Column column = new
MutableColumn(columnNamingSession.getNextColumnName(namingContext),
- ColumnType.STRING, table, j, true);
+ final Column column;
+ if (_configuration.isDetectColumnTypes()) {
+ column =
+ new
MutableColumn(columnNamingSession.getNextColumnName(namingContext),
columnTypes[j],
+ table, j, true);
+ } else {
+ column =
+ new
MutableColumn(columnNamingSession.getNextColumnName(namingContext),
+ ColumnType.STRING, table, j, true);
+ }
table.addColumn(column);
}
}
Review comment:
> I would do this check inside the `getColumnTypes` method, because you only
want to execute the logic which scans a number of rows in the Excel sheet for
data types when this is activated, otherwise you'll only lose performance for
something which you don't use. In case `isDetectColumnTypes` returns false,
just have the `getColumnTypes` method return an array filled with
`ColumnType.STRING` objects.
you mean this whole part? (lines 146 - 166)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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