You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2022/01/16 00:37:45 UTC

[GitHub] [drill] pjfanning commented on a change in pull request #2428: DRILL-8108: Excel Reader Fails with Duplicate Columns

pjfanning commented on a change in pull request #2428:
URL: https://github.com/apache/drill/pull/2428#discussion_r785376059



##########
File path: contrib/format-excel/src/main/java/org/apache/drill/exec/store/excel/ExcelBatchReader.java
##########
@@ -364,6 +368,27 @@ private void getColumnHeaders(SchemaBuilder builder) {
     builder.buildSchema();
   }
 
+  /**
+   * This function verifies whether a given column name is already present in the projected schema.
+   * If so, it appends _n to the column name.  N will be incremented for every duplicate column
+   * @param columnName The original column
+   * @return The deconflicted column name
+   */
+  private String deconflictColumnNames(String columnName) {
+    Pattern pattern = Pattern.compile("_(\\d+)$");
+    Matcher matcher = pattern.matcher(columnName);
+    while (excelFieldNames.contains(columnName)) {

Review comment:
       Does case matter because `contains` is case sensitive - so if col1 is called 'Column' and col2 is called 'column' then this code won't rename col2.




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org