Skip to content

Commit fb32a04

Browse files
committed
feat: Add native_pushdown_integer_upcasts_to_source session properties
This commit adds a new native session property native_pushdown_integer_ upcasts_to_scan, which when set to true, would rewrite the local plan and push down integer upcasts to the source operaters.
1 parent 46b667a commit fb32a04

File tree

12 files changed

+40
-7
lines changed

12 files changed

+40
-7
lines changed

.gitmodules

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[submodule "presto-native-execution/velox"]
22
path = presto-native-execution/velox
3-
url = https://github.com/facebookincubator/velox.git
3+
url = https://github.com/yingsu00/velox.git
4+
branch = pushdownCastToSourceLocal

presto-main-base/src/main/java/com/facebook/presto/sessionpropertyproviders/NativeWorkerSessionPropertyProvider.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public class NativeWorkerSessionPropertyProvider
8888
public static final String NATIVE_INDEX_LOOKUP_JOIN_SPLIT_OUTPUT = "native_index_lookup_join_split_output";
8989
public static final String NATIVE_UNNEST_SPLIT_OUTPUT = "native_unnest_split_output";
9090
public static final String NATIVE_USE_VELOX_GEOSPATIAL_JOIN = "native_use_velox_geospatial_join";
91+
public static final String NATIVE_PUSHDOWN_INTEGER_UPCASTS_TO_SOURCE = "native_pushdown_integer_upcasts_to_source";
9192

9293
private final List<PropertyMetadata<?>> sessionProperties;
9394

@@ -427,11 +428,19 @@ public NativeWorkerSessionPropertyProvider(FeaturesConfig featuresConfig)
427428
true,
428429
!nativeExecution),
429430
booleanProperty(
431+
430432
NATIVE_USE_VELOX_GEOSPATIAL_JOIN,
431433
"If this is true, then the protocol::SpatialJoinNode is converted to a " +
432434
"velox::core::SpatialJoinNode. Otherwise, it is converted to a " +
433435
"velox::core::NestedLoopJoinNode.",
434436
true,
437+
!nativeExecution),
438+
439+
booleanProperty(
440+
NATIVE_PUSHDOWN_INTEGER_UPCASTS_TO_SOURCE,
441+
"Native Execution only. Pushdown integer type upcasts to scan if they are " +
442+
"immediately after scan",
443+
false,
435444
!nativeExecution));
436445
}
437446

presto-main-base/src/main/java/com/facebook/presto/sql/Optimizer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
package com.facebook.presto.sql;
1515

16+
import com.facebook.airlift.log.Logger;
1617
import com.facebook.presto.Session;
1718
import com.facebook.presto.SystemSessionProperties;
1819
import com.facebook.presto.cost.CachingCostProvider;
@@ -104,9 +105,13 @@ public Plan validateAndOptimizePlan(PlanNode root, PlanStage stage)
104105
{
105106
validateIntermediatePlanWithRuntimeStats(root);
106107

108+
Logger log = Logger.get(Optimizer.class);
109+
107110
boolean enableVerboseRuntimeStats = SystemSessionProperties.isVerboseRuntimeStatsEnabled(session);
108111
if (stage.ordinal() >= OPTIMIZED.ordinal()) {
112+
int i = 0;
109113
for (PlanOptimizer optimizer : planOptimizers) {
114+
log.info("optimizer %s, name ", i++, optimizer.toString());
110115
if (Thread.currentThread().isInterrupted()) {
111116
throw new PrestoException(QUERY_PLANNING_TIMEOUT, String.format("The query optimizer exceeded the timeout of %s.", getQueryAnalyzerTimeout(session).toString()));
112117
}

presto-native-execution/presto_cpp/main/SessionProperties.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,14 @@ SessionProperties::SessionProperties() {
586586
false,
587587
std::nullopt,
588588
"true");
589+
590+
addSessionProperty(
591+
kPushdownIntegerUpcastsToSource,
592+
"Enable pushdown of integer upcasts to the source operators.",
593+
BOOLEAN(),
594+
false,
595+
QueryConfig::kPushdownIntegerUpcastsToSource,
596+
boolToString(c.pushdownIntegerUpcastsToSource()));
589597
}
590598

591599
const std::string SessionProperties::toVeloxConfig(

presto-native-execution/presto_cpp/main/SessionProperties.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ class SessionProperties {
378378
static constexpr const char* kUseVeloxGeospatialJoin =
379379
"native_use_velox_geospatial_join";
380380

381+
static constexpr const char* kPushdownIntegerUpcastsToSource =
382+
"native_pushdown_integer_upcasts_to_source";
383+
381384
inline bool hasVeloxConfig(const std::string& key) {
382385
auto sessionProperty = sessionProperties_.find(key);
383386
if (sessionProperty == sessionProperties_.end()) {

presto-native-execution/presto_cpp/main/connectors/SystemConnector.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ class SystemConnector : public velox::connector::Connector {
151151
const velox::RowTypePtr& outputType,
152152
const velox::connector::ConnectorTableHandlePtr& tableHandle,
153153
const velox::connector::ColumnHandleMap& columnHandles,
154-
velox::connector::ConnectorQueryCtx* connectorQueryCtx) override final {
154+
velox::connector::ConnectorQueryCtx* connectorQueryCtx,
155+
bool pushdownCasts = false) override final {
155156
VELOX_CHECK(taskManager_);
156157
return std::make_unique<SystemDataSource>(
157158
outputType,

presto-native-execution/presto_cpp/main/connectors/arrow_flight/ArrowFlightConnector.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ ArrowFlightConnector::createDataSource(
220220
const velox::RowTypePtr& outputType,
221221
const velox::connector::ConnectorTableHandlePtr& tableHandle,
222222
const velox::connector::ColumnHandleMap& columnHandles,
223-
velox::connector::ConnectorQueryCtx* connectorQueryCtx) {
223+
velox::connector::ConnectorQueryCtx* connectorQueryCtx,
224+
bool pushdownCasts) {
224225
return std::make_unique<ArrowFlightDataSource>(
225226
outputType,
226227
columnHandles,

presto-native-execution/presto_cpp/main/connectors/arrow_flight/ArrowFlightConnector.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ class ArrowFlightConnector : public velox::connector::Connector {
139139
const velox::RowTypePtr& outputType,
140140
const velox::connector::ConnectorTableHandlePtr& tableHandle,
141141
const velox::connector::ColumnHandleMap& columnHandles,
142-
velox::connector::ConnectorQueryCtx* connectorQueryCtx) override;
142+
velox::connector::ConnectorQueryCtx* connectorQueryCtx,
143+
bool pushdownCasts = false) override;
143144

144145
std::unique_ptr<velox::connector::DataSink> createDataSink(
145146
velox::RowTypePtr inputType,

presto-native-execution/presto_cpp/main/operators/PartitionAndSerialize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class PartitionAndSerializeOperator : public Operator {
155155
serializeKeys(
156156
nextOutputRow_, endOutputRow, keyOutputBufferSize, *keyVector);
157157

158-
// Extract slice from output_ and construct the output vector.
158+
// Extract slice from outputWithoutUpcasts_ and construct the output vector.
159159
std::vector<VectorPtr> childrenVectors;
160160
childrenVectors.push_back(
161161
output_->childAt(0)->slice(nextOutputRow_, batchSize));

presto-native-execution/presto_cpp/main/tests/QueryContextManagerTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ TEST_F(QueryContextManagerTest, nativeSessionProperties) {
6666
{"native_expression_max_array_size_in_reduce", "99999"},
6767
{"native_expression_max_compiled_regexes", "54321"},
6868
{"request_data_sizes_max_wait_sec", "20"},
69+
{"native_pushdown_integer_upcasts_to_source", "true"},
6970
}};
7071
protocol::TaskUpdateRequest updateRequest;
7172
updateRequest.session = session;
@@ -89,6 +90,7 @@ TEST_F(QueryContextManagerTest, nativeSessionProperties) {
8990
EXPECT_EQ(queryCtx->queryConfig().exprMaxArraySizeInReduce(), 99999);
9091
EXPECT_EQ(queryCtx->queryConfig().exprMaxCompiledRegexes(), 54321);
9192
EXPECT_EQ(queryCtx->queryConfig().requestDataSizesMaxWaitSec(), 20);
93+
EXPECT_TRUE(queryCtx->queryConfig().pushdownIntegerUpcastsToSource());
9294
}
9395

9496
TEST_F(QueryContextManagerTest, nativeConnectorSessionProperties) {

0 commit comments

Comments
 (0)