Skip to content

Commit 7bd0724

Browse files
committed
Revert "test(native): Add scalar function tests to native-tests (#26013)"
This reverts commit e3fa9d8.
1 parent 2b7ccc8 commit 7bd0724

File tree

21 files changed

+78
-588
lines changed

21 files changed

+78
-588
lines changed

pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@
161161
<module>presto-client</module>
162162
<module>presto-parser</module>
163163
<module>presto-main-base</module>
164-
<module>presto-main-tests</module>
165164
<module>presto-main</module>
166165
<module>presto-built-in-worker-function-tools</module>
167166
<module>presto-ml</module>
@@ -848,12 +847,6 @@
848847
<version>${project.version}</version>
849848
</dependency>
850849

851-
<dependency>
852-
<groupId>com.facebook.presto</groupId>
853-
<artifactId>presto-main-tests</artifactId>
854-
<version>${project.version}</version>
855-
</dependency>
856-
857850
<dependency>
858851
<groupId>com.facebook.presto</groupId>
859852
<artifactId>presto-built-in-worker-function-tools</artifactId>

presto-hive/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,6 @@
372372
<scope>test</scope>
373373
</dependency>
374374

375-
<dependency>
376-
<groupId>com.facebook.presto</groupId>
377-
<artifactId>presto-main-tests</artifactId>
378-
<scope>test</scope>
379-
</dependency>
380-
381375
<dependency>
382376
<groupId>com.facebook.presto</groupId>
383377
<artifactId>presto-hive-metastore</artifactId>

presto-i18n-functions/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,6 @@
9090
<type>test-jar</type>
9191
<scope>test</scope>
9292
</dependency>
93-
94-
<dependency>
95-
<groupId>com.facebook.presto</groupId>
96-
<artifactId>presto-main-tests</artifactId>
97-
<scope>test</scope>
98-
</dependency>
9993
</dependencies>
10094

10195
<build>

presto-iceberg/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,6 @@
581581
<artifactId>presto-main-base</artifactId>
582582
<scope>test</scope>
583583
</dependency>
584-
<dependency>
585-
<groupId>com.facebook.presto</groupId>
586-
<artifactId>presto-main-tests</artifactId>
587-
<scope>test</scope>
588-
</dependency>
589584
<dependency>
590585
<groupId>com.facebook.presto</groupId>
591586
<artifactId>presto-main</artifactId>

presto-main-base/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@
8484
<artifactId>presto-expressions</artifactId>
8585
</dependency>
8686

87-
<dependency>
88-
<groupId>com.facebook.presto</groupId>
89-
<artifactId>presto-main-tests</artifactId>
90-
<scope>test</scope>
91-
</dependency>
92-
9387
<dependency>
9488
<groupId>com.facebook.airlift</groupId>
9589
<artifactId>bootstrap</artifactId>

presto-main-base/src/test/java/com/facebook/presto/operator/scalar/AbstractTestFunctions.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.facebook.presto.sql.analyzer.FeaturesConfig;
3131
import com.facebook.presto.sql.analyzer.FunctionsConfig;
3232
import com.facebook.presto.sql.analyzer.SemanticErrorCode;
33-
import com.facebook.presto.tests.operator.scalar.TestFunctions;
3433
import com.google.common.collect.ImmutableList;
3534
import io.airlift.slice.Slice;
3635
import org.intellij.lang.annotations.Language;
@@ -53,7 +52,6 @@
5352
import static org.testng.Assert.fail;
5453

5554
public abstract class AbstractTestFunctions
56-
implements TestFunctions
5755
{
5856
private static final double DELTA = 1e-5;
5957

@@ -115,8 +113,7 @@ public FunctionAndTypeManager getFunctionAndTypeManager()
115113
return functionAssertions.getFunctionAndTypeManager();
116114
}
117115

118-
@Override
119-
public void assertFunction(String projection, Type expectedType, Object expected)
116+
protected void assertFunction(String projection, Type expectedType, Object expected)
120117
{
121118
functionAssertions.assertFunction(projection, expectedType, expected);
122119
}
@@ -218,8 +215,7 @@ public void assertCachedInstanceHasBoundedRetainedSize(String projection)
218215
functionAssertions.assertCachedInstanceHasBoundedRetainedSize(projection);
219216
}
220217

221-
@Override
222-
public void assertNotSupported(String projection, String message)
218+
protected void assertNotSupported(String projection, String message)
223219
{
224220
try {
225221
functionAssertions.executeProjectionWithFullEngine(projection);

presto-main-base/src/test/java/com/facebook/presto/operator/scalar/TestArrayExceptFunction.java

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,35 @@
1414
package com.facebook.presto.operator.scalar;
1515

1616
import com.facebook.presto.common.type.ArrayType;
17-
import com.facebook.presto.tests.operator.scalar.AbstractTestArrayExcept;
17+
import com.facebook.presto.common.type.RowType;
1818
import com.google.common.collect.ImmutableList;
1919
import org.testng.annotations.Test;
2020

21+
import static com.facebook.presto.common.type.BigintType.BIGINT;
22+
import static com.facebook.presto.common.type.BooleanType.BOOLEAN;
23+
import static com.facebook.presto.common.type.DoubleType.DOUBLE;
2124
import static com.facebook.presto.common.type.IntegerType.INTEGER;
2225
import static com.facebook.presto.common.type.UnknownType.UNKNOWN;
2326
import static com.facebook.presto.common.type.VarcharType.VARCHAR;
27+
import static com.facebook.presto.common.type.VarcharType.createVarcharType;
28+
import static java.util.Arrays.asList;
2429
import static java.util.Collections.singletonList;
2530

2631
public class TestArrayExceptFunction
2732
extends AbstractTestFunctions
28-
implements AbstractTestArrayExcept
2933
{
3034
@Test
31-
void testEmpty()
35+
public void testBasic()
36+
{
37+
assertFunction("array_except(ARRAY[1, 5, 3], ARRAY[3])", new ArrayType(INTEGER), ImmutableList.of(1, 5));
38+
assertFunction("array_except(ARRAY[CAST(1 as BIGINT), 5, 3], ARRAY[5])", new ArrayType(BIGINT), ImmutableList.of(1L, 3L));
39+
assertFunction("array_except(ARRAY[CAST('x' as VARCHAR), 'y', 'z'], ARRAY['x'])", new ArrayType(VARCHAR), ImmutableList.of("y", "z"));
40+
assertFunction("array_except(ARRAY[true, false, null], ARRAY[true])", new ArrayType(BOOLEAN), asList(false, null));
41+
assertFunction("array_except(ARRAY[1.1E0, 5.4E0, 3.9E0], ARRAY[5, 5.4E0])", new ArrayType(DOUBLE), ImmutableList.of(1.1, 3.9));
42+
}
43+
44+
@Test
45+
public void testEmpty()
3246
{
3347
assertFunction("array_except(ARRAY[], ARRAY[])", new ArrayType(UNKNOWN), ImmutableList.of());
3448
assertFunction("array_except(ARRAY[], ARRAY[1, 3])", new ArrayType(INTEGER), ImmutableList.of());
@@ -45,4 +59,40 @@ public void testNull()
4559
assertFunction("array_except(ARRAY[], ARRAY[NULL])", new ArrayType(UNKNOWN), ImmutableList.of());
4660
assertFunction("array_except(ARRAY[NULL], ARRAY[])", new ArrayType(UNKNOWN), singletonList(null));
4761
}
62+
63+
@Test
64+
public void testDuplicates()
65+
{
66+
assertFunction("array_except(ARRAY[1, 5, 3, 5, 1], ARRAY[3])", new ArrayType(INTEGER), ImmutableList.of(1, 5));
67+
assertFunction("array_except(ARRAY[CAST(1 as BIGINT), 5, 5, 3, 3, 3, 1], ARRAY[3, 5])", new ArrayType(BIGINT), ImmutableList.of(1L));
68+
assertFunction("array_except(ARRAY[CAST('x' as VARCHAR), 'x', 'y', 'z'], ARRAY['x', 'y', 'x'])", new ArrayType(VARCHAR), ImmutableList.of("z"));
69+
assertFunction("array_except(ARRAY[true, false, null, true, false, null], ARRAY[true, true, true])", new ArrayType(BOOLEAN), asList(false, null));
70+
}
71+
72+
@Test
73+
public void testIndeterminateRows()
74+
{
75+
// test unsupported
76+
assertFunction(
77+
"array_except(ARRAY[(123, 'abc'), (123, NULL)], ARRAY[(123, 'abc'), (123, NULL)])",
78+
new ArrayType(RowType.anonymous(ImmutableList.of(INTEGER, createVarcharType(3)))),
79+
ImmutableList.of());
80+
assertFunction(
81+
"array_except(ARRAY[(NULL, 'abc'), (123, null), (123, 'abc')], ARRAY[(456, 'def'),(NULL, 'abc')])",
82+
new ArrayType(RowType.anonymous(ImmutableList.of(INTEGER, createVarcharType(3)))),
83+
ImmutableList.of(asList(123, null), asList(123, "abc")));
84+
}
85+
86+
@Test
87+
public void testIndeterminateArrays()
88+
{
89+
assertFunction(
90+
"array_except(ARRAY[ARRAY[123, 456], ARRAY[123, NULL]], ARRAY[ARRAY[123, 456], ARRAY[123, NULL]])",
91+
new ArrayType(new ArrayType(INTEGER)),
92+
ImmutableList.of());
93+
assertFunction(
94+
"array_except(ARRAY[ARRAY[NULL, 456], ARRAY[123, null], ARRAY[123, 456]], ARRAY[ARRAY[456, 456],ARRAY[NULL, 456]])",
95+
new ArrayType(new ArrayType(INTEGER)),
96+
ImmutableList.of(asList(123, null), asList(123, 456)));
97+
}
4898
}

presto-main-base/src/test/java/com/facebook/presto/operator/scalar/TestArraySortFunction.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,30 @@
1313
*/
1414
package com.facebook.presto.operator.scalar;
1515

16-
import com.facebook.presto.tests.operator.scalar.AbstractTestArraySort;
16+
import com.facebook.presto.common.type.ArrayType;
17+
import com.google.common.collect.ImmutableList;
18+
import org.testng.annotations.Test;
19+
20+
import static com.facebook.presto.common.type.BigintType.BIGINT;
21+
import static com.facebook.presto.common.type.IntegerType.INTEGER;
22+
import static com.facebook.presto.common.type.VarcharType.createVarcharType;
23+
import static java.util.Arrays.asList;
1724

1825
public class TestArraySortFunction
1926
extends AbstractTestFunctions
20-
implements AbstractTestArraySort
2127
{
28+
@Test
29+
public void testArraySort()
30+
{
31+
assertFunction("array_sort(ARRAY [5, 20, null, 5, 3, 50]) ", new ArrayType(INTEGER),
32+
asList(3, 5, 5, 20, 50, null));
33+
assertFunction("array_sort(array['x', 'a', 'a', 'a', 'a', 'm', 'j', 'p'])",
34+
new ArrayType(createVarcharType(1)), ImmutableList.of("a", "a", "a", "a", "j", "m", "p", "x"));
35+
assertFunction("array_sort(sequence(-4, 3))", new ArrayType(BIGINT),
36+
asList(-4L, -3L, -2L, -1L, 0L, 1L, 2L, 3L));
37+
assertFunction("array_sort(reverse(sequence(-4, 3)))", new ArrayType(BIGINT),
38+
asList(-4L, -3L, -2L, -1L, 0L, 1L, 2L, 3L));
39+
assertFunction("repeat(1,4)", new ArrayType(INTEGER), asList(1, 1, 1, 1));
40+
assertFunction("cast(array[] as array<int>)", new ArrayType(INTEGER), asList());
41+
}
2242
}

presto-main-tests/pom.xml

Lines changed: 0 additions & 91 deletions
This file was deleted.

presto-main-tests/src/main/java/com/facebook/presto/tests/operator/scalar/AbstractTestArrayExcept.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)