@@ -50,17 +50,21 @@ pub fn data_types_with_scalar_udf(
50
50
func : & ScalarUDF ,
51
51
) -> Result < Vec < DataType > > {
52
52
let signature = func. signature ( ) ;
53
+ let type_signature = & signature. type_signature ;
53
54
54
55
if current_types. is_empty ( ) {
55
- if signature . type_signature . supports_zero_argument ( ) {
56
+ if type_signature. supports_zero_argument ( ) {
56
57
return Ok ( vec ! [ ] ) ;
58
+ } else if type_signature. used_to_support_zero_arguments ( ) {
59
+ // Special error to help during upgrade: https://github.com/apache/datafusion/issues/13763
60
+ return plan_err ! ( "{} does not support zero arguments. Use TypeSignature::Nullary for zero arguments." , func. name( ) ) ;
57
61
} else {
58
62
return plan_err ! ( "{} does not support zero arguments." , func. name( ) ) ;
59
63
}
60
64
}
61
65
62
66
let valid_types =
63
- get_valid_types_with_scalar_udf ( & signature . type_signature , current_types, func) ?;
67
+ get_valid_types_with_scalar_udf ( type_signature, current_types, func) ?;
64
68
65
69
if valid_types
66
70
. iter ( )
@@ -69,12 +73,7 @@ pub fn data_types_with_scalar_udf(
69
73
return Ok ( current_types. to_vec ( ) ) ;
70
74
}
71
75
72
- try_coerce_types (
73
- func. name ( ) ,
74
- valid_types,
75
- current_types,
76
- & signature. type_signature ,
77
- )
76
+ try_coerce_types ( func. name ( ) , valid_types, current_types, type_signature)
78
77
}
79
78
80
79
/// Performs type coercion for aggregate function arguments.
@@ -89,33 +88,29 @@ pub fn data_types_with_aggregate_udf(
89
88
func : & AggregateUDF ,
90
89
) -> Result < Vec < DataType > > {
91
90
let signature = func. signature ( ) ;
91
+ let type_signature = & signature. type_signature ;
92
92
93
93
if current_types. is_empty ( ) {
94
- if signature . type_signature . supports_zero_argument ( ) {
94
+ if type_signature. supports_zero_argument ( ) {
95
95
return Ok ( vec ! [ ] ) ;
96
+ } else if type_signature. used_to_support_zero_arguments ( ) {
97
+ // Special error to help during upgrade: https://github.com/apache/datafusion/issues/13763
98
+ return plan_err ! ( "{} does not support zero arguments. Use TypeSignature::Nullary for zero arguments." , func. name( ) ) ;
96
99
} else {
97
100
return plan_err ! ( "{} does not support zero arguments." , func. name( ) ) ;
98
101
}
99
102
}
100
103
101
- let valid_types = get_valid_types_with_aggregate_udf (
102
- & signature. type_signature ,
103
- current_types,
104
- func,
105
- ) ?;
104
+ let valid_types =
105
+ get_valid_types_with_aggregate_udf ( type_signature, current_types, func) ?;
106
106
if valid_types
107
107
. iter ( )
108
108
. any ( |data_type| data_type == current_types)
109
109
{
110
110
return Ok ( current_types. to_vec ( ) ) ;
111
111
}
112
112
113
- try_coerce_types (
114
- func. name ( ) ,
115
- valid_types,
116
- current_types,
117
- & signature. type_signature ,
118
- )
113
+ try_coerce_types ( func. name ( ) , valid_types, current_types, type_signature)
119
114
}
120
115
121
116
/// Performs type coercion for window function arguments.
@@ -130,30 +125,29 @@ pub fn data_types_with_window_udf(
130
125
func : & WindowUDF ,
131
126
) -> Result < Vec < DataType > > {
132
127
let signature = func. signature ( ) ;
128
+ let type_signature = & signature. type_signature ;
133
129
134
130
if current_types. is_empty ( ) {
135
- if signature . type_signature . supports_zero_argument ( ) {
131
+ if type_signature. supports_zero_argument ( ) {
136
132
return Ok ( vec ! [ ] ) ;
133
+ } else if type_signature. used_to_support_zero_arguments ( ) {
134
+ // Special error to help during upgrade: https://github.com/apache/datafusion/issues/13763
135
+ return plan_err ! ( "{} does not support zero arguments. Use TypeSignature::Nullary for zero arguments." , func. name( ) ) ;
137
136
} else {
138
137
return plan_err ! ( "{} does not support zero arguments." , func. name( ) ) ;
139
138
}
140
139
}
141
140
142
141
let valid_types =
143
- get_valid_types_with_window_udf ( & signature . type_signature , current_types, func) ?;
142
+ get_valid_types_with_window_udf ( type_signature, current_types, func) ?;
144
143
if valid_types
145
144
. iter ( )
146
145
. any ( |data_type| data_type == current_types)
147
146
{
148
147
return Ok ( current_types. to_vec ( ) ) ;
149
148
}
150
149
151
- try_coerce_types (
152
- func. name ( ) ,
153
- valid_types,
154
- current_types,
155
- & signature. type_signature ,
156
- )
150
+ try_coerce_types ( func. name ( ) , valid_types, current_types, type_signature)
157
151
}
158
152
159
153
/// Performs type coercion for function arguments.
@@ -168,31 +162,34 @@ pub fn data_types(
168
162
current_types : & [ DataType ] ,
169
163
signature : & Signature ,
170
164
) -> Result < Vec < DataType > > {
165
+ let type_signature = & signature. type_signature ;
166
+
171
167
if current_types. is_empty ( ) {
172
- if signature . type_signature . supports_zero_argument ( ) {
168
+ if type_signature. supports_zero_argument ( ) {
173
169
return Ok ( vec ! [ ] ) ;
170
+ } else if type_signature. used_to_support_zero_arguments ( ) {
171
+ // Special error to help during upgrade: https://github.com/apache/datafusion/issues/13763
172
+ return plan_err ! (
173
+ "signature {:?} does not support zero arguments. Use TypeSignature::Nullary for zero arguments." ,
174
+ type_signature
175
+ ) ;
174
176
} else {
175
177
return plan_err ! (
176
178
"signature {:?} does not support zero arguments." ,
177
- & signature . type_signature
179
+ type_signature
178
180
) ;
179
181
}
180
182
}
181
183
182
- let valid_types = get_valid_types ( & signature . type_signature , current_types) ?;
184
+ let valid_types = get_valid_types ( type_signature, current_types) ?;
183
185
if valid_types
184
186
. iter ( )
185
187
. any ( |data_type| data_type == current_types)
186
188
{
187
189
return Ok ( current_types. to_vec ( ) ) ;
188
190
}
189
191
190
- try_coerce_types (
191
- function_name,
192
- valid_types,
193
- current_types,
194
- & signature. type_signature ,
195
- )
192
+ try_coerce_types ( function_name, valid_types, current_types, type_signature)
196
193
}
197
194
198
195
fn is_well_supported_signature ( type_signature : & TypeSignature ) -> bool {
0 commit comments