cgivre commented on a change in pull request #2069:
URL: https://github.com/apache/drill/pull/2069#discussion_r430090264
##########
File path:
contrib/format-excel/src/main/java/org/apache/drill/exec/store/excel/ExcelBatchReader.java
##########
@@ -56,60 +61,70 @@
private static final Logger logger =
org.slf4j.LoggerFactory.getLogger(ExcelBatchReader.class);
private static final String SAFE_WILDCARD = "_$";
-
private static final String SAFE_SEPARATOR = "_";
-
private static final String PARSER_WILDCARD = ".*";
-
private static final String HEADER_NEW_LINE_REPLACEMENT = "__";
-
private static final String MISSING_FIELD_NAME_HEADER = "field_";
- private static final int ROW_CACHE_SIZE = 100;
+ private enum IMPLICIT_STRING_COLUMNS {
+ _category,
Review comment:
@vvysotskyi
Are you referring to the field names?
##########
File path:
contrib/format-excel/src/main/java/org/apache/drill/exec/store/excel/ExcelBatchReader.java
##########
@@ -56,60 +61,70 @@
private static final Logger logger =
org.slf4j.LoggerFactory.getLogger(ExcelBatchReader.class);
private static final String SAFE_WILDCARD = "_$";
-
private static final String SAFE_SEPARATOR = "_";
-
private static final String PARSER_WILDCARD = ".*";
-
private static final String HEADER_NEW_LINE_REPLACEMENT = "__";
-
private static final String MISSING_FIELD_NAME_HEADER = "field_";
- private static final int ROW_CACHE_SIZE = 100;
+ private enum IMPLICIT_STRING_COLUMNS {
+ _category,
Review comment:
Will do. Thanks for the review :-)
##########
File path:
contrib/format-excel/src/main/java/org/apache/drill/exec/store/excel/ExcelBatchReader.java
##########
@@ -56,60 +61,70 @@
private static final Logger logger =
org.slf4j.LoggerFactory.getLogger(ExcelBatchReader.class);
private static final String SAFE_WILDCARD = "_$";
-
private static final String SAFE_SEPARATOR = "_";
-
private static final String PARSER_WILDCARD = ".*";
-
private static final String HEADER_NEW_LINE_REPLACEMENT = "__";
-
private static final String MISSING_FIELD_NAME_HEADER = "field_";
- private static final int ROW_CACHE_SIZE = 100;
+ private enum IMPLICIT_STRING_COLUMNS {
+ _category,
Review comment:
Actually, a question about that... Since these are fields that could
appear in a SQL query, shouldn't they use snake case?
##########
File path:
contrib/format-excel/src/main/java/org/apache/drill/exec/store/excel/ExcelBatchReader.java
##########
@@ -56,60 +61,70 @@
private static final Logger logger =
org.slf4j.LoggerFactory.getLogger(ExcelBatchReader.class);
private static final String SAFE_WILDCARD = "_$";
-
private static final String SAFE_SEPARATOR = "_";
-
private static final String PARSER_WILDCARD = ".*";
-
private static final String HEADER_NEW_LINE_REPLACEMENT = "__";
-
private static final String MISSING_FIELD_NAME_HEADER = "field_";
- private static final int ROW_CACHE_SIZE = 100;
+ private enum IMPLICIT_STRING_COLUMNS {
Review comment:
Fixed
##########
File path:
contrib/format-excel/src/main/java/org/apache/drill/exec/store/excel/ExcelBatchReader.java
##########
@@ -56,60 +61,70 @@
private static final Logger logger =
org.slf4j.LoggerFactory.getLogger(ExcelBatchReader.class);
private static final String SAFE_WILDCARD = "_$";
-
private static final String SAFE_SEPARATOR = "_";
-
private static final String PARSER_WILDCARD = ".*";
-
private static final String HEADER_NEW_LINE_REPLACEMENT = "__";
-
private static final String MISSING_FIELD_NAME_HEADER = "field_";
- private static final int ROW_CACHE_SIZE = 100;
+ private enum IMPLICIT_STRING_COLUMNS {
+ _category,
+ _content_status,
+ _content_type,
+ _creator,
+ _description,
+ _identifier,
+ _keywords,
+ _last_modified_by_user,
+ _revision,
+ _subject,
+ _title
+ }
+
+ private enum IMPLICIT_TIMESTAMP_COLUMNS {
Review comment:
Fixed
##########
File path:
contrib/format-excel/src/main/java/org/apache/drill/exec/store/excel/ExcelBatchReader.java
##########
@@ -56,60 +61,70 @@
private static final Logger logger =
org.slf4j.LoggerFactory.getLogger(ExcelBatchReader.class);
private static final String SAFE_WILDCARD = "_$";
-
private static final String SAFE_SEPARATOR = "_";
-
private static final String PARSER_WILDCARD = ".*";
-
private static final String HEADER_NEW_LINE_REPLACEMENT = "__";
-
private static final String MISSING_FIELD_NAME_HEADER = "field_";
- private static final int ROW_CACHE_SIZE = 100;
+ private enum IMPLICIT_STRING_COLUMNS {
+ _category,
Review comment:
@vvysotskyi
The point of those `enum` was to be a list of the field names. Wouldn't
adding fields inside each enum just add additional complexity?
##########
File path:
contrib/format-excel/src/main/java/org/apache/drill/exec/store/excel/ExcelBatchReader.java
##########
@@ -420,15 +510,57 @@ private void addColumnToArray(TupleWriter rowWriter,
String name, TypeProtos.Min
}
}
+ private void addMetadataWriters() {
+ for (String colName : IMPLICIT_STRING_COLUMN_NAMES) {
+ addMetadataColumnsToArray(rowWriter, colName, MinorType.VARCHAR);
+ }
+ for (String colName : IMPLICIT_TIMESTAMP_COLUMN_NAMES) {
+ addMetadataColumnsToArray(rowWriter, colName, MinorType.TIMESTAMP);
+ }
+ }
+
+ private void addMetadataColumnsToArray(TupleWriter rowWriter, String name,
MinorType type) {
+ int index = rowWriter.tupleSchema().index(name);
+ if (index == -1) {
+ ColumnMetadata colSchema = MetadataUtils.newScalar(name, type,
TypeProtos.DataMode.OPTIONAL);
+ colSchema.setBooleanProperty(ColumnMetadata.EXCLUDE_FROM_WILDCARD, true);
+ index = rowWriter.addColumn(colSchema);
+ } else {
+ return;
+ }
+ metadataColumnWriters.add(rowWriter.scalar(index));
+ }
+
+ private void writeMetadata() {
+ for (int i = 0; i < metadataColumnWriters.size(); i++) {
Review comment:
Fixed
----------------------------------------------------------------
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]