diff --git a/presto-docs/src/main/sphinx/presto_cpp/features.rst b/presto-docs/src/main/sphinx/presto_cpp/features.rst index 7b814b1adbd2c..a0245fadc985d 100644 --- a/presto-docs/src/main/sphinx/presto_cpp/features.rst +++ b/presto-docs/src/main/sphinx/presto_cpp/features.rst @@ -395,6 +395,14 @@ Native Execution only. Enable row number spilling on native engine. Native Execution only. Enable simplified path in expression evaluation. +``native_expression.max_array_size_in_reduce`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* **Type:** ``integer`` +* **Default value:** ``100000`` + +Native Execution only. The `reduce `_ function will throw an error if it encounters an array of size greater than this value. + ``native_spill_compression_codec`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/presto-main/src/main/java/com/facebook/presto/SystemSessionProperties.java b/presto-main/src/main/java/com/facebook/presto/SystemSessionProperties.java index d039bd5595744..1afdd169ba5e4 100644 --- a/presto-main/src/main/java/com/facebook/presto/SystemSessionProperties.java +++ b/presto-main/src/main/java/com/facebook/presto/SystemSessionProperties.java @@ -335,6 +335,7 @@ public final class SystemSessionProperties // TODO: Native execution related session properties that are temporarily put here. They will be relocated in the future. public static final String NATIVE_SIMPLIFIED_EXPRESSION_EVALUATION_ENABLED = "native_simplified_expression_evaluation_enabled"; + public static final String NATIVE_EXPRESSION_MAX_ARRAY_SIZE_IN_REDUCE = "native_expression.max_array_size_in_reduce"; public static final String NATIVE_AGGREGATION_SPILL_ALL = "native_aggregation_spill_all"; public static final String NATIVE_MAX_SPILL_LEVEL = "native_max_spill_level"; public static final String NATIVE_MAX_SPILL_FILE_SIZE = "native_max_spill_file_size"; @@ -1648,6 +1649,11 @@ public SystemSessionProperties( "Native Execution only. Enable simplified path in expression evaluation", false, false), + integerProperty( + NATIVE_EXPRESSION_MAX_ARRAY_SIZE_IN_REDUCE, + "Native Execution only. Reduce() function will throw an error if it encounters an array of size greater than this value.", + 100000, + false), booleanProperty( NATIVE_AGGREGATION_SPILL_ALL, "Native Execution only. If true and spilling has been triggered during the input " + diff --git a/presto-native-execution/presto_cpp/main/SessionProperties.cpp b/presto-native-execution/presto_cpp/main/SessionProperties.cpp index 334820042630b..8af2b944b443c 100644 --- a/presto-native-execution/presto_cpp/main/SessionProperties.cpp +++ b/presto-native-execution/presto_cpp/main/SessionProperties.cpp @@ -64,6 +64,14 @@ SessionProperties::SessionProperties() { QueryConfig::kExprEvalSimplified, boolToString(c.exprEvalSimplified())); + addSessionProperty( + kExprMaxArraySizeInReduce, + "Reduce() function will throw an error if it encounters an array of size greater than this value.", + BIGINT(), + false, + QueryConfig::kExprMaxArraySizeInReduce, + std::to_string(c.exprMaxArraySizeInReduce())); + addSessionProperty( kMaxPartialAggregationMemory, "The max partial aggregation memory when data reduction is not optimal.", diff --git a/presto-native-execution/presto_cpp/main/SessionProperties.h b/presto-native-execution/presto_cpp/main/SessionProperties.h index f3e90fe2ee8ac..e911aa6016bde 100644 --- a/presto-native-execution/presto_cpp/main/SessionProperties.h +++ b/presto-native-execution/presto_cpp/main/SessionProperties.h @@ -77,6 +77,11 @@ class SessionProperties { static constexpr const char* kExprEvalSimplified = "native_simplified_expression_evaluation_enabled"; + /// Reduce() function will throw an error if it encounters an array of size + /// greater than this value. + static constexpr const char* kExprMaxArraySizeInReduce = + "native_expression.max_array_size_in_reduce"; + /// The maximum memory used by partial aggregation when data reduction is not /// optimal. static constexpr const char* kMaxPartialAggregationMemory = diff --git a/presto-native-execution/presto_cpp/main/tests/QueryContextManagerTest.cpp b/presto-native-execution/presto_cpp/main/tests/QueryContextManagerTest.cpp index 75730cca8aeb7..14f1a7e870316 100644 --- a/presto-native-execution/presto_cpp/main/tests/QueryContextManagerTest.cpp +++ b/presto-native-execution/presto_cpp/main/tests/QueryContextManagerTest.cpp @@ -57,7 +57,9 @@ TEST_F(QueryContextManagerTest, nativeSessionProperties) { {"native_debug_disable_expression_with_memoization", "true"}, {"native_debug_disable_expression_with_lazy_inputs", "true"}, {"native_selective_nimble_reader_enabled", "true"}, - {"aggregation_spill_all", "true"}}}; + {"aggregation_spill_all", "true"}, + {"native_expression.max_array_size_in_reduce", "99999"}, + }}; auto queryCtx = taskManager_->getQueryContextManager()->findOrCreateQueryCtx( taskId, session); EXPECT_EQ(queryCtx->queryConfig().maxSpillLevel(), 2); @@ -70,6 +72,7 @@ TEST_F(QueryContextManagerTest, nativeSessionProperties) { EXPECT_TRUE(queryCtx->queryConfig().debugDisableExpressionsWithLazyInputs()); EXPECT_TRUE(queryCtx->queryConfig().selectiveNimbleReaderEnabled()); EXPECT_EQ(queryCtx->queryConfig().spillWriteBufferSize(), 1024); + EXPECT_EQ(queryCtx->queryConfig().exprMaxArraySizeInReduce(), 99999); } TEST_F(QueryContextManagerTest, defaultSessionProperties) {