Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -1705,11 +1705,21 @@ object SQLConf {
.doc("Enable two-level aggregate hash map. When enabled, records will first be " +
"inserted/looked-up at a 1st-level, small, fast map, and then fallback to a " +
"2nd-level, larger, slower map when 1st level is full or keys cannot be found. " +
"When disabled, records go directly to the 2nd level.")
"When disabled, records go directly to the 2nd level. Enable for partial aggregate only.")
.version("2.3.0")
.booleanConf
.createWithDefault(true)

val ENABLE_TWOLEVEL_FINAL_AGG_MAP =
buildConf("spark.sql.codegen.aggregate.final.map.twolevel.enabled")
Copy link
Contributor

Choose a reason for hiding this comment

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

how about park.sql.codegen.aggregate.map.twolevel.partialOnly

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 - sure, updated. So given the new meaning of config, changed the default config value to true as well.

.internal()
.doc("Enable two-level aggregate hash map for final aggregate as well. Disable by default " +
"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.0")
Copy link
Contributor

Choose a reason for hiding this comment

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

3.2.1

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 - yes, updated.

.booleanConf
.createWithDefault(false)

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 enableTwoLevelFinalAggMap: Boolean = getConf(ENABLE_TWOLEVEL_FINAL_AGG_MAP)

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.enableTwoLevelFinalAggMap
}

isSupported && isNotByteArrayDecimalType && isEnabledForAggModes
}

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