Skip to content
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

Small code cleanup #14742

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 @@ -14,6 +14,7 @@
package io.trino.sql.planner.assertions;

import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.trino.Session;
import io.trino.cost.StatsProvider;
import io.trino.metadata.Metadata;
Expand Down Expand Up @@ -196,73 +197,85 @@ public static class Builder
this.source = requireNonNull(source, "source is null");
}

@CanIgnoreReturnValue
public Builder specification(ExpectedValueProvider<WindowNode.Specification> specification)
{
this.specification = Optional.of(specification);
return this;
}

@CanIgnoreReturnValue
public Builder addFunction(String outputAlias, ExpectedValueProvider<FunctionCall> functionCall)
{
windowFunctionMatchers.add(new AliasMatcher(Optional.of(outputAlias), new WindowFunctionMatcher(functionCall, Optional.empty(), Optional.empty())));
return this;
}

@CanIgnoreReturnValue
public Builder addMeasure(String outputAlias, String expression, Type type)
{
measures.put(outputAlias, new AbstractMap.SimpleEntry<>(expression, type));
return this;
}

@CanIgnoreReturnValue
public Builder frame(ExpectedValueProvider<WindowNode.Frame> frame)
{
this.frame = Optional.of(frame);
return this;
}

@CanIgnoreReturnValue
public Builder rowsPerMatch(RowsPerMatch rowsPerMatch)
{
this.rowsPerMatch = rowsPerMatch;
return this;
}

@CanIgnoreReturnValue
public Builder skipTo(SkipTo.Position position, IrLabel label)
{
this.skipToLabel = Optional.of(label);
this.skipToPosition = position;
return this;
}

@CanIgnoreReturnValue
public Builder skipTo(SkipTo.Position position)
{
this.skipToPosition = position;
return this;
}

@CanIgnoreReturnValue
public Builder seek()
{
this.initial = false;
return this;
}

@CanIgnoreReturnValue
public Builder pattern(IrRowPattern pattern)
{
this.pattern = pattern;
return this;
}

@CanIgnoreReturnValue
public Builder addSubset(IrLabel name, Set<IrLabel> elements)
{
subsets.put(name, elements);
return this;
}

@CanIgnoreReturnValue
public Builder addVariableDefinition(IrLabel name, String expression)
{
this.variableDefinitionsBySql.put(name, expression);
return this;
}

@CanIgnoreReturnValue
public Builder addVariableDefinition(IrLabel name, Expression expression)
{
this.variableDefinitionsByExpression.put(name, expression);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
import static java.lang.String.format;
import static java.lang.System.currentTimeMillis;
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;
import static java.util.UUID.randomUUID;
import static java.util.concurrent.TimeUnit.DAYS;
import static org.apache.hadoop.hive.common.FileUtils.makePartName;
Expand Down Expand Up @@ -1450,14 +1451,9 @@ private static PartitionValues make(String... values)
return new PartitionValues(Arrays.asList(values));
}

private static PartitionValues make(List<String> values)
{
return new PartitionValues(values);
}

private PartitionValues(List<String> values)
{
this.values = values;
this.values = ImmutableList.copyOf(requireNonNull(values, "values is null"));
}

public List<String> getValues()
Expand Down