You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gluten.apache.org by "KevinyhZou (via GitHub)" <gi...@apache.org> on 2024/09/23 02:32:57 UTC
[I] [CH] Result diff when set `streaming_aggregate_enabled` true [incubator-gluten]
KevinyhZou opened a new issue, #7311:
URL: https://github.com/apache/incubator-gluten/issues/7311
### Backend
CH (ClickHouse)
### Bug description
The diff problem is found at case `dsgluten_2413_0_1`
When set the config `spark.gluten.sql.columnar.backend.ch.runtime_config.enable_streaming_aggregating` false, the result is same as valina , as below
```
2024-08-26,0,AD,208, all, all, 29,22, 1.3181818,,,,
```
when set this config as true, the result is different from valina
```
2024-08-26,0,AD,208,all,all, 29, 23, 1.260869 ,,,,
```
### Spark version
Spark-3.3.x
### Spark configurations
_No response_
### System information
_No response_
### Relevant logs
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [I] [CH] Result diff when set `streaming_aggregate_enabled` true [incubator-gluten]
Posted by "lgbo-ustc (via GitHub)" <gi...@apache.org>.
lgbo-ustc commented on issue #7311:
URL: https://github.com/apache/incubator-gluten/issues/7311#issuecomment-2367388298
It may be a problem related to `uniqExact`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [I] [CH] Result diff when set `streaming_aggregate_enabled` true [incubator-gluten]
Posted by "lgbo-ustc (via GitHub)" <gi...@apache.org>.
lgbo-ustc commented on issue #7311:
URL: https://github.com/apache/incubator-gluten/issues/7311#issuecomment-2409651777
Another idea, could we remove other aggregate functions in the distinct aggregate step, for example `partial_sum` in the first 2 aggregate step of following

When the distinct variable is high cardinality, the other partial aggregations in the first 2 aggregate step should bring nagative performance benfits.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [I] [CH] Result diff when set `streaming_aggregate_enabled` true [incubator-gluten]
Posted by "lgbo-ustc (via GitHub)" <gi...@apache.org>.
lgbo-ustc commented on issue #7311:
URL: https://github.com/apache/incubator-gluten/issues/7311#issuecomment-2367738266
Disabling streaming aggregating cannot guarantee this problem will not occur
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [I] [CH] Result diff when set `streaming_aggregate_enabled` true [incubator-gluten]
Posted by "lgbo-ustc (via GitHub)" <gi...@apache.org>.
lgbo-ustc commented on issue #7311:
URL: https://github.com/apache/incubator-gluten/issues/7311#issuecomment-2408422282
该用例暴露了比较多的问题。
### 需要区分聚合阶段AGGREGATION_PHASE_INITIAL_TO_INTERMEDIATE
和 AGGREGATION_PHASE_INTERMEDIATE_TO_INTERMEDIATE
在当前的实现中,这个两个状态是同等对待的。都是用 `StreamingAggregatingStep`来对待。实际上处于AGGREGATION_PHASE_INTERMEDIATE_TO_INTERMEDIATE 状态时,不一定能采用streaming的方式来处理。一些情况下,必须消费完所有数据,完成聚合,才能向下游生成数据。如count(distint x) 和其他聚合函数混用时。
为了应对高基数可能引起OOM的情况,引入了`GraceAggregatingStep`。这个沿用之前的代码,可以快速实现,相对简单。
### `CH` 一个执行步骤内对多聚合阶段的支持
`CH`默认一个执行步骤内只有一种聚合阶段。但在spark中,会出现多种聚合解读的情况,如AGGREGATION_PHASE_INITIAL_TO_INTERMEDIATE 和 AGGREGATION_PHASE_INTERMEDIATE_TO_INTERMEDIATE。我们需要更新聚合step的output header的生成方式。
### 多聚合阶段折叠
`MergeTwoPhasesHashBaseAggregate` 会将两个在聚合阶段合并为同一个。这会影响判断采用哪种聚合 step。我们必须做出修正。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [I] [CH] Result diff when set `streaming_aggregate_enabled` true [incubator-gluten]
Posted by "lgbo-ustc (via GitHub)" <gi...@apache.org>.
lgbo-ustc commented on issue #7311:
URL: https://github.com/apache/incubator-gluten/issues/7311#issuecomment-2369991391
Some example queries
```sql
select n_regionkey, count(distinct(n_name)), sum(distinct(n_nationkey)) from tpch_pq.nation group by n_regionkey with cube;
```
```
AdaptiveSparkPlan isFinalPlan=false
+- HashAggregate(keys=[n_regionkey#45L, spark_grouping_id#44L], functions=[count(spark_catalog.tpch_pq.nation.n_name#47), sum(spark_catalog.tpch_pq.nation.n_nationkey#48L)])
+- Exchange hashpartitioning(n_regionkey#45L, spark_grouping_id#44L, 5), ENSURE_REQUIREMENTS, [plan_id=273]
+- HashAggregate(keys=[n_regionkey#45L, spark_grouping_id#44L], functions=[partial_count(spark_catalog.tpch_pq.nation.n_name#47) FILTER (WHERE (gid#46 = 1)), partial_sum(spark_catalog.tpch_pq.nation.n_nationkey#48L) FILTER (WHERE (gid#46 = 2))])
+- HashAggregate(keys=[n_regionkey#45L, spark_grouping_id#44L, spark_catalog.tpch_pq.nation.n_name#47, spark_catalog.tpch_pq.nation.n_nationkey#48L, gid#46], functions=[])
+- Exchange hashpartitioning(n_regionkey#45L, spark_grouping_id#44L, spark_catalog.tpch_pq.nation.n_name#47, spark_catalog.tpch_pq.nation.n_nationkey#48L, gid#46, 5), ENSURE_REQUIREMENTS, [plan_id=269]
+- HashAggregate(keys=[n_regionkey#45L, spark_grouping_id#44L, spark_catalog.tpch_pq.nation.n_name#47, spark_catalog.tpch_pq.nation.n_nationkey#48L, gid#46], functions=[])
+- Expand [[n_regionkey#45L, spark_grouping_id#44L, n_name#1, null, 1], [n_regionkey#45L, spark_grouping_id#44L, null, n_nationkey#0L, 2]], [n_regionkey#45L, spark_grouping_id#44L, spark_catalog.tpch_pq.nation.n_name#47, spark_catalog.tpch_pq.nation.n_nationkey#48L, gid#46]
+- Expand [[n_nationkey#0L, n_name#1, n_regionkey#2L, 0], [n_nationkey#0L, n_name#1, null, 1]], [n_nationkey#0L, n_name#1, n_regionkey#45L, spark_grouping_id#44L]
+- FileScan parquet tpch_pq.nation[n_nationkey#0L,n_name#1,n_regionkey#2L] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex(1 paths)[file:/home/workspace/docker/local_gluten/tpch_pq_data/nat..., PartitionFilters: [], PushedFilters: [], ReadSchema: struct<n_nationkey:bigint,n_name:string,n_regionkey:bigint>
```
```sql
select n_regionkey, count(distinct(n_name)), sum(distinct(n_nationkey)) from tpch_pq.nation group by n_regionkey
```
```
AdaptiveSparkPlan isFinalPlan=false
+- HashAggregate(keys=[n_regionkey#2L], functions=[count(spark_catalog.tpch_pq.nation.n_name#65), sum(spark_catalog.tpch_pq.nation.n_nationkey#66L)])
+- Exchange hashpartitioning(n_regionkey#2L, 5), ENSURE_REQUIREMENTS, [plan_id=310]
+- HashAggregate(keys=[n_regionkey#2L], functions=[partial_count(spark_catalog.tpch_pq.nation.n_name#65) FILTER (WHERE (gid#64 = 1)), partial_sum(spark_catalog.tpch_pq.nation.n_nationkey#66L) FILTER (WHERE (gid#64 = 2))])
+- HashAggregate(keys=[n_regionkey#2L, spark_catalog.tpch_pq.nation.n_name#65, spark_catalog.tpch_pq.nation.n_nationkey#66L, gid#64], functions=[])
+- Exchange hashpartitioning(n_regionkey#2L, spark_catalog.tpch_pq.nation.n_name#65, spark_catalog.tpch_pq.nation.n_nationkey#66L, gid#64, 5), ENSURE_REQUIREMENTS, [plan_id=306]
+- HashAggregate(keys=[n_regionkey#2L, spark_catalog.tpch_pq.nation.n_name#65, spark_catalog.tpch_pq.nation.n_nationkey#66L, gid#64], functions=[])
+- Expand [[n_regionkey#2L, n_name#1, null, 1], [n_regionkey#2L, null, n_nationkey#0L, 2]], [n_regionkey#2L, spark_catalog.tpch_pq.nation.n_name#65, spark_catalog.tpch_pq.nation.n_nationkey#66L, gid#64]
+- FileScan parquet tpch_pq.nation[n_nationkey#0L,n_name#1,n_regionkey#2L] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex(1 paths)[file:/home/workspace/docker/local_gluten/tpch_pq_data/nat..., PartitionFilters: [], PushedFilters: [], ReadSchema: struct<n_nationkey:bigint,n_name:string,n_regionkey:bigint>
```
```sql
select n_regionkey, count(distinct(n_name)) from tpch_pq.nation group by n_regionkey
```
```
AdaptiveSparkPlan isFinalPlan=false
+- HashAggregate(keys=[n_regionkey#2L], functions=[count(distinct n_name#1)])
+- Exchange hashpartitioning(n_regionkey#2L, 5), ENSURE_REQUIREMENTS, [plan_id=342]
+- HashAggregate(keys=[n_regionkey#2L], functions=[partial_count(distinct n_name#1)])
+- HashAggregate(keys=[n_regionkey#2L, n_name#1], functions=[])
+- Exchange hashpartitioning(n_regionkey#2L, n_name#1, 5), ENSURE_REQUIREMENTS, [plan_id=338]
+- HashAggregate(keys=[n_regionkey#2L, n_name#1], functions=[])
+- FileScan parquet tpch_pq.nation[n_name#1,n_regionkey#2L] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex(1 paths)[file:/home/workspace/docker/local_gluten/tpch_pq_data/nat..., PartitionFilters: [], PushedFilters: [], ReadSchema: struct<n_name:string,n_regionkey:bigint>
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [I] [CH] Result diff when set `streaming_aggregate_enabled` true [incubator-gluten]
Posted by "lgbo-ustc (via GitHub)" <gi...@apache.org>.
lgbo-ustc commented on issue #7311:
URL: https://github.com/apache/incubator-gluten/issues/7311#issuecomment-2367761583
We could make a patch for `count(distinct)` to fix this problem, but what about other aggregate functions?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [I] [CH] Result diff when set `streaming_aggregate_enabled` true [incubator-gluten]
Posted by "baibaichen (via GitHub)" <gi...@apache.org>.
baibaichen closed issue #7311: [CH] Result diff when set `streaming_aggregate_enabled` true
URL: https://github.com/apache/incubator-gluten/issues/7311
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [I] [CH] Result diff when set `streaming_aggregate_enabled` true [incubator-gluten]
Posted by "KevinyhZou (via GitHub)" <gi...@apache.org>.
KevinyhZou commented on issue #7311:
URL: https://github.com/apache/incubator-gluten/issues/7311#issuecomment-2367145160
@lgbo-ustc
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org