Skip to content

Commit ddb40cd

Browse files
committed
improved tests
1 parent 9e78a73 commit ddb40cd

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/ChickenScoreFunctionIT.java

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ public void testSimpleWhereMatch() {
3737
try (var resp = run(query)) {
3838
assertColumnNames(resp.columns(), List.of("id", "_score"));
3939
assertColumnTypes(resp.columns(), List.of("integer", "double"));
40-
assertValues(resp.values(), List.of(List.of(1, 1.4274532794952393), List.of(6, 1.1248724460601807)));
40+
assertValues(resp.values(), List.of(
41+
List.of(1, 1.4274532794952393),
42+
List.of(6, 1.1248724460601807))
43+
);
4144
}
4245
}
4346

44-
public void testSimpleChickenScoreWithWhereMatch() {
47+
public void testSimpleChickenScoreWhereMatch() {
4548
var query = """
4649
FROM test METADATA _score
4750
| EVAL first_score = chicken_score(match(content, "brown"))
@@ -55,14 +58,18 @@ public void testSimpleChickenScoreWithWhereMatch() {
5558
assertColumnTypes(resp.columns(), List.of("integer", "double", "double"));
5659
assertValues(
5760
resp.values(),
58-
List.of(List.of(1, 1.156558871269226, 0.2708943784236908), List.of(6, 0.9114001989364624, 0.21347221732139587))
61+
List.of(
62+
List.of(1, 1.156558871269226, 0.2708943784236908),
63+
List.of(6, 0.9114001989364624, 0.21347221732139587))
5964
);
6065
}
6166
}
6267

63-
public void testSimpleChickenScoreAlone() {
68+
public void testChickenScorePlusWhereMatch() {
6469
var query = """
6570
FROM test METADATA _score
71+
| WHERE match(content, "brown")
72+
| WHERE match(content, "fox")
6673
| EVAL first_score = chicken_score(match(content, "brown"))
6774
| KEEP id, _score, first_score
6875
| SORT id
@@ -71,25 +78,17 @@ public void testSimpleChickenScoreAlone() {
7178
try (var resp = run(query)) {
7279
assertColumnNames(resp.columns(), List.of("id", "_score", "first_score"));
7380
assertColumnTypes(resp.columns(), List.of("integer", "double", "double"));
74-
assertValues(
75-
resp.values(),
76-
List.of(
77-
List.of(1, 0.0, 0.2708943784236908),
78-
List.of(2, 0.0, 0.2708943784236908),
79-
List.of(3, 0.0, 0.2708943784236908),
80-
List.of(4, 0.0, 0.19301524758338928),
81-
List.of(5, 0.0, 0.0),
82-
List.of(6, 0.0, 0.21347221732139587)
83-
)
81+
assertValues(resp.values(), List.of(
82+
List.of(1, 1.4274532794952393, 0.2708943784236908),
83+
List.of(6, 1.1248724460601807, 0.21347221732139587))
8484
);
8585
}
8686
}
8787

88-
public void testSimpleMatchScoreCopy() {
88+
public void testSimpleChickenScoreAlone() {
8989
var query = """
9090
FROM test METADATA _score
91-
| WHERE match(content, "fox")
92-
| EVAL first_score = _score
91+
| EVAL first_score = chicken_score(match(content, "brown"))
9392
| KEEP id, _score, first_score
9493
| SORT id
9594
""";
@@ -99,7 +98,14 @@ public void testSimpleMatchScoreCopy() {
9998
assertColumnTypes(resp.columns(), List.of("integer", "double", "double"));
10099
assertValues(
101100
resp.values(),
102-
List.of(List.of(1, 1.156558871269226, 1.156558871269226), List.of(6, 0.9114001989364624, 0.9114001989364624))
101+
List.of(
102+
List.of(1, 0.0, 0.2708943784236908),
103+
List.of(2, 0.0, 0.2708943784236908),
104+
List.of(3, 0.0, 0.2708943784236908),
105+
List.of(4, 0.0, 0.19301524758338928),
106+
List.of(5, 0.0, 0.0),
107+
List.of(6, 0.0, 0.21347221732139587)
108+
)
103109
);
104110
}
105111
}
@@ -116,7 +122,9 @@ public void testSimpleEvalScoreWithWhereMatch() {
116122
try (var resp = run(query)) {
117123
assertColumnNames(resp.columns(), List.of("id", "_score", "first_score"));
118124
assertColumnTypes(resp.columns(), List.of("integer", "double", "boolean"));
119-
assertValues(resp.values(), List.of(List.of(1, 1.156558871269226, true), List.of(6, 0.9114001989364624, true)));
125+
assertValues(resp.values(), List.of(
126+
List.of(1, 1.156558871269226, true),
127+
List.of(6, 0.9114001989364624, true)));
120128
}
121129
}
122130

0 commit comments

Comments
 (0)