-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This applies that pattern from #119678 to the `convert` tests. It doesn't buy us any speed, sadly. This is because conversions are *unary* and we rarely get much bonus from unary functions for this. Still, we do marginally reduce the number of test cases which is good for gradle: ``` 13862 -> 11948 (14%) ```
- Loading branch information
Showing
43 changed files
with
826 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...org/elasticsearch/xpack/esql/expression/function/scalar/convert/FromBase64ErrorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.expression.function.scalar.convert; | ||
|
||
import org.elasticsearch.xpack.esql.core.expression.Expression; | ||
import org.elasticsearch.xpack.esql.core.tree.Source; | ||
import org.elasticsearch.xpack.esql.core.type.DataType; | ||
import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase; | ||
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; | ||
import org.hamcrest.Matcher; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class FromBase64ErrorTests extends ErrorsForCasesWithoutExamplesTestCase { | ||
@Override | ||
protected List<TestCaseSupplier> cases() { | ||
return paramsToSuppliers(FromBase64Tests.parameters()); | ||
} | ||
|
||
@Override | ||
protected Expression build(Source source, List<Expression> args) { | ||
return new FromBase64(source, args.get(0)); | ||
} | ||
|
||
@Override | ||
protected Matcher<String> expectedTypeErrorMatcher(List<Set<DataType>> validPerPosition, List<DataType> signature) { | ||
return equalTo(typeErrorMessage(false, validPerPosition, signature, (v, p) -> "string")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...a/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBase64ErrorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.expression.function.scalar.convert; | ||
|
||
import org.elasticsearch.xpack.esql.core.expression.Expression; | ||
import org.elasticsearch.xpack.esql.core.tree.Source; | ||
import org.elasticsearch.xpack.esql.core.type.DataType; | ||
import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase; | ||
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; | ||
import org.hamcrest.Matcher; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class ToBase64ErrorTests extends ErrorsForCasesWithoutExamplesTestCase { | ||
@Override | ||
protected List<TestCaseSupplier> cases() { | ||
return paramsToSuppliers(ToBase64Tests.parameters()); | ||
} | ||
|
||
@Override | ||
protected Expression build(Source source, List<Expression> args) { | ||
return new ToBase64(source, args.get(0)); | ||
} | ||
|
||
@Override | ||
protected Matcher<String> expectedTypeErrorMatcher(List<Set<DataType>> validPerPosition, List<DataType> signature) { | ||
return equalTo(typeErrorMessage(false, validPerPosition, signature, (v, p) -> "string")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
.../org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanErrorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.expression.function.scalar.convert; | ||
|
||
import org.elasticsearch.xpack.esql.core.expression.Expression; | ||
import org.elasticsearch.xpack.esql.core.tree.Source; | ||
import org.elasticsearch.xpack.esql.core.type.DataType; | ||
import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase; | ||
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; | ||
import org.hamcrest.Matcher; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class ToBooleanErrorTests extends ErrorsForCasesWithoutExamplesTestCase { | ||
@Override | ||
protected List<TestCaseSupplier> cases() { | ||
return paramsToSuppliers(ToBooleanTests.parameters()); | ||
} | ||
|
||
@Override | ||
protected Expression build(Source source, List<Expression> args) { | ||
return new ToBoolean(source, args.get(0)); | ||
} | ||
|
||
@Override | ||
protected Matcher<String> expectedTypeErrorMatcher(List<Set<DataType>> validPerPosition, List<DataType> signature) { | ||
return equalTo(typeErrorMessage(false, validPerPosition, signature, (v, p) -> "boolean or numeric or string")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...asticsearch/xpack/esql/expression/function/scalar/convert/ToCartesianPointErrorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.expression.function.scalar.convert; | ||
|
||
import org.elasticsearch.xpack.esql.core.expression.Expression; | ||
import org.elasticsearch.xpack.esql.core.tree.Source; | ||
import org.elasticsearch.xpack.esql.core.type.DataType; | ||
import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase; | ||
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; | ||
import org.hamcrest.Matcher; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class ToCartesianPointErrorTests extends ErrorsForCasesWithoutExamplesTestCase { | ||
@Override | ||
protected List<TestCaseSupplier> cases() { | ||
return paramsToSuppliers(ToCartesianPointTests.parameters()); | ||
} | ||
|
||
@Override | ||
protected Expression build(Source source, List<Expression> args) { | ||
return new ToCartesianPoint(source, args.get(0)); | ||
} | ||
|
||
@Override | ||
protected Matcher<String> expectedTypeErrorMatcher(List<Set<DataType>> validPerPosition, List<DataType> signature) { | ||
return equalTo(typeErrorMessage(false, validPerPosition, signature, (v, p) -> "cartesian_point or string")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...asticsearch/xpack/esql/expression/function/scalar/convert/ToCartesianShapeErrorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.expression.function.scalar.convert; | ||
|
||
import org.elasticsearch.xpack.esql.core.expression.Expression; | ||
import org.elasticsearch.xpack.esql.core.tree.Source; | ||
import org.elasticsearch.xpack.esql.core.type.DataType; | ||
import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase; | ||
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; | ||
import org.hamcrest.Matcher; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class ToCartesianShapeErrorTests extends ErrorsForCasesWithoutExamplesTestCase { | ||
@Override | ||
protected List<TestCaseSupplier> cases() { | ||
return paramsToSuppliers(ToCartesianShapeTests.parameters()); | ||
} | ||
|
||
@Override | ||
protected Expression build(Source source, List<Expression> args) { | ||
return new ToCartesianShape(source, args.get(0)); | ||
} | ||
|
||
@Override | ||
protected Matcher<String> expectedTypeErrorMatcher(List<Set<DataType>> validPerPosition, List<DataType> signature) { | ||
return equalTo(typeErrorMessage(false, validPerPosition, signature, (v, p) -> "cartesian_point or cartesian_shape or string")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...rg/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDateNanosErrorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.expression.function.scalar.convert; | ||
|
||
import org.elasticsearch.xpack.esql.core.expression.Expression; | ||
import org.elasticsearch.xpack.esql.core.tree.Source; | ||
import org.elasticsearch.xpack.esql.core.type.DataType; | ||
import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase; | ||
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; | ||
import org.hamcrest.Matcher; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class ToDateNanosErrorTests extends ErrorsForCasesWithoutExamplesTestCase { | ||
@Override | ||
protected List<TestCaseSupplier> cases() { | ||
return paramsToSuppliers(ToDateNanosTests.parameters()); | ||
} | ||
|
||
@Override | ||
protected Expression build(Source source, List<Expression> args) { | ||
return new ToDateNanos(source, args.get(0)); | ||
} | ||
|
||
@Override | ||
protected Matcher<String> expectedTypeErrorMatcher(List<Set<DataType>> validPerPosition, List<DataType> signature) { | ||
return equalTo( | ||
typeErrorMessage( | ||
false, | ||
validPerPosition, | ||
signature, | ||
(v, p) -> "date_nanos or datetime or double or long or string or unsigned_long" | ||
) | ||
); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...icsearch/xpack/esql/expression/function/scalar/convert/ToDateNanosSerializationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.expression.function.scalar.convert; | ||
|
||
import org.elasticsearch.xpack.esql.core.expression.Expression; | ||
import org.elasticsearch.xpack.esql.core.tree.Source; | ||
import org.elasticsearch.xpack.esql.expression.AbstractUnaryScalarSerializationTests; | ||
|
||
public class ToDateNanosSerializationTests extends AbstractUnaryScalarSerializationTests<ToDateNanos> { | ||
@Override | ||
protected ToDateNanos create(Source source, Expression child) { | ||
return new ToDateNanos(source, child); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...g/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatePeriodErrorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.expression.function.scalar.convert; | ||
|
||
import org.elasticsearch.xpack.esql.core.expression.Expression; | ||
import org.elasticsearch.xpack.esql.core.tree.Source; | ||
import org.elasticsearch.xpack.esql.core.type.DataType; | ||
import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase; | ||
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; | ||
import org.hamcrest.Matcher; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class ToDatePeriodErrorTests extends ErrorsForCasesWithoutExamplesTestCase { | ||
@Override | ||
protected List<TestCaseSupplier> cases() { | ||
return paramsToSuppliers(ToDatePeriodTests.parameters()); | ||
} | ||
|
||
@Override | ||
protected Expression build(Source source, List<Expression> args) { | ||
return new ToDatePeriod(source, args.get(0)); | ||
} | ||
|
||
@Override | ||
protected Matcher<String> expectedTypeErrorMatcher(List<Set<DataType>> validPerPosition, List<DataType> signature) { | ||
return equalTo(typeErrorMessage(false, validPerPosition, signature, (v, p) -> "date_period or string")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.