@@ -23,7 +23,7 @@ pub use schema::TypeInfo;
2323
2424use crate :: naming;
2525use crate :: parser;
26- use crate :: plot:: layer :: geom :: GeomAesthetics ;
26+ use crate :: plot:: aesthetic :: { primary_aesthetic , ALL_POSITIONAL } ;
2727use crate :: plot:: { AestheticValue , Layer , Scale , ScaleTypeKind , Schema } ;
2828use crate :: { DataFrame , GgsqlError , Plot , Result } ;
2929use std:: collections:: { HashMap , HashSet } ;
@@ -285,12 +285,6 @@ fn add_discrete_columns_to_partition_by(
285285 layer_schemas : & [ Schema ] ,
286286 scales : & [ Scale ] ,
287287) {
288- // Positional aesthetics should NOT be auto-added to grouping.
289- // Stats that need to group by positional aesthetics (like bar/histogram)
290- // already handle this themselves via stat_consumed_aesthetics().
291- const POSITIONAL_AESTHETICS : & [ & str ] =
292- & [ "x" , "y" , "xmin" , "xmax" , "ymin" , "ymax" , "xend" , "yend" ] ;
293-
294288 // Build a map of aesthetic -> scale for quick lookup
295289 let scale_map: HashMap < & str , & Scale > =
296290 scales. iter ( ) . map ( |s| ( s. aesthetic . as_str ( ) , s) ) . collect ( ) ;
@@ -307,8 +301,10 @@ fn add_discrete_columns_to_partition_by(
307301 let consumed_aesthetics = layer. geom . stat_consumed_aesthetics ( ) ;
308302
309303 for ( aesthetic, value) in & layer. mappings . aesthetics {
310- // Skip positional aesthetics - these should not trigger auto-grouping
311- if POSITIONAL_AESTHETICS . contains ( & aesthetic. as_str ( ) ) {
304+ // Skip positional aesthetics - these should not trigger auto-grouping.
305+ // Stats that need to group by positional aesthetics (like bar/histogram)
306+ // already handle this themselves via stat_consumed_aesthetics().
307+ if ALL_POSITIONAL . iter ( ) . any ( |s| s == aesthetic) {
312308 continue ;
313309 }
314310
@@ -329,7 +325,7 @@ fn add_discrete_columns_to_partition_by(
329325 //
330326 // Discrete and Binned scales produce categorical groupings.
331327 // Continuous scales don't group. Identity defers to column type.
332- let primary_aesthetic = GeomAesthetics :: primary_aesthetic ( aesthetic) ;
328+ let primary_aesthetic = primary_aesthetic ( aesthetic) ;
333329 let is_discrete = if let Some ( scale) = scale_map. get ( primary_aesthetic) {
334330 if let Some ( ref scale_type) = scale. scale_type {
335331 match scale_type. scale_type_kind ( ) {
@@ -1063,20 +1059,20 @@ mod tests {
10631059 let result = prepare_data_with_reader ( query, & reader) . unwrap ( ) ;
10641060 let layer = & result. specs [ 0 ] . layers [ 0 ] ;
10651061
1066- // Layer should have y2 in mappings (added by default for bar)
1062+ // Layer should have yend in mappings (added by default for bar)
10671063 assert ! (
1068- layer. mappings. aesthetics. contains_key( "y2 " ) ,
1069- "Bar should have y2 mapping for baseline: {:?}" ,
1064+ layer. mappings. aesthetics. contains_key( "yend " ) ,
1065+ "Bar should have yend mapping for baseline: {:?}" ,
10701066 layer. mappings. aesthetics. keys( ) . collect:: <Vec <_>>( )
10711067 ) ;
10721068
1073- // The DataFrame should have the y2 column with 0 values
1069+ // The DataFrame should have the yend column with 0 values
10741070 let layer_df = result. data . get ( & naming:: layer_key ( 0 ) ) . unwrap ( ) ;
1075- let y2_col = naming:: aesthetic_column ( "y2 " ) ;
1071+ let yend_col = naming:: aesthetic_column ( "yend " ) ;
10761072 assert ! (
1077- layer_df. column( & y2_col ) . is_ok( ) ,
1073+ layer_df. column( & yend_col ) . is_ok( ) ,
10781074 "DataFrame should have '{}' column: {:?}" ,
1079- y2_col ,
1075+ yend_col ,
10801076 layer_df. get_column_names_str( )
10811077 ) ;
10821078 }
0 commit comments