Skip to content

Commit

Permalink
Add config and session property deprecated.legacy-timestamp
Browse files Browse the repository at this point in the history
This is flag for switching between legacy TIME/TIMESTAMP semantic
and new one beeing aligned with ANSI SQL. See: prestodb#7122
  • Loading branch information
fiedukow committed Feb 16, 2017
1 parent 8836116 commit 478d7aa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public final class SystemSessionProperties
public static final String REORDER_WINDOWS = "reorder_windows";
public static final String ITERATIVE_OPTIMIZER = "iterative_optimizer_enabled";
public static final String EXCHANGE_COMPRESSION = "exchange_compression";
public static final String LEGACY_TIMESTAMP = "legacy_timestamp";

private final List<PropertyMetadata<?>> sessionProperties;

Expand Down Expand Up @@ -283,6 +284,11 @@ public SystemSessionProperties(
EXCHANGE_COMPRESSION,
"Enable compression in exchanges",
featuresConfig.isExchangeCompressionEnabled(),
false),
booleanSessionProperty(
LEGACY_TIMESTAMP,
"Use legacy TIMESTAMP, TIME & DATE semantic",
featuresConfig.isLegacyTimestamp(),
false));
}

Expand Down Expand Up @@ -445,6 +451,11 @@ public static boolean isNewOptimizerEnabled(Session session)
return session.getSystemProperty(ITERATIVE_OPTIMIZER, Boolean.class);
}

@Deprecated
public static boolean isLegacyTimestamp(Session session)
{
return session.getSystemProperty(LEGACY_TIMESTAMP, Boolean.class);
}
public static boolean isExchangeCompressionEnabled(Session session)
{
return session.getSystemProperty(EXCHANGE_COMPRESSION, Boolean.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public static class ProcessingOptimization
private boolean exchangeCompressionEnabled = false;
private boolean legacyArrayAgg;
private boolean legacyOrderBy;
private boolean legacyTimestamp = true;
private boolean legacyMapSubscript;
private boolean optimizeMixedDistinctAggregations;

Expand Down Expand Up @@ -125,6 +126,18 @@ public boolean isLegacyOrderBy()
return legacyOrderBy;
}

@Config("deprecated.legacy-timestamp")
public FeaturesConfig setLegacyTimestamp(boolean value)
{
this.legacyTimestamp = value;
return this;
}

public boolean isLegacyTimestamp()
{
return legacyTimestamp;
}

@Config("deprecated.legacy-map-subscript")
public FeaturesConfig setLegacyMapSubscript(boolean value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public void testDefaults()
.setOptimizeMixedDistinctAggregations(false)
.setLegacyOrderBy(false)
.setIterativeOptimizerEnabled(false)
.setExchangeCompressionEnabled(false));
.setExchangeCompressionEnabled(false)
.setLegacyTimestamp(true));
}

@Test
Expand Down Expand Up @@ -93,6 +94,7 @@ public void testExplicitPropertyMappings()
.put("experimental.spiller-spill-path", "/tmp/custom/spill/path")
.put("experimental.spiller-threads", "42")
.put("exchange.compression-enabled", "true")
.put("deprecated.legacy-timestamp", "false")
.build();
Map<String, String> properties = new ImmutableMap.Builder<String, String>()
.put("experimental.resource-groups-enabled", "true")
Expand Down Expand Up @@ -121,6 +123,7 @@ public void testExplicitPropertyMappings()
.put("experimental.spiller-spill-path", "/tmp/custom/spill/path")
.put("experimental.spiller-threads", "42")
.put("exchange.compression-enabled", "true")
.put("deprecated.legacy-timestamp", "false")
.build();

FeaturesConfig expected = new FeaturesConfig()
Expand Down Expand Up @@ -149,7 +152,8 @@ public void testExplicitPropertyMappings()
.setSpillerSpillPath("/tmp/custom/spill/path")
.setSpillerThreads(42)
.setLegacyOrderBy(true)
.setExchangeCompressionEnabled(true);
.setExchangeCompressionEnabled(true)
.setLegacyTimestamp(false);

assertFullMapping(properties, expected);
assertDeprecatedEquivalence(FeaturesConfig.class, properties, propertiesLegacy);
Expand Down

0 comments on commit 478d7aa

Please sign in to comment.