@@ -0,0 +1,2409 @@
+/*%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage io.trino.sql.query;%0A%0Aimport org.testng.annotations.AfterClass;%0Aimport org.testng.annotations.BeforeClass;%0Aimport org.testng.annotations.Test;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0A%0Apublic class TestSetDigestFunctions%0A%7B%0A    private QueryAssertions assertions;%0A%0A    @BeforeClass%0A    public void init()%0A    %7B%0A        assertions = new QueryAssertions();%0A    %7D%0A%0A    @AfterClass(alwaysRun = true)%0A    public void teardown()%0A    %7B%0A        assertions.close();%0A        assertions = null;%0A    %7D%0A%0A    @Test%0A    public void testCardinality()%0A    %7B%0A        assertThat(assertions.query(%0A                %22SELECT cardinality(make_set_digest(value)) %22 +%0A                        %22FROM (VALUES 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5) T(value)%22))%0A                .matches(%22VALUES CAST(5 AS BIGINT)%22);%0A    %7D%0A%0A    @Test%0A    public void testExactIntersectionCardinality()%0A    %7B%0A        assertThat(assertions.query(%0A                %22SELECT intersection_cardinality(make_set_digest(v1), make_set_digest(v2)) %22 +%0A                        %22FROM (VALUES (1, 1), (NULL, 2), (2, 3), (3, 4)) T(v1, v2)%22))%0A                .matches(%22VALUES CAST(3 AS BIGINT)%22);%0A    %7D%0A%0A    @Test%0A    public void testJaccardIndex()%0A    %7B%0A        assertThat(assertions.query(%0A                %22SELECT jaccard_index(make_set_digest(v1), make_set_digest(v2)) %22 +%0A                        %22FROM (VALUES (1, 1), (NULL,2), (2, 3), (NULL, 4)) T(v1, v2)%22))%0A                .matches(%22VALUES CAST(0.5 AS DOUBLE)%22);%0A    %7D%0A%0A    @Test%0A    public void hashCounts()%0A    %7B%0A        assertThat(assertions.query(%0A                %22SELECT hash_counts(make_set_digest(value)) %22 +%0A                        %22FROM (VALUES 1, 1, 1, 2, 2) T(value)%22))%0A                .matches(%22VALUES map(cast(ARRAY%5B19144387141682250, -2447670524089286488%5D AS array(bigint)), cast(ARRAY%5B3, 2%5D AS array(smallint)))%22);%0A    %7D%0A%7D%0A

Add test for setdigest functions