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

Remove deprecated unnest behavior #430

Merged
merged 1 commit into from
Mar 11, 2019
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 @@ -113,7 +113,6 @@ public final class SystemSessionProperties
public static final String PREFER_PARTIAL_AGGREGATION = "prefer_partial_aggregation";
public static final String OPTIMIZE_TOP_N_ROW_NUMBER = "optimize_top_n_row_number";
public static final String MAX_GROUPING_SETS = "max_grouping_sets";
public static final String LEGACY_UNNEST = "legacy_unnest";
public static final String STATISTICS_CPU_TIMER_ENABLED = "statistics_cpu_timer_enabled";
public static final String ENABLE_STATS_CALCULATOR = "enable_stats_calculator";
public static final String IGNORE_STATS_CALCULATOR_FAILURES = "ignore_stats_calculator_failures";
Expand Down Expand Up @@ -528,11 +527,6 @@ public SystemSessionProperties(
"Maximum number of grouping sets in a GROUP BY",
featuresConfig.getMaxGroupingSets(),
true),
booleanProperty(
LEGACY_UNNEST,
"Using legacy unnest semantic, where unnest(array(row)) will create one column of type row",
featuresConfig.isLegacyUnnestArrayRows(),
false),
booleanProperty(
STATISTICS_CPU_TIMER_ENABLED,
"Experimental: Enable cpu time tracking for automatic column statistics collection on write",
Expand Down Expand Up @@ -892,11 +886,6 @@ public static int getMaxGroupingSets(Session session)
return session.getSystemProperty(MAX_GROUPING_SETS, Integer.class);
}

public static boolean isLegacyUnnest(Session session)
{
return session.getSystemProperty(LEGACY_UNNEST, Boolean.class);
}

public static OptionalInt getMaxDriversPerTask(Session session)
{
Integer value = session.getSystemProperty(MAX_DRIVERS_PER_TASK, Integer.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package io.prestosql.operator;

import com.google.common.collect.ImmutableList;
import io.prestosql.SystemSessionProperties;
import io.prestosql.spi.Page;
import io.prestosql.spi.PageBuilder;
import io.prestosql.spi.block.Block;
Expand Down Expand Up @@ -65,7 +64,7 @@ public Operator createOperator(DriverContext driverContext)
{
checkState(!closed, "Factory is already closed");
OperatorContext operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, UnnestOperator.class.getSimpleName());
return new UnnestOperator(operatorContext, replicateChannels, replicateTypes, unnestChannels, unnestTypes, withOrdinality, SystemSessionProperties.isLegacyUnnest(driverContext.getSession()));
return new UnnestOperator(operatorContext, replicateChannels, replicateTypes, unnestChannels, unnestTypes, withOrdinality);
}

@Override
Expand Down Expand Up @@ -94,7 +93,7 @@ public OperatorFactory duplicate()
private int currentPosition;
private int ordinalityCount;

public UnnestOperator(OperatorContext operatorContext, List<Integer> replicateChannels, List<Type> replicateTypes, List<Integer> unnestChannels, List<Type> unnestTypes, boolean withOrdinality, boolean isLegacyUnnest)
public UnnestOperator(OperatorContext operatorContext, List<Integer> replicateChannels, List<Type> replicateTypes, List<Integer> unnestChannels, List<Type> unnestTypes, boolean withOrdinality)
{
this.operatorContext = requireNonNull(operatorContext, "operatorContext is null");
this.replicateChannels = ImmutableList.copyOf(requireNonNull(replicateChannels, "replicateChannels is null"));
Expand All @@ -106,7 +105,7 @@ public UnnestOperator(OperatorContext operatorContext, List<Integer> replicateCh
checkArgument(unnestChannels.size() == unnestTypes.size(), "unnest channels or types has wrong size");
ImmutableList.Builder<Type> outputTypesBuilder = ImmutableList.<Type>builder()
.addAll(replicateTypes)
.addAll(getUnnestedTypes(unnestTypes, isLegacyUnnest));
.addAll(getUnnestedTypes(unnestTypes));
if (withOrdinality) {
outputTypesBuilder.add(BIGINT);
}
Expand All @@ -115,7 +114,7 @@ public UnnestOperator(OperatorContext operatorContext, List<Integer> replicateCh
for (Type type : unnestTypes) {
if (type instanceof ArrayType) {
Type elementType = ((ArrayType) type).getElementType();
if (!isLegacyUnnest && elementType instanceof RowType) {
if (elementType instanceof RowType) {
unnesters.add(new ArrayOfRowsUnnester(elementType));
}
else {
Expand All @@ -132,12 +131,12 @@ else if (type instanceof MapType) {
}
}

private static List<Type> getUnnestedTypes(List<Type> types, boolean isLegacyUnnest)
private static List<Type> getUnnestedTypes(List<Type> types)
{
ImmutableList.Builder<Type> builder = ImmutableList.builder();
for (Type type : types) {
checkArgument(type instanceof ArrayType || type instanceof MapType, "Can only unnest map and array types");
if (type instanceof ArrayType && !isLegacyUnnest && ((ArrayType) type).getElementType() instanceof RowType) {
if (type instanceof ArrayType && ((ArrayType) type).getElementType() instanceof RowType) {
builder.addAll(((ArrayType) type).getElementType().getTypeParameters());
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import static java.util.concurrent.TimeUnit.MINUTES;

@DefunctConfig({
"deprecated.legacy-unnest-array-rows",
"resource-group-manager",
"experimental.resource-groups-enabled",
"experimental-syntax-enabled",
Expand Down Expand Up @@ -124,7 +125,6 @@ public class FeaturesConfig
private DataSize filterAndProjectMinOutputPageSize = new DataSize(500, KILOBYTE);
private int filterAndProjectMinOutputPageRowCount = 256;
private int maxGroupingSets = 2048;
private boolean legacyUnnestArrayRows;

public enum JoinReorderingStrategy
{
Expand Down Expand Up @@ -914,16 +914,4 @@ public FeaturesConfig setMaxGroupingSets(int maxGroupingSets)
this.maxGroupingSets = maxGroupingSets;
return this;
}

public boolean isLegacyUnnestArrayRows()
{
return legacyUnnestArrayRows;
}

@Config("deprecated.legacy-unnest-array-rows")
Copy link
Member

Choose a reason for hiding this comment

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

maybe add to defunct configs?

public FeaturesConfig setLegacyUnnestArrayRows(boolean legacyUnnestArrayRows)
{
this.legacyUnnestArrayRows = legacyUnnestArrayRows;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import io.prestosql.Session;
import io.prestosql.SystemSessionProperties;
import io.prestosql.connector.ConnectorId;
import io.prestosql.execution.warnings.WarningCollector;
import io.prestosql.metadata.FunctionKind;
Expand Down Expand Up @@ -751,7 +750,7 @@ protected Scope visitUnnest(Unnest node, Optional<Scope> scope)
Type expressionType = expressionAnalysis.getType(expression);
if (expressionType instanceof ArrayType) {
Type elementType = ((ArrayType) expressionType).getElementType();
if (!SystemSessionProperties.isLegacyUnnest(session) && elementType instanceof RowType) {
if (elementType instanceof RowType) {
((RowType) elementType).getFields().stream()
.map(field -> Field.newUnqualified(field.getName(), field.getType()))
.forEach(outputFields::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.common.collect.ListMultimap;
import com.google.common.collect.UnmodifiableIterator;
import io.prestosql.Session;
import io.prestosql.SystemSessionProperties;
import io.prestosql.metadata.Metadata;
import io.prestosql.metadata.TableHandle;
import io.prestosql.spi.connector.ColumnHandle;
Expand Down Expand Up @@ -576,7 +575,7 @@ private RelationPlan planCrossJoinUnnest(RelationPlan leftPlan, Join joinNode, U
Symbol inputSymbol = translations.get(expression);
if (type instanceof ArrayType) {
Type elementType = ((ArrayType) type).getElementType();
if (!SystemSessionProperties.isLegacyUnnest(session) && elementType instanceof RowType) {
if (elementType instanceof RowType) {
ImmutableList.Builder<Symbol> unnestSymbolBuilder = ImmutableList.builder();
for (int i = 0; i < ((RowType) elementType).getFields().size(); i++) {
unnestSymbolBuilder.add(unnestedSymbolsIterator.next());
Expand Down Expand Up @@ -677,7 +676,7 @@ protected RelationPlan visitUnnest(Unnest node, Void context)
argumentSymbols.add(inputSymbol);
if (type instanceof ArrayType) {
Type elementType = ((ArrayType) type).getElementType();
if (!SystemSessionProperties.isLegacyUnnest(session) && elementType instanceof RowType) {
if (elementType instanceof RowType) {
ImmutableList.Builder<Symbol> unnestSymbolBuilder = ImmutableList.builder();
for (int i = 0; i < ((RowType) elementType).getFields().size(); i++) {
unnestSymbolBuilder.add(unnestedSymbolsIterator.next());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ public void testDefaults()
.setArrayAggGroupImplementation(ArrayAggGroupImplementation.NEW)
.setMultimapAggGroupImplementation(MultimapAggGroupImplementation.NEW)
.setDistributedSortEnabled(true)
.setMaxGroupingSets(2048)
.setLegacyUnnestArrayRows(false));
.setMaxGroupingSets(2048));
}

@Test
Expand Down Expand Up @@ -176,7 +175,6 @@ public void testExplicitPropertyMappings()
.put("optimizer.optimize-top-n-row-number", "false")
.put("distributed-sort", "false")
.put("analyzer.max-grouping-sets", "2047")
.put("deprecated.legacy-unnest-array-rows", "true")
.build();

FeaturesConfig expected = new FeaturesConfig()
Expand Down Expand Up @@ -240,7 +238,6 @@ public void testExplicitPropertyMappings()
.setMultimapAggGroupImplementation(MultimapAggGroupImplementation.LEGACY)
.setDistributedSortEnabled(false)
.setMaxGroupingSets(2047)
.setLegacyUnnestArrayRows(true)
.setDefaultFilterFactorEnabled(true);
assertFullMapping(properties, expected);
}
Expand Down

This file was deleted.