|
26 | 26 | public class Function extends ASTNodeAccessImpl implements Expression { |
27 | 27 | private List<String> nameparts; |
28 | 28 | private ExpressionList<?> parameters; |
| 29 | + private ExpressionList<?> chainedParameters; |
29 | 30 | private NamedExpressionList<?> namedParameters; |
30 | 31 | private boolean allColumns = false; |
31 | 32 | private boolean distinct = false; |
@@ -192,6 +193,20 @@ public void setParameters(ExpressionList<?> list) { |
192 | 193 | parameters = list; |
193 | 194 | } |
194 | 195 |
|
| 196 | + /** |
| 197 | + * Additional function-call parameters for dialects that support chained function calls, e.g. |
| 198 | + * quantile(0.95)(cost) in ClickHouse. |
| 199 | + * |
| 200 | + * @return the chained parameters of the function (if any, else null) |
| 201 | + */ |
| 202 | + public ExpressionList<?> getChainedParameters() { |
| 203 | + return chainedParameters; |
| 204 | + } |
| 205 | + |
| 206 | + public void setChainedParameters(ExpressionList<?> chainedParameters) { |
| 207 | + this.chainedParameters = chainedParameters; |
| 208 | + } |
| 209 | + |
195 | 210 | /** |
196 | 211 | * the parameters might be named parameters, e.g. substring('foobar' from 2 for 3) |
197 | 212 | * |
@@ -335,6 +350,10 @@ public String toString() { |
335 | 350 |
|
336 | 351 | String ans = getName() + params; |
337 | 352 |
|
| 353 | + if (chainedParameters != null) { |
| 354 | + ans += "(" + chainedParameters + ")"; |
| 355 | + } |
| 356 | + |
338 | 357 | if (nullHandling != null && isIgnoreNullsOutside()) { |
339 | 358 | switch (nullHandling) { |
340 | 359 | case IGNORE_NULLS: |
@@ -393,6 +412,11 @@ public Function withParameters(Expression... parameters) { |
393 | 412 | return withParameters(new ExpressionList<>(parameters)); |
394 | 413 | } |
395 | 414 |
|
| 415 | + public Function withChainedParameters(ExpressionList<?> chainedParameters) { |
| 416 | + this.setChainedParameters(chainedParameters); |
| 417 | + return this; |
| 418 | + } |
| 419 | + |
396 | 420 | public Function withNamedParameters(NamedExpressionList<?> namedParameters) { |
397 | 421 | this.setNamedParameters(namedParameters); |
398 | 422 | return this; |
|
0 commit comments