Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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 @@ -1710,6 +1710,16 @@ object SQLConf {
.booleanConf
.createWithDefault(true)

val ENABLE_TWOLEVEL_AGG_MAP_PARTIAL_ONLY =
buildConf("spark.sql.codegen.aggregate.map.twolevel.partialOnly")
.internal()
.doc("Enable two-level aggregate hash map for partial aggregate only, " +
"because final aggregate might get more distinct keys compared to partial aggregate. " +
"Overhead of looking up 1st-level map might dominate when having a lot of distinct keys.")
.version("3.2.1")
.booleanConf
.createWithDefault(true)

val ENABLE_VECTORIZED_HASH_MAP =
buildConf("spark.sql.codegen.aggregate.map.vectorized.enable")
.internal()
Expand Down Expand Up @@ -3865,6 +3875,8 @@ class SQLConf extends Serializable with Logging {

def enableTwoLevelAggMap: Boolean = getConf(ENABLE_TWOLEVEL_AGG_MAP)

def enableTwoLevelAggMapPartialOnly: Boolean = getConf(ENABLE_TWOLEVEL_AGG_MAP_PARTIAL_ONLY)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we don't need to add a corresponding conf method if it's only called once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cloud-fan - updated.


def enableVectorizedHashMap: Boolean = getConf(ENABLE_VECTORIZED_HASH_MAP)

def useObjectHashAggregation: Boolean = getConf(USE_OBJECT_HASH_AGG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,14 @@ case class HashAggregateExec(
val isNotByteArrayDecimalType = bufferSchema.map(_.dataType).filter(_.isInstanceOf[DecimalType])
.forall(!DecimalType.isByteArrayDecimalType(_))

isSupported && isNotByteArrayDecimalType
val isEnabledForAggModes =
if (modes.forall(mode => mode == Partial || mode == PartialMerge)) {
true
} else {
!conf.enableTwoLevelAggMapPartialOnly
}

isSupported && isNotByteArrayDecimalType && isEnabledForAggModes
}

private def enableTwoLevelHashMap(ctx: CodegenContext): Unit = {
Expand Down