Skip to content

Commit

Permalink
Compare types ignoring cases. This is not complete solution and shoul…
Browse files Browse the repository at this point in the history
…d be reverted once prestodb#2863 is resolved.
  • Loading branch information
Sailesh Mittal committed Oct 2, 2015
1 parent eff7e3b commit ec109d1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public FunctionInfo resolveFunction(QualifiedName name, List<TypeSignature> para
RowType rowType = RowParametricType.ROW.createType(resolveTypes(typeSignature.getParameters(), typeManager), typeSignature.getLiteralParameters());
// search for exact match
for (ParametricFunction function : RowParametricType.ROW.createFunctions(rowType)) {
if (!function.getSignature().getName().equals(name.toString())) {
if (!function.getSignature().getName().equalsIgnoreCase(name.toString())) {
continue;
}
Map<String, Type> boundTypeParameters = function.getSignature().bindTypeParameters(resolvedTypes, false, typeManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import java.lang.invoke.MethodHandle;
import java.util.Map;
import java.util.Optional;

import static com.facebook.presto.sql.QueryUtil.mangleFieldReference;
import static com.facebook.presto.type.RowType.RowField;
Expand Down Expand Up @@ -59,7 +58,7 @@ public RowFieldReference(RowType type, String fieldName)
Type returnType = null;
int index = 0;
for (RowField field : type.getFields()) {
if (field.getName().equals(Optional.of(fieldName))) {
if (field.getName().get().equalsIgnoreCase(fieldName)) {
returnType = field.getType();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private Type tryVisitRowFieldAccessor(QualifiedNameReference node)
RowType rowType = checkType(field.getType(), RowType.class, "field.getType()");
Type rowFieldType = null;
for (RowField rowField : rowType.getFields()) {
if (rowField.getName().equals(Optional.of(node.getName().getSuffix()))) {
if (rowField.getName().get().equalsIgnoreCase(node.getName().getSuffix())) {
rowFieldType = rowField.getType();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public List<ParametricFunction> createFunctions(Type type)
ImmutableList.Builder<ParametricFunction> builder = ImmutableList.builder();
for (RowField field : rowType.getFields()) {
field.getName()
.ifPresent(name -> builder.add(new RowFieldReference(rowType, field.getName().get())));
.ifPresent(name -> builder.add(new RowFieldReference(rowType, field.getName().get().toLowerCase())));
}
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private static Object parseLiteral(String literal)
{
if (literal.startsWith("'") || literal.endsWith("'")) {
checkArgument(literal.startsWith("'") && literal.endsWith("'"), "Bad literal: '%s'", literal);
return literal.substring(1, literal.length() - 1);
return literal.substring(1, literal.length() - 1).toLowerCase();
}
else {
return Long.parseLong(literal);
Expand Down

1 comment on commit ec109d1

@syed72
Copy link

@syed72 syed72 commented on ec109d1 Nov 3, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried above code changes and applied, still it throws the below exception:

java.lang.IllegalArgumentException: tableName is not lowercase
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
at com.facebook.presto.metadata.MetadataUtil.checkLowerCase(MetadataUtil.java:101)
at com.facebook.presto.metadata.MetadataUtil.checkTableName(MetadataUtil.java:85)
at com.facebook.presto.metadata.QualifiedTableName.(QualifiedTableName.java:51)
at com.facebook.presto.metadata.MetadataUtil.createQualifiedTableName(MetadataUtil.java:128)
at com.facebook.presto.sql.analyzer.StatementAnalyzer.visitShowColumns(StatementAnalyzer.java:232)
at com.facebook.presto.sql.analyzer.StatementAnalyzer.visitShowColumns(StatementAnalyzer.java:126)
at com.facebook.presto.sql.tree.ShowColumns.accept(ShowColumns.java:39)
at com.facebook.presto.sql.tree.AstVisitor.process(AstVisitor.java:22)
at com.facebook.presto.sql.analyzer.Analyzer.analyze(Analyzer.java:60)
at com.facebook.presto.execution.SqlQueryExecution.doAnalyzeQuery(SqlQueryExecution.java:259)
at com.facebook.presto.execution.SqlQueryExecution.analyzeQuery(SqlQueryExecution.java:245)
at com.facebook.presto.execution.SqlQueryExecution.start(SqlQueryExecution.java:209)
at com.facebook.presto.execution.QueuedExecution.lambda$start$152(QueuedExecution.java:68)
at com.facebook.presto.execution.QueuedExecution$$Lambda$240/987644155.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Please sign in to comment.