Skip to content
Merged
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 @@ -24,6 +24,8 @@
import io.trino.sql.tree.Identifier;
import io.trino.sql.tree.SymbolReference;

import javax.annotation.Nullable;

import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -67,7 +69,7 @@ public Symbol newHashSymbol()
return newSymbol("$hashValue", BigintType.BIGINT);
}

public Symbol newSymbol(String nameHint, Type type, String suffix)
public Symbol newSymbol(String nameHint, Type type, @Nullable String suffix)
{
requireNonNull(nameHint, "nameHint is null");
requireNonNull(type, "type is null");
Expand All @@ -92,13 +94,11 @@ public Symbol newSymbol(String nameHint, Type type, String suffix)
unique = unique + "$" + suffix;
}

String attempt = unique;
while (symbols.containsKey(new Symbol(attempt))) {
attempt = unique + "_" + nextId();
Symbol symbol = new Symbol(unique);
while (symbols.putIfAbsent(symbol, type) != null) {
symbol = new Symbol(unique + "_" + nextId());
}

Symbol symbol = new Symbol(attempt);
symbols.put(symbol, type);
return symbol;
}

Expand Down