Skip to content

Commit

Permalink
Fix CI failures
Browse files Browse the repository at this point in the history
  • Loading branch information
pdabre12 authored and Pratik Joseph Dabre committed Nov 21, 2024
1 parent 06a9335 commit e675df4
Showing 1 changed file with 38 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package com.facebook.presto.sidecar.functionNamespace;

import com.facebook.presto.Session;
import com.facebook.presto.nativeworker.PrestoNativeQueryRunnerUtils;
import com.facebook.presto.testing.MaterializedResult;
import com.facebook.presto.testing.MaterializedRow;
Expand All @@ -25,10 +26,6 @@
import java.util.List;
import java.util.regex.Pattern;

import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.createLineitem;
import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.createNation;
import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.createOrders;
import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.createOrdersEx;
import static com.facebook.presto.sidecar.NativeSidecarPluginQueryRunnerUtils.setupNativeSidecarPlugin;
import static java.lang.String.format;
import static org.testng.Assert.assertEquals;
Expand All @@ -39,16 +36,12 @@ public class TestNativeSidecarPluginFunctionNamespaceManager
extends AbstractTestQueryFramework
{
private static final String REGEX_FUNCTION_NAMESPACE = "native.default.*";
private static final int FUNCTION_COUNT = 1184;
private static final int FUNCTION_COUNT = 1199;

@Override
protected void createTables()
public Session getSession()
{
QueryRunner queryRunner = (QueryRunner) getExpectedQueryRunner();
createLineitem(queryRunner);
createNation(queryRunner);
createOrders(queryRunner);
createOrdersEx(queryRunner);
return Session.builder(super.getSession()).setCatalog("tpch").setSchema("tiny").build();
}

@Override
Expand Down Expand Up @@ -94,62 +87,67 @@ public void testShowFunctions()
@Test
public void testGeneralQueries()
{
assertQuery("SELECT substr(comment, 1, 10), length(comment), trim(comment) FROM orders");
assertQuery("SELECT substr(comment, 1, 10), length(comment), ltrim(comment) FROM orders");
assertQuery("SELECT substr(comment, 1, 10), length(comment), rtrim(comment) FROM orders");
assertQuery("select lower(comment) from nation");
assertQuery("SELECT trim(comment, ' ns'), ltrim(comment, 'a b c'), rtrim(comment, 'l y') FROM orders");
assertQuery("select array[nationkey], array_constructor(comment) from nation");
assertQuery("SELECT nationkey, bit_count(nationkey, 10) FROM nation ORDER BY 1");
assertQuery("SELECT * FROM lineitem WHERE shipinstruct like 'TAKE BACK%'");
assertQuery("SELECT * FROM lineitem WHERE shipinstruct like 'TAKE BACK#%' escape '#'");
Session session = getSession();
assertQuery(session, "SELECT substr(comment, 1, 10), length(comment), trim(comment) FROM orders");
assertQuery(session, "SELECT substr(comment, 1, 10), length(comment), ltrim(comment) FROM orders");
assertQuery(session, "SELECT substr(comment, 1, 10), length(comment), rtrim(comment) FROM orders");
assertQuery(session, "select lower(comment) from nation");
assertQuery(session, "SELECT trim(comment, ' ns'), ltrim(comment, 'a b c'), rtrim(comment, 'l y') FROM orders");
assertQuery(session, "select array[nationkey], array_constructor(comment) from nation");
assertQuery(session, "SELECT nationkey, bit_count(nationkey, 10) FROM nation ORDER BY 1");
assertQuery(session, "SELECT * FROM lineitem WHERE shipinstruct like 'TAKE BACK%'");
assertQuery(session, "SELECT * FROM lineitem WHERE shipinstruct like 'TAKE BACK#%' escape '#'");
}

@Test
public void testAggregateFunctions()
{
assertQuery("select corr(nation.nationkey, nation.nationkey) from nation");
assertQuery("select count(comment) from orders");
assertQuery("select count(*) from nation");
assertQuery("select count(abs(orderkey) between 1 and 60000) from orders group by orderkey");
assertQuery("SELECT count(orderkey) FROM orders WHERE orderkey < 0 GROUP BY GROUPING SETS (())");
Session session = getSession();
assertQuery(session, "select corr(nation.nationkey, nation.nationkey) from nation");
assertQuery(session, "select count(comment) from orders");
assertQuery(session, "select count(*) from nation");
assertQuery(session, "select count(abs(orderkey) between 1 and 60000) from orders group by orderkey");
assertQuery(session, "SELECT count(orderkey) FROM orders WHERE orderkey < 0 GROUP BY GROUPING SETS (())");
// tinyint
assertQuery("SELECT sum(cast(linenumber as tinyint)), sum(cast(linenumber as tinyint)) FROM lineitem");
assertQuery(session, "SELECT sum(cast(linenumber as tinyint)), sum(cast(linenumber as tinyint)) FROM lineitem");
// smallint
assertQuery("SELECT sum(cast(linenumber as smallint)), sum(cast(linenumber as smallint)) FROM lineitem");
assertQuery(session, "SELECT sum(cast(linenumber as smallint)), sum(cast(linenumber as smallint)) FROM lineitem");
// integer
assertQuery("SELECT sum(linenumber), sum(linenumber) FROM lineitem");
assertQuery(session, "SELECT sum(linenumber), sum(linenumber) FROM lineitem");
// bigint
assertQuery("SELECT sum(orderkey), sum(orderkey) FROM lineitem");
assertQuery(session, "SELECT sum(orderkey), sum(orderkey) FROM lineitem");
// real
assertQuery("SELECT sum(tax_as_real), sum(tax_as_real) FROM lineitem");
assertQuery(session, "SELECT sum(tax_as_real), sum(tax_as_real) FROM lineitem");
// double
assertQuery("SELECT sum(quantity), sum(quantity) FROM lineitem");
assertQuery("SELECT orderkey, array_sort(reduce_agg(linenumber, array[], (s, x) -> s || x, (s, s2) -> s || s2)) FROM lineitem GROUP BY orderkey");
assertQuery(session, "SELECT sum(quantity), sum(quantity) FROM lineitem");
assertQuery(session, "SELECT orderkey, array_sort(reduce_agg(linenumber, array[], (s, x) -> s || x, (s, s2) -> s || s2)) FROM lineitem GROUP BY orderkey");
}

@Test
public void testWindowFunctions()
{
assertQuery("SELECT * FROM (SELECT row_number() over(partition by orderstatus order by orderkey, orderstatus) rn, * from orders) WHERE rn = 1");
assertQuery("WITH t AS (SELECT linenumber, row_number() over (partition by linenumber order by linenumber) as rn FROM lineitem) SELECT * FROM t WHERE rn = 1");
assertQuery("SELECT row_number() OVER (PARTITION BY orderdate ORDER BY orderdate) FROM orders");
assertQuery("SELECT min(orderkey) OVER (PARTITION BY orderdate ORDER BY orderdate, totalprice) FROM orders");
assertQuery("SELECT sum(rn) FROM (SELECT row_number() over() rn, * from orders) WHERE rn = 10");
assertQuery("SELECT * FROM (SELECT row_number() over(partition by orderstatus order by orderkey) rn, * from orders) WHERE rn = 1");
Session session = getSession();
assertQuery(session, "SELECT * FROM (SELECT row_number() over(partition by orderstatus order by orderkey, orderstatus) rn, * from orders) WHERE rn = 1");
assertQuery(session, "WITH t AS (SELECT linenumber, row_number() over (partition by linenumber order by linenumber) as rn FROM lineitem) SELECT * FROM t WHERE rn = 1");
assertQuery(session, "SELECT row_number() OVER (PARTITION BY orderdate ORDER BY orderdate) FROM orders");
assertQuery(session, "SELECT min(orderkey) OVER (PARTITION BY orderdate ORDER BY orderdate, totalprice) FROM orders");
assertQuery(session, "SELECT sum(rn) FROM (SELECT row_number() over() rn, * from orders) WHERE rn = 10");
assertQuery(session, "SELECT * FROM (SELECT row_number() over(partition by orderstatus order by orderkey) rn, * from orders) WHERE rn = 1");
}

@Test
public void testArraySort()
{
assertQueryFails("SELECT array_sort(quantities, (x, y) -> if (x < y, 1, if (x > y, -1, 0))) FROM orders_ex",
Session session = getSession();
assertQueryFails(session, "SELECT array_sort(array_agg(quantity), (x, y) -> if (x < y, 1, if (x > y, -1, 0))) FROM lineitem",
"line 1:31: Expected a lambda that takes 1 argument\\(s\\) but got 2");
}

@Test
public void testInformationSchemaTables()
{
assertQueryFails("select lower(table_name) from information_schema.tables "
Session session = getSession();
assertQueryFails(session, "select lower(table_name) from information_schema.tables "
+ "where table_name = 'lineitem' or table_name = 'LINEITEM' ",
"Compiler failed");
}
Expand Down

0 comments on commit e675df4

Please sign in to comment.