Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import static io.trino.sql.analyzer.TypeSignatureTranslator.toTypeSignature;
import static java.lang.String.format;
import static java.util.Collections.nCopies;
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;
import static java.util.function.Predicate.not;

Expand Down Expand Up @@ -629,6 +630,9 @@ public Context newScope()
private static String identifierValue(Identifier name)
{
// TODO: this should use getCanonicalValue()
return name.getValue();
// stop-gap: lowercasing for now to match what is happening during analysis;
// otherwise we do not support non-lowercase variables in functions.
// Rework as part of https://github.com/trinodb/trino/pull/24829
return name.getValue().toLowerCase(ENGLISH);
Copy link
Member

Choose a reason for hiding this comment

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

Add a link to #17 so we can find the places that need to be fixed when we work on that issue.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import static io.trino.sql.relational.Expressions.call;
import static io.trino.sql.relational.Expressions.constantNull;
import static io.trino.sql.relational.Expressions.field;
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;

public final class SqlRoutinePlanner
Expand Down Expand Up @@ -360,7 +361,10 @@ private static IrBlock block(List<IrStatement> statements)
private static String identifierValue(Identifier name)
{
// TODO: this should use getCanonicalValue()
return name.getValue();
// stop-gap: lowercasing for now to match what is happening during analysis;
// otherwise we do not support non-lowercase variables in functions.
// Rework as part of https://github.com/trinodb/trino/pull/24829
return name.getValue().toLowerCase(ENGLISH);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6652,6 +6652,19 @@ SELECT my_pow(2, 8)
"""))
.matches("VALUES 256");

assertThat(query(
"""
WITH
FUNCTION fun_with_uppercase_var()
RETURNS int
BEGIN
DECLARE R int DEFAULT 7;
RETURN R;
END
SELECT fun_with_uppercase_var()
"""))
.matches("VALUES 7");

// invoke function on data from connector to prevent constant folding on the coordinator
assertThat(query(
"""
Expand Down
Loading