Skip to content

Commit

Permalink
[ES|QL] Remove variadic functions' optional args from the output of s…
Browse files Browse the repository at this point in the history
…how functions (#106454)

* remove optional args from the output of show functions optionalArgs, argNames and argTypes for variadic functions
* consistent names for arguments
  • Loading branch information
fang-xing-esql authored Mar 20, 2024
1 parent 09b6072 commit 5d05d81
Show file tree
Hide file tree
Showing 72 changed files with 267 additions and 236 deletions.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/concat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/types/case.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

[%header.monospaced.styled,format=dsv,separator=|]
|===
condition | rest | result
condition | value | result

|===
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/types/concat.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[%header.monospaced.styled,format=dsv,separator=|]
|===
first | rest | result
string1 | string2 | result
keyword | keyword | keyword
text | text | keyword
|===
306 changes: 153 additions & 153 deletions x-pack/plugin/esql/qa/testFixtures/src/main/resources/meta.csv-spec

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class Avg extends AggregateFunction implements SurrogateExpression {

@FunctionInfo(returnType = "double", description = "The average of a numeric field.", isAggregation = true)
public Avg(Source source, @Param(name = "field", type = { "double", "integer", "long" }) Expression field) {
public Avg(Source source, @Param(name = "number", type = { "double", "integer", "long" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class Max extends NumericAggregate {

@FunctionInfo(returnType = { "double", "integer", "long" }, description = "The maximum value of a numeric field.", isAggregation = true)
public Max(Source source, @Param(name = "field", type = { "double", "integer", "long" }) Expression field) {
public Max(Source source, @Param(name = "number", type = { "double", "integer", "long" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Median extends AggregateFunction implements SurrogateExpression {
description = "The value that is greater than half of all values and less than half of all values.",
isAggregation = true
)
public Median(Source source, @Param(name = "field", type = { "double", "integer", "long" }) Expression field) {
public Median(Source source, @Param(name = "number", type = { "double", "integer", "long" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class MedianAbsoluteDeviation extends NumericAggregate {
description = "The median absolute deviation, a measure of variability.",
isAggregation = true
)
public MedianAbsoluteDeviation(Source source, @Param(name = "field", type = { "double", "integer", "long" }) Expression field) {
public MedianAbsoluteDeviation(Source source, @Param(name = "number", type = { "double", "integer", "long" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class Min extends NumericAggregate {

@FunctionInfo(returnType = { "double", "integer", "long" }, description = "The minimum value of a numeric field.", isAggregation = true)
public Min(Source source, @Param(name = "field", type = { "double", "integer", "long" }) Expression field) {
public Min(Source source, @Param(name = "number", type = { "double", "integer", "long" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Percentile extends NumericAggregate {
)
public Percentile(
Source source,
@Param(name = "field", type = { "double", "integer", "long" }) Expression field,
@Param(name = "number", type = { "double", "integer", "long" }) Expression field,
@Param(name = "percentile", type = { "double", "integer", "long" }) Expression percentile
) {
super(source, field, List.of(percentile));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class Sum extends NumericAggregate {

@FunctionInfo(returnType = "long", description = "The sum of a numeric field.", isAggregation = true)
public Sum(Source source, @Param(name = "field", type = { "double", "integer", "long" }) Expression field) {
public Sum(Source source, @Param(name = "number", type = { "double", "integer", "long" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Case(
Source source,
@Param(name = "condition", type = { "boolean" }) Expression first,
@Param(
name = "rest",
name = "trueValue",
type = {
"boolean",
"cartesian_point",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class Greatest extends EsqlScalarFunction implements OptionalArgument {
public Greatest(
Source source,
@Param(name = "first", type = { "integer", "long", "double", "boolean", "keyword", "text", "ip", "version" }) Expression first,
@Param(name = "rest", type = { "integer", "long", "double", "boolean", "keyword", "text", "ip", "version" }) List<Expression> rest
@Param(name = "rest", type = { "integer", "long", "double", "boolean", "keyword", "text", "ip", "version" }, optional = true) List<
Expression> rest
) {
super(source, Stream.concat(Stream.of(first), rest.stream()).toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class Least extends EsqlScalarFunction implements OptionalArgument {
public Least(
Source source,
@Param(name = "first", type = { "integer", "long", "double", "boolean", "keyword", "text", "ip", "version" }) Expression first,
@Param(name = "rest", type = { "integer", "long", "double", "boolean", "keyword", "text", "ip", "version" }) List<Expression> rest
@Param(name = "rest", type = { "integer", "long", "double", "boolean", "keyword", "text", "ip", "version" }, optional = true) List<
Expression> rest
) {
super(source, Stream.concat(Stream.of(first), rest.stream()).toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class ToBoolean extends AbstractConvertFunction {
@FunctionInfo(returnType = "boolean", description = "Converts an input value to a boolean value.")
public ToBoolean(
Source source,
@Param(name = "v", type = { "boolean", "keyword", "text", "double", "long", "unsigned_long", "integer" }) Expression field
@Param(name = "field", type = { "boolean", "keyword", "text", "double", "long", "unsigned_long", "integer" }) Expression field
) {
super(source, field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ToCartesianPoint extends AbstractConvertFunction {
);

@FunctionInfo(returnType = "cartesian_point", description = "Converts an input value to a point value.")
public ToCartesianPoint(Source source, @Param(name = "v", type = { "cartesian_point", "keyword", "text" }) Expression field) {
public ToCartesianPoint(Source source, @Param(name = "field", type = { "cartesian_point", "keyword", "text" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class ToCartesianShape extends AbstractConvertFunction {
@FunctionInfo(returnType = "cartesian_shape", description = "Converts an input value to a shape value.")
public ToCartesianShape(
Source source,
@Param(name = "v", type = { "cartesian_point", "cartesian_shape", "keyword", "text" }) Expression field
@Param(name = "field", type = { "cartesian_point", "cartesian_shape", "keyword", "text" }) Expression field
) {
super(source, field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ToDatetime extends AbstractConvertFunction {
@FunctionInfo(returnType = "date", description = "Converts an input value to a date value.")
public ToDatetime(
Source source,
@Param(name = "v", type = { "date", "keyword", "text", "double", "long", "unsigned_long", "integer" }) Expression field
@Param(name = "field", type = { "date", "keyword", "text", "double", "long", "unsigned_long", "integer" }) Expression field
) {
super(source, field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ToDegrees extends AbstractConvertFunction implements EvaluatorMappe
);

@FunctionInfo(returnType = "double", description = "Converts a number in radians to degrees.")
public ToDegrees(Source source, @Param(name = "v", type = { "double", "integer", "long", "unsigned_long" }) Expression field) {
public ToDegrees(Source source, @Param(name = "number", type = { "double", "integer", "long", "unsigned_long" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public class ToDouble extends AbstractConvertFunction {
@FunctionInfo(returnType = "double", description = "Converts an input value to a double value.")
public ToDouble(
Source source,
@Param(name = "v", type = { "boolean", "date", "keyword", "text", "double", "long", "unsigned_long", "integer" }) Expression field
@Param(
name = "field",
type = { "boolean", "date", "keyword", "text", "double", "long", "unsigned_long", "integer" }
) Expression field
) {
super(source, field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ToGeoPoint extends AbstractConvertFunction {
);

@FunctionInfo(returnType = "geo_point", description = "Converts an input value to a geo_point value.")
public ToGeoPoint(Source source, @Param(name = "v", type = { "geo_point", "keyword", "text" }) Expression field) {
public ToGeoPoint(Source source, @Param(name = "field", type = { "geo_point", "keyword", "text" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ToGeoShape extends AbstractConvertFunction {
);

@FunctionInfo(returnType = "geo_shape", description = "Converts an input value to a geo_shape value.")
public ToGeoShape(Source source, @Param(name = "v", type = { "geo_point", "geo_shape", "keyword", "text" }) Expression field) {
public ToGeoShape(Source source, @Param(name = "field", type = { "geo_point", "geo_shape", "keyword", "text" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ToIP extends AbstractConvertFunction {
);

@FunctionInfo(returnType = "ip", description = "Converts an input string to an IP value.")
public ToIP(Source source, @Param(name = "v", type = { "ip", "keyword", "text" }) Expression field) {
public ToIP(Source source, @Param(name = "field", type = { "ip", "keyword", "text" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public class ToInteger extends AbstractConvertFunction {
@FunctionInfo(returnType = "integer", description = "Converts an input value to an integer value.")
public ToInteger(
Source source,
@Param(name = "v", type = { "boolean", "date", "keyword", "text", "double", "long", "unsigned_long", "integer" }) Expression field
@Param(
name = "field",
type = { "boolean", "date", "keyword", "text", "double", "long", "unsigned_long", "integer" }
) Expression field
) {
super(source, field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ public class ToLong extends AbstractConvertFunction {
@FunctionInfo(returnType = "long", description = "Converts an input value to a long value.")
public ToLong(
Source source,
@Param(name = "v", type = { "boolean", "date", "keyword", "text", "double", "long", "unsigned_long", "integer" }) Expression field
@Param(
name = "field",
type = { "boolean", "date", "keyword", "text", "double", "long", "unsigned_long", "integer" }
) Expression field
) {
super(source, field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ToRadians extends AbstractConvertFunction implements EvaluatorMappe
);

@FunctionInfo(returnType = "double", description = "Converts a number in degrees to radians.")
public ToRadians(Source source, @Param(name = "v", type = { "double", "integer", "long", "unsigned_long" }) Expression field) {
public ToRadians(Source source, @Param(name = "number", type = { "double", "integer", "long", "unsigned_long" }) Expression field) {
super(source, field);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class ToString extends AbstractConvertFunction implements EvaluatorMapper
public ToString(
Source source,
@Param(
name = "v",
name = "field",
type = {
"boolean",
"cartesian_point",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ public class ToUnsignedLong extends AbstractConvertFunction {
@FunctionInfo(returnType = "unsigned_long", description = "Converts an input value to an unsigned long value.")
public ToUnsignedLong(
Source source,
@Param(name = "v", type = { "boolean", "date", "keyword", "text", "double", "long", "unsigned_long", "integer" }) Expression field
@Param(
name = "field",
type = { "boolean", "date", "keyword", "text", "double", "long", "unsigned_long", "integer" }
) Expression field
) {
super(source, field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ToVersion extends AbstractConvertFunction {
);

@FunctionInfo(returnType = "version", description = "Converts an input string to a version value.")
public ToVersion(Source source, @Param(name = "v", type = { "keyword", "text", "version" }) Expression v) {
public ToVersion(Source source, @Param(name = "field", type = { "keyword", "text", "version" }) Expression v) {
super(source, v);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public DateExtract(
Source source,
// Need to replace the commas in the description here with semi-colon as there's a bug in the CSV parser
// used in the CSVTests and fixing it is not trivial
@Param(name = "date_part", type = { "keyword" }, description = """
@Param(name = "datePart", type = { "keyword" }, description = """
Part of the date to extract.
Can be: aligned_day_of_week_in_month; aligned_day_of_week_in_year; aligned_week_of_month;
aligned_week_of_year; ampm_of_day; clock_hour_of_ampm; clock_hour_of_day; day_of_month; day_of_week;
day_of_year; epoch_day; era; hour_of_ampm; hour_of_day; instant_seconds; micro_of_day; micro_of_second;
milli_of_day; milli_of_second; minute_of_day; minute_of_hour; month_of_year; nano_of_day; nano_of_second;
offset_seconds; proleptic_month; second_of_day; second_of_minute; year; or year_of_era.""") Expression chronoFieldExp,
@Param(name = "field", type = "date", description = "Date expression") Expression field,
@Param(name = "date", type = "date", description = "Date expression") Expression field,
Configuration configuration
) {
super(source, List.of(chronoFieldExp, field), configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class DateFormat extends EsqlConfigurationFunction implements OptionalArg
@FunctionInfo(returnType = "keyword", description = "Returns a string representation of a date, in the provided format.")
public DateFormat(
Source source,
@Param(optional = true, name = "format", type = { "keyword" }, description = "A valid date pattern") Expression format,
@Param(optional = true, name = "dateFormat", type = { "keyword" }, description = "A valid date pattern") Expression format,
@Param(name = "date", type = { "date" }, description = "Date expression") Expression date,
Configuration configuration
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

public class Abs extends UnaryScalarFunction {
@FunctionInfo(returnType = { "double", "integer", "long", "unsigned_long" }, description = "Returns the absolute value.")
public Abs(Source source, @Param(name = "n", type = { "double", "integer", "long", "unsigned_long" }) Expression n) {
public Abs(Source source, @Param(name = "number", type = { "double", "integer", "long", "unsigned_long" }) Expression n) {
super(source, n);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public class Acos extends AbstractTrigonometricFunction {
@FunctionInfo(returnType = "double", description = "The arccosine of an angle, expressed in radians.")
public Acos(
Source source,
@Param(name = "n", type = { "double", "integer", "long", "unsigned_long" }, description = "Number between -1 and 1") Expression n
@Param(
name = "number",
type = { "double", "integer", "long", "unsigned_long" },
description = "Number between -1 and 1"
) Expression n
) {
super(source, n);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public class Asin extends AbstractTrigonometricFunction {
@FunctionInfo(returnType = "double", description = "Inverse sine trigonometric function.")
public Asin(
Source source,
@Param(name = "n", type = { "double", "integer", "long", "unsigned_long" }, description = "Number between -1 and 1") Expression n
@Param(
name = "number",
type = { "double", "integer", "long", "unsigned_long" },
description = "Number between -1 and 1"
) Expression n
) {
super(source, n);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Atan extends AbstractTrigonometricFunction {
@FunctionInfo(returnType = "double", description = "Inverse tangent trigonometric function.")
public Atan(
Source source,
@Param(name = "n", type = { "double", "integer", "long", "unsigned_long" }, description = "A number") Expression n
@Param(name = "number", type = { "double", "integer", "long", "unsigned_long" }, description = "A number") Expression n
) {
super(source, n);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public class Atan2 extends EsqlScalarFunction {
)
public Atan2(
Source source,
@Param(name = "y", type = { "double", "integer", "long", "unsigned_long" }, description = "y coordinate") Expression y,
@Param(name = "x", type = { "double", "integer", "long", "unsigned_long" }, description = "x coordinate") Expression x
@Param(name = "y_coordinate", type = { "double", "integer", "long", "unsigned_long" }, description = "y coordinate") Expression y,
@Param(name = "x_coordinate", type = { "double", "integer", "long", "unsigned_long" }, description = "x coordinate") Expression x
) {
super(source, List.of(y, x));
this.y = y;
Expand Down
Loading

0 comments on commit 5d05d81

Please sign in to comment.