improve regex for column cleaning
@@ -44,18 +44,14 @@ class QueryResultRowTransform(schema: StructType, destination: String, converter
} else {
// Generate name for non-alphanumeric fields
var name: String = if (field.name != null) field.name.replaceAll(QueryResultRowTransform.REPLACE_PATTERN_STR, "_") else "?"
- name = if (name.substring(0, 1).matches("\\d")) "C_"+name else name;
- do {
+ name = if (name.substring(0, 1).matches("\\d")) "c_"+name else name;
try {
schema(name)
- name = null
} catch {
case _: IllegalArgumentException => // ignored
name = QueryResultRowTransform.DISPLAY_NAME_PREFIX + index
index += 1
}
- } while (name == null)
-
column.setDisplayName(name)
column.setField(name)
}
