@@ -245,6 +245,12 @@ pub trait Dialect: Send + Sync {
245245 fn to_unicode_string_literal ( & self , _s : & str ) -> Option < ast:: Expr > {
246246 None
247247 }
248+
249+ /// Whether the dialect supports using literal values as GROUP BY keys.
250+ /// Some dialects like BigQuery do not support using literal values as GROUP BY keys.
251+ fn support_literal_group_by_key ( & self ) -> bool {
252+ true
253+ }
248254}
249255
250256/// `IntervalStyle` to use for unparsing
@@ -582,6 +588,10 @@ impl Dialect for BigQueryDialect {
582588 fn unnest_as_table_factor ( & self ) -> bool {
583589 true
584590 }
591+
592+ fn support_literal_group_by_key ( & self ) -> bool {
593+ false
594+ }
585595}
586596
587597impl BigQueryDialect {
@@ -786,6 +796,7 @@ pub struct CustomDialect {
786796 window_func_support_window_frame : bool ,
787797 full_qualified_col : bool ,
788798 unnest_as_table_factor : bool ,
799+ support_literal_group_by_key : bool ,
789800}
790801
791802impl Default for CustomDialect {
@@ -814,6 +825,7 @@ impl Default for CustomDialect {
814825 window_func_support_window_frame : true ,
815826 full_qualified_col : false ,
816827 unnest_as_table_factor : false ,
828+ support_literal_group_by_key : true ,
817829 }
818830 }
819831}
@@ -935,6 +947,10 @@ impl Dialect for CustomDialect {
935947 fn unnest_as_table_factor ( & self ) -> bool {
936948 self . unnest_as_table_factor
937949 }
950+
951+ fn support_literal_group_by_key ( & self ) -> bool {
952+ self . support_literal_group_by_key
953+ }
938954}
939955
940956/// `CustomDialectBuilder` to build `CustomDialect` using builder pattern
@@ -973,6 +989,7 @@ pub struct CustomDialectBuilder {
973989 full_qualified_col : bool ,
974990 unnest_as_table_factor : bool ,
975991 unnest_to_flattened_table_factor : bool ,
992+ support_literal_group_by_key : bool ,
976993}
977994
978995impl Default for CustomDialectBuilder {
@@ -1008,6 +1025,7 @@ impl CustomDialectBuilder {
10081025 full_qualified_col : false ,
10091026 unnest_as_table_factor : false ,
10101027 unnest_to_flattened_table_factor : false ,
1028+ support_literal_group_by_key : true ,
10111029 }
10121030 }
10131031
@@ -1034,6 +1052,7 @@ impl CustomDialectBuilder {
10341052 window_func_support_window_frame : self . window_func_support_window_frame ,
10351053 full_qualified_col : self . full_qualified_col ,
10361054 unnest_as_table_factor : self . unnest_as_table_factor ,
1055+ support_literal_group_by_key : self . support_literal_group_by_key ,
10371056 }
10381057 }
10391058
@@ -1182,4 +1201,12 @@ impl CustomDialectBuilder {
11821201 self . unnest_to_flattened_table_factor = unnest_to_flattened_table_factor;
11831202 self
11841203 }
1204+
1205+ pub fn with_support_literal_group_by_key (
1206+ mut self ,
1207+ support_literal_group_by_key : bool ,
1208+ ) -> Self {
1209+ self . support_literal_group_by_key = support_literal_group_by_key;
1210+ self
1211+ }
11851212}
0 commit comments