-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gapfill: Add support for lowercase datatypes #11722
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ | |
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import org.apache.pinot.common.request.context.ExpressionContext; | ||
import org.apache.pinot.common.request.context.FunctionContext; | ||
import org.apache.pinot.common.response.broker.BrokerResponseNative; | ||
|
@@ -134,6 +136,9 @@ protected void replaceColumnNameWithAlias(DataSchema dataSchema) { | |
for (int i = 0; i < dataSchema.getColumnNames().length; i++) { | ||
if (columnNameToAliasMap.containsKey(dataSchema.getColumnNames()[i])) { | ||
dataSchema.getColumnNames()[i] = columnNameToAliasMap.get(dataSchema.getColumnNames()[i]); | ||
} else if (columnNameToAliasMap.containsKey(caseInsensitiveTypeString(dataSchema.getColumnNames()[i]))) { | ||
dataSchema.getColumnNames()[i] = | ||
columnNameToAliasMap.get(caseInsensitiveTypeString(dataSchema.getColumnNames()[i])); | ||
} | ||
} | ||
} | ||
|
@@ -226,4 +231,16 @@ protected List<Object[]> gapFillAndAggregate(List<Object[]> rows, DataSchema dat | |
DataSchema resultTableSchema) { | ||
throw new UnsupportedOperationException("Not supported"); | ||
} | ||
|
||
protected String caseInsensitiveTypeString(String columnName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I haven't check the details of the logic, so I may be wrong): |
||
String dataTypePattern = "(BOOLEAN|INT|LONG|FLOAT|DOUBLE|STRING)"; | ||
Matcher matcher = Pattern.compile(dataTypePattern, Pattern.CASE_INSENSITIVE).matcher(columnName); | ||
StringBuffer result = new StringBuffer(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to make the code thread-safe? If not, |
||
while (matcher.find()) { | ||
String dataType = matcher.group().toLowerCase(); | ||
matcher.appendReplacement(result, dataType); | ||
} | ||
matcher.appendTail(result); | ||
return result.toString(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
caseInsensitiveTypeString
code and may be a bit slower), what do you think?lowerCaseColumnName = caseInsensitiveTypeString(columnName)
to avoid execute the same code twice.