diff --git a/presto-hive/src/test/java/com/facebook/presto/hive/TestHiveLogicalPlanner.java b/presto-hive/src/test/java/com/facebook/presto/hive/TestHiveLogicalPlanner.java index bf7f7ef948c0d..79c2fb970bf18 100644 --- a/presto-hive/src/test/java/com/facebook/presto/hive/TestHiveLogicalPlanner.java +++ b/presto-hive/src/test/java/com/facebook/presto/hive/TestHiveLogicalPlanner.java @@ -1230,20 +1230,7 @@ public void testPushDownSubfieldsFromLambdas() "am array(map(int,row(a1 bigint, a2 double))), " + "aa array(array(row(a1 bigint, a2 double))), " + "z array(array(row(p bigint, e row(e1 bigint, e2 varchar)))))"); - - // functions that are not outputting all subfields - // all_match - assertPushdownSubfields("SELECT ALL_MATCH(y, x -> x.a > 0) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - assertPushdownSubfields("SELECT ALL_MATCH(y, x -> true) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].$"))); - // any_match - assertPushdownSubfields("SELECT ANY_MATCH(y, x -> x.a > 0) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - // none_match - assertPushdownSubfields("SELECT NONE_MATCH(y, x -> x.d.d1 > 0) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].d.d1"))); - // transform + // transform assertPushdownSubfields("SELECT TRANSFORM(y, x -> x.d.d1) FROM " + tableName, tableName, ImmutableMap.of("y", toSubfields("y[*].d.d1"))); @@ -1251,45 +1238,10 @@ public void testPushDownSubfieldsFromLambdas() assertPushdownSubfields("SELECT MAP_ZIP_WITH(m1, m2, (k, v1, v2) -> v1.a1 + v2.a2) FROM " + tableName, tableName, ImmutableMap.of("m1", toSubfields("m1[*].a1"), "m2", toSubfields("m2[*].a2"))); - assertPushdownSubfields("SELECT ANY_MATCH(MAP_VALUES(MAP_ZIP_WITH(m1, m2, (k, v1, v2) -> CAST(ROW(v1.a1, v2.a2) AS ROW(a1 BIGINT, a2 DOUBLE)))), x -> x.a1 > 100) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].a1"), "m2", toSubfields("m2[*].a2"))); - // transform_values assertPushdownSubfields("SELECT TRANSFORM_VALUES(m1, (k, v) -> v.a1 * 1000) FROM " + tableName, tableName, ImmutableMap.of("m1", toSubfields("m1[*].a1"))); - assertPushdownSubfields("SELECT TRANSFORM_VALUES(MAP_FILTER(m1, (k,v) -> v.a2 > 100), (k, v) -> v.a1 * 1000) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].a1", "m1[*].a2"))); - - assertPushdownSubfields("SELECT MAP_FILTER(TRANSFORM_VALUES(m1, (k, v) -> CAST(ROW(v.a1 * 1000, v.a1) AS ROW(a1 BIGINT, a2 DOUBLE))), (k,v) -> v.a2 > 100) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].a1"))); - - // map_values - assertPushdownSubfields("SELECT ANY_MATCH(MAP_VALUES(m1), x -> x.a1 > 100) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].a1"))); - - // cardinality - assertPushdownSubfields("SELECT CARDINALITY(y) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].$"))); - - assertPushdownSubfields("SELECT CARDINALITY(FLATTEN(z)) FROM " + tableName, tableName, - ImmutableMap.of("z", toSubfields("z[*][*].$"))); - - assertPushdownSubfields("SELECT CARDINALITY(FILTER(y, x -> true)) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].$"))); - - assertPushdownSubfields("SELECT CARDINALITY(FILTER(y, x -> position('9' IN x.b) > 0)) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].b"))); - - assertPushdownSubfields("SELECT CARDINALITY(m1) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].$"))); - - assertPushdownSubfields("SELECT CARDINALITY(MAP_FILTER(m1, (k,v) -> v.a2 > 100)) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].a2"))); - - assertPushdownSubfields("SELECT CARDINALITY(MAP_FILTER(m1, (k,v) -> v.a1 > 100)) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].a1"))); - // transform assertPushdownSubfields("SELECT TRANSFORM(y, x -> ROW(x.a, x.d.d1)) FROM " + tableName, tableName, ImmutableMap.of("y", toSubfields("y[*].a", "y[*].d.d1"))); @@ -1307,49 +1259,10 @@ public void testPushDownSubfieldsFromLambdas() assertPushdownSubfields("SELECT FILTER(y, x -> x.a > 0) FROM " + tableName, tableName, ImmutableMap.of("y", toSubfields())); - assertPushdownSubfields("SELECT CARDINALITY(FILTER(y, x -> x.a > 0)) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - - // slice - assertPushdownSubfields("SELECT TRANSFORM(SLICE(y, 1, 5), x -> x.a) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - - //array_sort - assertPushdownSubfields("SELECT ARRAY_SORT(y, (l, r) -> IF(l.a < r.a, 1, IF(l.a = r.a, 0, -1))) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields())); - - assertPushdownSubfields("SELECT ANY_MATCH(SLICE(ARRAY_SORT(y, (l, r) -> IF(l.a < r.a, 1, IF(l.a = r.a, 0, -1))), 1, 3), x -> x.c > 0) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a", "y[*].c"))); - - assertPushdownSubfields("SELECT TRANSFORM(ARRAY_SORT(y), x -> x.a) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields())); // ARRAY_SORT(y) function accesses all the subfields as there is no lambda function provided. - - // combinations - assertPushdownSubfields("SELECT TRANSFORM(COMBINATIONS(y, 3), x -> x[1].a) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - - assertPushdownSubfields("SELECT TRANSFORM(FLATTEN(COMBINATIONS(y, 3)), x -> x.a) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - - assertPushdownSubfields("SELECT TRANSFORM(COMBINATIONS(FLATTEN(z), 3), x -> x[1].p) FROM " + tableName, tableName, - ImmutableMap.of("z", toSubfields("z[*][*].p"))); - // flatten assertPushdownSubfields("SELECT TRANSFORM(FLATTEN(z), x -> x.p) FROM " + tableName, tableName, ImmutableMap.of("z", toSubfields("z[*][*].p"))); - // reverse - assertPushdownSubfields("SELECT TRANSFORM(REVERSE(y), x -> x.a) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - - // shuffle - assertPushdownSubfields("SELECT TRANSFORM(SHUFFLE(y), x -> x.a) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - - // trim_array - assertPushdownSubfields("SELECT TRANSFORM(TRIM_ARRAY(y, 5), x -> x.a) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - // concat assertPushdownSubfields("SELECT TRANSFORM(y || yy, x -> x.d.d1) FROM " + tableName, tableName, ImmutableMap.of("y", toSubfields("y[*].d.d1"), "yy", toSubfields("yy[*].d.d1"))); @@ -1360,88 +1273,9 @@ public void testPushDownSubfieldsFromLambdas() assertPushdownSubfields("SELECT TRANSFORM(CONCAT(y, yy, yyy) , x -> x.d.d1) FROM " + tableName, tableName, ImmutableMap.of("y", toSubfields("y[*].d.d1"), "yy", toSubfields("yy[*].d.d1"), "yyy", toSubfields("yyy[*].d.d1"))); - // map_concat - assertPushdownSubfields("SELECT ANY_MATCH(MAP_VALUES(MAP_CONCAT(m1, m2, m3)), x -> x.a1 > 100) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].a1"), "m2", toSubfields("m2[*].a1"), "m3", toSubfields("m3[*].a1"))); - - // map - assertPushdownSubfields("SELECT ANY_MATCH(MAP_VALUES(MAP(a, y)), x -> x.a > 100) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - - assertPushdownSubfields("SELECT ANY_MATCH(MAP_VALUES(CAST(MAP() AS MAP(VARCHAR, ROW(a BIGINT)))), x -> x.a > 100) FROM " + tableName, tableName, - ImmutableMap.of()); - - // map_filter - assertPushdownSubfields("SELECT ANY_MATCH(MAP_VALUES(MAP_FILTER(m1, (k,v) -> v.a2 > 100)), x -> x.a1 > 100) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].a1", "m1[*].a2"))); - - assertPushdownSubfields("SELECT MAP_FILTER(m1, (k,v) -> v.a2 > 100) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields())); - - // map_remove_null_values - assertPushdownSubfields("SELECT ANY_MATCH(MAP_VALUES(MAP_REMOVE_NULL_VALUES(m1)), x -> x.a1 > 100) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].a1"))); - - // map_subset - assertPushdownSubfields("SELECT ANY_MATCH(MAP_VALUES(map_subset(m1, ARRAY[1,2,3])), x -> x.a1 > 100) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].a1"))); - - // map_top_n_values - assertPushdownSubfields("SELECT ANY_MATCH(MAP_TOP_N_VALUES(m1, 10, (x, y) -> IF(x.a1 < y.a1, -1, IF(x.a1 = y.a1, 0, 1))), x -> x.a2 > 100) FROM " + tableName, tableName, - ImmutableMap.of("m1", toSubfields("m1[*].a1", "m1[*].a2"))); - - // Simple test of different column type of the array argument - assertPushdownSubfields("SELECT ALL_MATCH(y, x -> x.d.d1 > 0) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].d.d1"))); - - assertPushdownSubfields("SELECT ANY_MATCH(r.a, x -> x.a1 > 0) FROM " + tableName, tableName, - ImmutableMap.of("r", toSubfields("r.a[*].a1"))); - - assertPushdownSubfields("SELECT ANY_MATCH(z[1], x -> x.e.e1 > 0) FROM " + tableName, tableName, - ImmutableMap.of("z", toSubfields("z[1][*].e.e1"))); - - assertPushdownSubfields("SELECT ANY_MATCH(mi[1], x -> x.a1 > 0) FROM " + tableName, tableName, - ImmutableMap.of("mi", toSubfields("mi[1][*].a1"))); - - assertPushdownSubfields("SELECT ANY_MATCH(mv['a'], x -> x.a1 > 0) FROM " + tableName, tableName, - ImmutableMap.of("mv", toSubfields("mv[\"a\"][*].a1"))); - - assertPushdownSubfields("SELECT ANY_MATCH(aa, x -> x[1].a1 > 0) FROM " + tableName, tableName, - ImmutableMap.of("aa", toSubfields("aa[*][1].a1"))); - - assertPushdownSubfields("SELECT ANY_MATCH(am, x -> x[1].a1 > 0) FROM " + tableName, tableName, - ImmutableMap.of("am", toSubfields("am[*][1].a1"))); - - // element_at - assertPushdownSubfields("SELECT ANY_MATCH(ELEMENT_AT(mi, 42), x -> x.a1 > 100) FROM " + tableName, tableName, - ImmutableMap.of("mi", toSubfields("mi[42][*].a1"))); - - assertPushdownSubfields("SELECT ANY_MATCH(ELEMENT_AT(mv, '42'), x -> x.a1 > 100) FROM " + tableName, tableName, - ImmutableMap.of("mv", toSubfields("mv[\"42\"][*].a1"))); - - // Queries that reference variables in different arguments - assertPushdownSubfields("SELECT ANY_MATCH(SLICE(y, 1, mv['42'][1].a1), x -> x.a > 100) FROM " + tableName, tableName, - ImmutableMap.of("mv", toSubfields("mv[\"42\"][1].a1"), "y", toSubfields("y[*].a"))); - - // Special form expressions that can hide the access to the entire struct ('and', 'or' are not interesting) - // equal - assertPushdownSubfields("SELECT ANY_MATCH(y, x -> x = (row(1, '', 1.0, row(1, 1.0)))) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields())); // 'equal' effectively accesses the entire struct of the element of 'y' - - // coalesce - assertPushdownSubfields("SELECT ANY_MATCH(ZIP_WITH(y, yy, (x, xx) -> COALESCE(x,xx)), x -> x.a > 0) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields(), "yy", toSubfields())); // - assertPushdownSubfields("SELECT TRANSFORM(y, x -> COALESCE(x, row(1, '', 1.0, row(1, 1.0)))) FROM " + tableName, tableName, ImmutableMap.of("y", toSubfields())); // 'coalesce' effectively includes the entire subfield to returned values - assertPushdownSubfields("SELECT ANY_MATCH(COALESCE(y, yy), x -> x.a > 0) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"), "yy", toSubfields("yy[*].a"))); - - // in - assertPushdownSubfields("SELECT ANY_MATCH(y, x -> x IN (row(1, '', 1.0, row(1, 1.0)))) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields())); // 'in' effectively accesses the entire struct of the element of 'y' - // row_construction assertPushdownSubfields("SELECT TRANSFORM(y, x -> ROW(x)) FROM " + tableName, tableName, ImmutableMap.of("y", toSubfields())); // entire struct of the element of 'y' was included to the output @@ -1456,78 +1290,6 @@ public void testPushDownSubfieldsFromLambdas() // if assertPushdownSubfields("SELECT TRANSFORM(y, x -> IF(x = row(1, '', 1.0, row(1, 1.0)), 1, 0)) FROM " + tableName, tableName, ImmutableMap.of("y", toSubfields())); // entire struct of the element of 'y' was accessed - - // is_null - assertPushdownSubfields("SELECT ANY_MATCH(y, x -> x IS NULL) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].$"))); // only checks whether entire struct is null and does not access struct subfields - - // bind - assertPushdownSubfields("SELECT ANY_MATCH(y, x -> x.a > mv['42'][1].a1) FROM " + tableName, tableName, // missing support for extracting subfields from BIND expression - ImmutableMap.of("mv", toSubfields("mv[\"42\"][1].a1"))); // In fact, we are accessing only y.a and mv['a'].[*].a1 - - // Queries that lack full support - - // Special form expression - // cast - assertPushdownSubfields("SELECT ANY_MATCH(TRANSFORM(r.a, x -> cast(x AS row(quantity bigint, price double))), x -> x.quantity > 100) FROM " + tableName, tableName, - ImmutableMap.of("r", toSubfields("r.a"))); // in fact, we are accessing only r.a[*].a1 - - // WHERE clause - // lambda subfield extraction from WHERE clause is not supported when hive.pushdown-filter-enabled=true. The entire field will be included in - // OrcSelectivePageSourceFactory by SubfieldExtractor in presto-hive module. - assertPushdownSubfields("SELECT a FROM " + tableName + " WHERE ALL_MATCH(y, x -> x.a > 0)", tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); // In fact, we are accessing only y[*].a. - - assertPushdownSubfields("SELECT TRANSFORM(y, x-> x.d.d1) FROM " + tableName + " WHERE ALL_MATCH(y, x -> x.a > 0)", tableName, - ImmutableMap.of("y", toSubfields("y[*].d.d1", "y[*].a"))); // In OrcSelectivePageSourceFactory, - // 'remainingPredicate' will contain 'ALL_MATCH(y, x -> x.a > 0)' and RequiredSubfieldsExtractor will extract the entire 'y' column that will lead to correct results - // though without any optimization - } - finally { - assertUpdate("DROP TABLE IF EXISTS " + tableName); - } - } - - @Test - public void testMergingSubfields() - { - final String tableName = "test_merging_subfields"; - try { - assertUpdate("CREATE TABLE " + tableName + "(id bigint, " + - "r row(a array(row(a1 bigint, a2 double)), i bigint, d row(d1 bigint, d2 double)), " + - "y array(row(a bigint, b varchar, c double, d row(d1 bigint, d2 double))))"); - - // NoSubfields - assertPushdownSubfields("SELECT CARDINALITY(y) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].$"))); - - assertPushdownSubfields("SELECT CARDINALITY(y), ALL_MATCH(y, x -> x.d.d1 > 0) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].d.d1"))); - - assertPushdownSubfields("SELECT CARDINALITY(y) FROM " + tableName + " WHERE ALL_MATCH(y, x -> x.d.d1 > 0)", tableName, - ImmutableMap.of("y", toSubfields("y[*].d.d1"))); - - assertPushdownSubfields("SELECT CARDINALITY(y), TRANSFORM(y, x -> x.a) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - - assertPushdownSubfields("SELECT TRANSFORM(y, x -> x.a), CARDINALITY(y) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - - assertPushdownSubfields("SELECT CARDINALITY(y), ALL_MATCH(y, x -> x.a > 0), TRANSFORM(y, x -> x.d.d1) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a", "y[*].d.d1"))); - - assertPushdownSubfields("SELECT ALL_MATCH(y, x -> x.a > 0) FROM " + tableName + " WHERE CARDINALITY(y) > 42", tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - - assertPushdownSubfields("SELECT TRANSFORM(y, x -> x.d), ALL_MATCH(y, x -> x.d.d1 > 0), CARDINALITY(y) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].d"))); - - assertPushdownSubfields("SELECT ALL_MATCH(y, x -> x.a > 0), CARDINALITY(y) FROM " + tableName, tableName, - ImmutableMap.of("y", toSubfields("y[*].a"))); - - // AllSubfields - assertPushdownSubfields("SELECT r.a[1].a1 FROM " + tableName + " WHERE CARDINALITY(r.a) > 42", tableName, - ImmutableMap.of("r", toSubfields("r.a[*].$", "r.a[1].a1"))); // File format reader will handle this situation and extract only r.a[*].a1 } finally { assertUpdate("DROP TABLE IF EXISTS " + tableName); diff --git a/presto-hive/src/test/java/com/facebook/presto/hive/TestLambdaSubfieldPruning.java b/presto-hive/src/test/java/com/facebook/presto/hive/TestLambdaSubfieldPruning.java index 19473ec5261f7..a0559b03b0302 100644 --- a/presto-hive/src/test/java/com/facebook/presto/hive/TestLambdaSubfieldPruning.java +++ b/presto-hive/src/test/java/com/facebook/presto/hive/TestLambdaSubfieldPruning.java @@ -146,16 +146,7 @@ public void testPushDownSubfieldsFromLambdas() private void testPushDownSubfieldsFromLambdas(String tableName) { - // functions that are not outputting all subfields - assertQuery("SELECT ALL_MATCH(array_of_rows, x -> x.itemdata > 0) FROM " + tableName); - assertQuery("SELECT ALL_MATCH(array_of_rows, x -> true) FROM " + tableName); - assertQuery("SELECT ALL_MATCH(array_of_rows, x -> x IS NULL) FROM " + tableName); - assertQuery("SELECT ANY_MATCH(array_of_rows, x -> x.itemdata > 0) FROM " + tableName); - assertQuery("SELECT NONE_MATCH(array_of_rows, x -> x.itemdata > 0) FROM " + tableName); assertQuery("SELECT TRANSFORM(array_of_rows, x -> x.itemdata > 0) FROM " + tableName); - assertQuery("SELECT CARDINALITY(array_of_rows) FROM " + tableName); - assertQuery("SELECT CARDINALITY(FLATTEN(array_of_array_of_rows)) FROM " + tableName); - assertQuery("SELECT CARDINALITY(FILTER(array_of_rows, x -> POSITION('T' IN x.comment) > 0)) FROM " + tableName); assertQuery("SELECT TRANSFORM(row_with_array_of_rows.array_of_rows, x -> CAST(ROW(x.comment, x.comment) AS ROW(d1 VARCHAR, d2 VARCHAR))) FROM " + tableName); assertQuery("SELECT TRANSFORM_VALUES(map_varchar_key_row_value, (k,v) -> v.orderkey) FROM " + tableName); assertQuery("SELECT ZIP_WITH(array_of_rows, row_with_array_of_rows.array_of_rows, (x, y) -> CAST(ROW(x.itemdata, y.comment) AS ROW(d1 BIGINT, d2 VARCHAR))) FROM " + tableName); @@ -163,38 +154,11 @@ private void testPushDownSubfieldsFromLambdas(String tableName) // functions that outputing all subfields and accept functional parameter assertQuery("SELECT FILTER(array_of_rows, x -> POSITION('T' IN x.comment) > 0) FROM " + tableName); - assertQuery("SELECT ARRAY_SORT(array_of_rows, (l, r) -> IF(l.itemdata < r.itemdata, 1, IF(l.itemdata = r.itemdata, 0, -1))) FROM " + tableName); - assertQuery("SELECT ANY_MATCH(SLICE(ARRAY_SORT(array_of_rows, (l, r) -> IF(l.itemdata < r.itemdata, 1, IF(l.itemdata = r.itemdata, 0, -1))), 1, 3), x -> x.itemdata > 0) FROM " + tableName); - assertQuery("SELECT TRANSFORM(ARRAY_SORT(array_of_non_null_rows), x -> x.itemdata) FROM " + tableName); - assertQuery("SELECT TRANSFORM(COMBINATIONS(array_of_non_null_rows, 3), x -> x[1].itemdata) FROM " + tableName); assertQuery("SELECT TRANSFORM(FLATTEN(array_of_array_of_rows), x -> x.itemdata) FROM " + tableName); - assertQuery("SELECT TRANSFORM(REVERSE(array_of_rows), x -> x.itemdata) FROM " + tableName); - assertQuery("SELECT ARRAY_SORT(TRANSFORM(SHUFFLE(array_of_non_null_rows), x -> x.itemdata)) FROM " + tableName); - assertQuery("SELECT TRANSFORM(SLICE(array_of_rows, 1, 5), x -> x.itemdata) FROM " + tableName); - assertQuery("SELECT TRANSFORM(TRIM_ARRAY(array_of_rows, 2), x -> x.itemdata) FROM " + tableName); assertQuery("SELECT TRANSFORM(CONCAT(array_of_rows, row_with_array_of_rows.array_of_rows), x -> x.itemdata) FROM " + tableName); assertQuery("SELECT TRANSFORM(array_of_rows || row_with_array_of_rows.array_of_rows, x -> x.itemdata) FROM " + tableName); assertQuery("SELECT TRANSFORM_VALUES(MAP_CONCAT(map_varchar_key_row_value, row_with_map_varchar_key_row_value.map_varchar_key_row_value), (k,v) -> v.orderkey) FROM " + tableName); assertQuery("SELECT TRANSFORM_VALUES(MAP_REMOVE_NULL_VALUES(row_with_map_varchar_key_row_value.map_varchar_key_row_value), (k,v) -> v.orderkey) FROM " + tableName); assertQuery("SELECT TRANSFORM_VALUES(MAP_SUBSET(row_with_map_varchar_key_row_value.map_varchar_key_row_value, ARRAY['orderdata_ex']), (k,v) -> v.orderkey) FROM " + tableName); - assertQuery("SELECT ANY_MATCH(MAP_VALUES(map_varchar_key_row_value), x -> x.orderkey % 2 = 0) FROM " + tableName); - assertQuery("SELECT ANY_MATCH(MAP_TOP_N_VALUES(map_varchar_key_row_value, 10, (x, y) -> IF(x.orderkey < y.orderkey, -1, IF(x.orderkey = y.orderkey, 0, 1))), x -> x.orderkey % 2 = 0) FROM " + tableName); - assertQuery("SELECT ANY_MATCH(MAP_VALUES(map_varchar_key_row_value), x -> x.orderkey % 2 = 0) FROM " + tableName); - - // Simple test of different column type of the array argument - assertQuery("SELECT ALL_MATCH(array_of_rows, x -> x.itemdata > 0) FROM " + tableName); - assertQuery("SELECT ALL_MATCH(row_with_array_of_rows.array_of_rows, x -> x.itemdata > 0) FROM " + tableName); - assertQuery("SELECT ALL_MATCH(array_of_array_of_rows[1], x -> x.itemdata > 0) FROM " + tableName); - assertQuery("SELECT ALL_MATCH(map_varchar_key_array_of_row_value['orderdata'], x -> x.orderkey > 0) FROM " + tableName); - - // element_at - assertQuery("SELECT ALL_MATCH(ELEMENT_AT(map_varchar_key_array_of_row_value, 'orderdata'), x -> x.orderkey > 0) FROM " + tableName); - assertQuery("SELECT ALL_MATCH(ELEMENT_AT(array_of_array_of_rows, 1), x -> x.itemdata > 0) FROM " + tableName); - - // Queries that reference variables in lambdas - assertQuery("SELECT ALL_MATCH(SLICE(array_of_rows, 1, row_with_array_of_rows.array_of_rows[1].itemdata), x -> x.itemdata > 0) FROM " + tableName); - assertQuery("SELECT ALL_MATCH(array_of_rows, x -> x.itemdata > row_with_array_of_rows.array_of_rows[1].itemdata) FROM " + tableName); - - // Queries that lack full support } } diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayAllMatchFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayAllMatchFunction.java index 98943e896e649..4bf8974a5f885 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayAllMatchFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayAllMatchFunction.java @@ -16,15 +16,10 @@ import com.facebook.presto.common.block.Block; import com.facebook.presto.common.type.StandardTypes; import com.facebook.presto.common.type.Type; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaArgumentDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaDescriptor; import com.facebook.presto.spi.function.SqlNullable; import com.facebook.presto.spi.function.SqlType; -import com.facebook.presto.spi.function.StaticMethodPointer; import com.facebook.presto.spi.function.TypeParameter; import com.facebook.presto.spi.function.TypeParameterSpecialization; import io.airlift.slice.Slice; @@ -32,15 +27,7 @@ import static java.lang.Boolean.FALSE; @Description("Returns true if all elements of the array match the given predicate") -@ScalarFunction(value = "all_match", descriptor = @ScalarFunctionDescriptor( - outputToInputTransformationFunction = {@StaticMethodPointer(clazz = ComplexTypeFunctionDescriptor.class, method = "clearRequiredSubfields")}, - lambdaDescriptors = { - @ScalarFunctionLambdaDescriptor( - callArgumentIndex = 1, - lambdaArgumentDescriptors = { - @ScalarFunctionLambdaArgumentDescriptor( - lambdaArgumentIndex = 0, - callArgumentIndex = 0)})})) +@ScalarFunction(value = "all_match") public final class ArrayAllMatchFunction { private ArrayAllMatchFunction() {} diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayAnyMatchFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayAnyMatchFunction.java index 1f5043a549fad..029c0caf9a325 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayAnyMatchFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayAnyMatchFunction.java @@ -16,15 +16,10 @@ import com.facebook.presto.common.block.Block; import com.facebook.presto.common.type.StandardTypes; import com.facebook.presto.common.type.Type; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaArgumentDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaDescriptor; import com.facebook.presto.spi.function.SqlNullable; import com.facebook.presto.spi.function.SqlType; -import com.facebook.presto.spi.function.StaticMethodPointer; import com.facebook.presto.spi.function.TypeParameter; import com.facebook.presto.spi.function.TypeParameterSpecialization; import io.airlift.slice.Slice; @@ -32,15 +27,7 @@ import static java.lang.Boolean.TRUE; @Description("Returns true if the array contains one or more elements that match the given predicate") -@ScalarFunction(value = "any_match", descriptor = @ScalarFunctionDescriptor( - outputToInputTransformationFunction = {@StaticMethodPointer(clazz = ComplexTypeFunctionDescriptor.class, method = "clearRequiredSubfields")}, - lambdaDescriptors = { - @ScalarFunctionLambdaDescriptor( - callArgumentIndex = 1, - lambdaArgumentDescriptors = { - @ScalarFunctionLambdaArgumentDescriptor( - lambdaArgumentIndex = 0, - callArgumentIndex = 0)})})) +@ScalarFunction(value = "any_match") public final class ArrayAnyMatchFunction { private ArrayAnyMatchFunction() {} diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayCardinalityFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayCardinalityFunction.java index 4865cf6721892..58baf6c0d475a 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayCardinalityFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayCardinalityFunction.java @@ -15,19 +15,13 @@ import com.facebook.presto.common.block.Block; import com.facebook.presto.common.type.StandardTypes; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; import com.facebook.presto.spi.function.SqlType; -import com.facebook.presto.spi.function.StaticMethodPointer; import com.facebook.presto.spi.function.TypeParameter; @Description("Returns the cardinality (length) of the array") -@ScalarFunction(value = "cardinality", descriptor = @ScalarFunctionDescriptor( - isAccessingInputValues = false, - outputToInputTransformationFunction = {@StaticMethodPointer(clazz = ComplexTypeFunctionDescriptor.class, method = "clearRequiredSubfields")}, - lambdaDescriptors = {})) +@ScalarFunction("cardinality") public final class ArrayCardinalityFunction { private ArrayCardinalityFunction() {} diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayCombinationsFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayCombinationsFunction.java index dc4a62aff07cb..bc2d442340c22 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayCombinationsFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayCombinationsFunction.java @@ -21,12 +21,9 @@ import com.facebook.presto.common.type.StandardTypes; import com.facebook.presto.common.type.Type; import com.facebook.presto.spi.PrestoException; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; import com.facebook.presto.spi.function.SqlType; -import com.facebook.presto.spi.function.StaticMethodPointer; import com.facebook.presto.spi.function.TypeParameter; import com.google.common.annotations.VisibleForTesting; @@ -42,10 +39,7 @@ import static java.util.Arrays.setAll; @Description("Returns n-element combinations from array") -@ScalarFunction(value = "combinations", descriptor = @ScalarFunctionDescriptor( - isAccessingInputValues = false, - outputToInputTransformationFunction = {@StaticMethodPointer(clazz = ComplexTypeFunctionDescriptor.class, method = "removeSecondPathElement")}, - lambdaDescriptors = {})) +@ScalarFunction("combinations") public final class ArrayCombinationsFunction { private ArrayCombinationsFunction() {} diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayFilterFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayFilterFunction.java index e229030203fb1..74495c2061138 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayFilterFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayFilterFunction.java @@ -18,9 +18,6 @@ import com.facebook.presto.common.type.Type; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaArgumentDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaDescriptor; import com.facebook.presto.spi.function.SqlType; import com.facebook.presto.spi.function.TypeParameter; import com.facebook.presto.spi.function.TypeParameterSpecialization; @@ -29,14 +26,7 @@ import static java.lang.Boolean.TRUE; @Description("return array containing elements that match the given predicate") -@ScalarFunction(value = "filter", deterministic = false, descriptor = @ScalarFunctionDescriptor( - lambdaDescriptors = { - @ScalarFunctionLambdaDescriptor( - callArgumentIndex = 1, - lambdaArgumentDescriptors = { - @ScalarFunctionLambdaArgumentDescriptor( - lambdaArgumentIndex = 0, - callArgumentIndex = 0)})})) +@ScalarFunction(value = "filter", deterministic = false) public final class ArrayFilterFunction { private ArrayFilterFunction() {} diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayNoneMatchFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayNoneMatchFunction.java index 6fe1d559cb29b..b3bcacd103a30 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayNoneMatchFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayNoneMatchFunction.java @@ -16,29 +16,16 @@ import com.facebook.presto.common.block.Block; import com.facebook.presto.common.type.StandardTypes; import com.facebook.presto.common.type.Type; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaArgumentDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaDescriptor; import com.facebook.presto.spi.function.SqlNullable; import com.facebook.presto.spi.function.SqlType; -import com.facebook.presto.spi.function.StaticMethodPointer; import com.facebook.presto.spi.function.TypeParameter; import com.facebook.presto.spi.function.TypeParameterSpecialization; import io.airlift.slice.Slice; @Description("Returns true if all elements of the array don't match the given predicate") -@ScalarFunction(value = "none_match", descriptor = @ScalarFunctionDescriptor( - outputToInputTransformationFunction = {@StaticMethodPointer(clazz = ComplexTypeFunctionDescriptor.class, method = "clearRequiredSubfields")}, - lambdaDescriptors = { - @ScalarFunctionLambdaDescriptor( - callArgumentIndex = 1, - lambdaArgumentDescriptors = { - @ScalarFunctionLambdaArgumentDescriptor( - lambdaArgumentIndex = 0, - callArgumentIndex = 0)})})) +@ScalarFunction(value = "none_match") public final class ArrayNoneMatchFunction { private ArrayNoneMatchFunction() {} diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayReverseFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayReverseFunction.java index 85653db745aa9..cc5555c227a99 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayReverseFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayReverseFunction.java @@ -18,12 +18,11 @@ import com.facebook.presto.common.type.Type; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; import com.facebook.presto.spi.function.SqlType; import com.facebook.presto.spi.function.TypeParameter; +@ScalarFunction("reverse") @Description("Returns an array which has the reversed order of the given array.") -@ScalarFunction(value = "reverse", descriptor = @ScalarFunctionDescriptor(isAccessingInputValues = false)) public final class ArrayReverseFunction { @TypeParameter("E") diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayShuffleFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayShuffleFunction.java index dff971c95a573..53da9ace28b53 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayShuffleFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayShuffleFunction.java @@ -18,14 +18,13 @@ import com.facebook.presto.common.type.Type; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; import com.facebook.presto.spi.function.SqlType; import com.facebook.presto.spi.function.TypeParameter; import java.util.concurrent.ThreadLocalRandom; +@ScalarFunction(value = "shuffle", deterministic = false) @Description("Generates a random permutation of the given array.") -@ScalarFunction(value = "shuffle", deterministic = false, descriptor = @ScalarFunctionDescriptor(isAccessingInputValues = false)) public final class ArrayShuffleFunction { private static final int INITIAL_LENGTH = 128; diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArraySliceFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArraySliceFunction.java index 8b645528a5f90..e37f7f0384b9a 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArraySliceFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArraySliceFunction.java @@ -19,14 +19,13 @@ import com.facebook.presto.common.type.Type; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; import com.facebook.presto.spi.function.SqlType; import com.facebook.presto.spi.function.TypeParameter; import static com.facebook.presto.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT; import static com.facebook.presto.util.Failures.checkCondition; -@ScalarFunction(value = "slice", descriptor = @ScalarFunctionDescriptor(isAccessingInputValues = false)) +@ScalarFunction("slice") @Description("Subsets an array given an offset (1-indexed) and length") public final class ArraySliceFunction { diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArraySortComparatorFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArraySortComparatorFunction.java index 0be7d15564201..6e986fa3d7f30 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArraySortComparatorFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArraySortComparatorFunction.java @@ -19,9 +19,6 @@ import com.facebook.presto.spi.PrestoException; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaArgumentDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaDescriptor; import com.facebook.presto.spi.function.SqlType; import com.facebook.presto.spi.function.TypeParameter; import com.facebook.presto.spi.function.TypeParameterSpecialization; @@ -35,17 +32,7 @@ import static com.facebook.presto.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT; import static com.facebook.presto.util.Failures.checkCondition; -@ScalarFunction(value = "array_sort", descriptor = @ScalarFunctionDescriptor( - lambdaDescriptors = { - @ScalarFunctionLambdaDescriptor( - callArgumentIndex = 1, - lambdaArgumentDescriptors = { - @ScalarFunctionLambdaArgumentDescriptor( - lambdaArgumentIndex = 0, - callArgumentIndex = 0), - @ScalarFunctionLambdaArgumentDescriptor( - lambdaArgumentIndex = 1, - callArgumentIndex = 0)})})) +@ScalarFunction("array_sort") @Description("Sorts the given array with a lambda comparator.") public final class ArraySortComparatorFunction { diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayTrimFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayTrimFunction.java index 12b8ffe4656e7..469b88f741afb 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayTrimFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ArrayTrimFunction.java @@ -18,7 +18,6 @@ import com.facebook.presto.common.type.Type; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; import com.facebook.presto.spi.function.SqlType; import com.facebook.presto.spi.function.TypeParameter; @@ -26,9 +25,7 @@ import static com.facebook.presto.util.Failures.checkCondition; import static java.lang.Math.toIntExact; -@ScalarFunction(value = "trim_array", descriptor = @ScalarFunctionDescriptor( - isAccessingInputValues = false, - lambdaDescriptors = {})) +@ScalarFunction("trim_array") @Description("Remove elements from the end of array") public final class ArrayTrimFunction { diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapCardinalityFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapCardinalityFunction.java index 4aaa4e167c553..bbe0b9d4c4e2a 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapCardinalityFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapCardinalityFunction.java @@ -15,18 +15,12 @@ import com.facebook.presto.common.block.Block; import com.facebook.presto.common.type.StandardTypes; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; import com.facebook.presto.spi.function.SqlType; -import com.facebook.presto.spi.function.StaticMethodPointer; import com.facebook.presto.spi.function.TypeParameter; -@ScalarFunction(value = "cardinality", descriptor = @ScalarFunctionDescriptor( - isAccessingInputValues = false, - outputToInputTransformationFunction = {@StaticMethodPointer(clazz = ComplexTypeFunctionDescriptor.class, method = "clearRequiredSubfields")}, - lambdaDescriptors = {})) +@ScalarFunction("cardinality") @Description("Returns the cardinality (the number of key-value pairs) of the map") public final class MapCardinalityFunction { diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapFilterFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapFilterFunction.java index ab5177bcd4765..b8c9bd7238c62 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapFilterFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapFilterFunction.java @@ -30,10 +30,6 @@ import com.facebook.presto.common.type.Type; import com.facebook.presto.spi.function.CodegenScalarFunction; import com.facebook.presto.spi.function.Description; -import com.facebook.presto.spi.function.IntArray; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaArgumentDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaDescriptor; import com.facebook.presto.spi.function.SqlType; import com.facebook.presto.spi.function.TypeParameter; import com.facebook.presto.sql.gen.SqlTypeBytecodeExpression; @@ -68,15 +64,7 @@ public final class MapFilterFunction { private MapFilterFunction() {} - @CodegenScalarFunction(value = "map_filter", deterministic = false, descriptor = @ScalarFunctionDescriptor( - argumentIndicesContainingMapOrArray = @IntArray(0), - lambdaDescriptors = { - @ScalarFunctionLambdaDescriptor( - callArgumentIndex = 1, - lambdaArgumentDescriptors = { - @ScalarFunctionLambdaArgumentDescriptor( - lambdaArgumentIndex = 1, - callArgumentIndex = 0)})})) + @CodegenScalarFunction(value = "map_filter", deterministic = false) @Description("return map containing entries that match the given predicate") @TypeParameter("K") @TypeParameter("V") diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapSubsetFunction.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapSubsetFunction.java index 8449715f48e46..abc360666d9e1 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapSubsetFunction.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapSubsetFunction.java @@ -1,4 +1,4 @@ - /* +/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,12 +19,9 @@ import com.facebook.presto.operator.aggregation.TypedSet; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; import com.facebook.presto.spi.function.SqlType; import com.facebook.presto.spi.function.TypeParameter; -@ScalarFunction(value = "map_subset", descriptor = @ScalarFunctionDescriptor( - isAccessingInputValues = false, - lambdaDescriptors = {})) +@ScalarFunction("map_subset") @Description("returns a map where the keys are a subset of the given array of keys") public final class MapSubsetFunction { diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapValues.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapValues.java index dc89acb0b2591..adca86b8d6df6 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapValues.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/MapValues.java @@ -18,12 +18,10 @@ import com.facebook.presto.common.type.Type; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.ScalarFunction; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; import com.facebook.presto.spi.function.SqlType; import com.facebook.presto.spi.function.TypeParameter; -@ScalarFunction(value = "map_values", descriptor = @ScalarFunctionDescriptor( - isAccessingInputValues = false)) +@ScalarFunction("map_values") @Description("Returns the values of the given map(K,V) as an array") public final class MapValues { diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ParametricScalar.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ParametricScalar.java index 7a836fbd2b3c3..3950c075e9fe4 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ParametricScalar.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ParametricScalar.java @@ -19,7 +19,6 @@ import com.facebook.presto.operator.ParametricImplementationsGroup; import com.facebook.presto.operator.scalar.annotations.ParametricScalarImplementation; import com.facebook.presto.spi.PrestoException; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; import com.facebook.presto.spi.function.Signature; import com.facebook.presto.spi.function.SqlFunctionVisibility; import com.google.common.annotations.VisibleForTesting; @@ -39,7 +38,6 @@ public class ParametricScalar { private final ScalarHeader details; private final ParametricImplementationsGroup implementations; - private final ComplexTypeFunctionDescriptor descriptor; public ParametricScalar( Signature signature, @@ -49,12 +47,6 @@ public ParametricScalar( super(signature); this.details = requireNonNull(details); this.implementations = requireNonNull(implementations); - this.descriptor = new ComplexTypeFunctionDescriptor( - details.getFunctionDescriptor().isAccessingInputValues(), - details.getFunctionDescriptor().getLambdaDescriptors(), - details.getFunctionDescriptor().getArgumentIndicesContainingMapOrArray(), - details.getFunctionDescriptor().getOutputToInputTransformationFunction(), - signature); } @Override @@ -122,10 +114,4 @@ public BuiltInScalarFunctionImplementation specialize(BoundVariables boundVariab throw new PrestoException(FUNCTION_IMPLEMENTATION_MISSING, format("Unsupported type parameters (%s) for %s", boundVariables, getSignature())); } - - @Override - public ComplexTypeFunctionDescriptor getComplexTypeFunctionDescriptor() - { - return descriptor; - } } diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ScalarHeader.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ScalarHeader.java index 8aa40cf3ff11a..b6b5e33fa6c00 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/ScalarHeader.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/ScalarHeader.java @@ -13,7 +13,6 @@ */ package com.facebook.presto.operator.scalar; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; import com.facebook.presto.spi.function.SqlFunctionVisibility; import java.util.Optional; @@ -24,15 +23,13 @@ public class ScalarHeader private final SqlFunctionVisibility visibility; private final boolean deterministic; private final boolean calledOnNullInput; - private final ComplexTypeFunctionDescriptor functionDescriptor; - public ScalarHeader(Optional description, SqlFunctionVisibility visibility, boolean deterministic, boolean calledOnNullInput, ComplexTypeFunctionDescriptor functionDescriptor) + public ScalarHeader(Optional description, SqlFunctionVisibility visibility, boolean deterministic, boolean calledOnNullInput) { this.description = description; this.visibility = visibility; this.deterministic = deterministic; this.calledOnNullInput = calledOnNullInput; - this.functionDescriptor = functionDescriptor; } public Optional getDescription() @@ -54,9 +51,4 @@ public boolean isCalledOnNullInput() { return calledOnNullInput; } - - public ComplexTypeFunctionDescriptor getFunctionDescriptor() - { - return functionDescriptor; - } } diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/CodegenScalarFromAnnotationsParser.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/CodegenScalarFromAnnotationsParser.java index 49804e1d440ae..f773497fd08bb 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/CodegenScalarFromAnnotationsParser.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/CodegenScalarFromAnnotationsParser.java @@ -25,7 +25,6 @@ import com.facebook.presto.spi.PrestoException; import com.facebook.presto.spi.function.BlockPosition; import com.facebook.presto.spi.function.CodegenScalarFunction; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.FunctionKind; import com.facebook.presto.spi.function.IsNull; @@ -57,7 +56,6 @@ import static com.facebook.presto.operator.scalar.ScalarFunctionImplementationChoice.ArgumentProperty.valueTypeArgumentProperty; import static com.facebook.presto.operator.scalar.ScalarFunctionImplementationChoice.NullConvention.RETURN_NULL_ON_NULL; import static com.facebook.presto.operator.scalar.ScalarFunctionImplementationChoice.NullConvention.USE_BOXED_TYPE; -import static com.facebook.presto.operator.scalar.annotations.FunctionDescriptorParser.parseFunctionDescriptor; import static com.facebook.presto.spi.StandardErrorCode.FUNCTION_IMPLEMENTATION_ERROR; import static com.facebook.presto.spi.function.Signature.withVariadicBound; import static com.facebook.presto.util.Failures.checkCondition; @@ -123,13 +121,8 @@ private static SqlScalarFunction createSqlScalarFunction(Method method) parseTypeSignature(method.getAnnotation(SqlType.class).value()), Arrays.stream(method.getParameters()).map(p -> parseTypeSignature(p.getAnnotation(SqlType.class).value())).collect(toImmutableList()), false); - ComplexTypeFunctionDescriptor functionDescriptor = parseFunctionDescriptor(codegenScalarFunction.descriptor()); - return new SqlScalarFunction(signature, new ComplexTypeFunctionDescriptor( - functionDescriptor.isAccessingInputValues(), - functionDescriptor.getLambdaDescriptors(), - functionDescriptor.getArgumentIndicesContainingMapOrArray(), - functionDescriptor.getOutputToInputTransformationFunction(), - signature)) + + return new SqlScalarFunction(signature) { @Override public BuiltInScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, FunctionAndTypeManager functionAndTypeManager) diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/FunctionDescriptorParser.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/FunctionDescriptorParser.java deleted file mode 100644 index ebf3ae125cc9e..0000000000000 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/FunctionDescriptorParser.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.operator.scalar.annotations; - -import com.facebook.presto.common.Subfield; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; -import com.facebook.presto.spi.function.LambdaArgumentDescriptor; -import com.facebook.presto.spi.function.LambdaDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaArgumentDescriptor; -import com.facebook.presto.spi.function.ScalarFunctionLambdaDescriptor; -import com.facebook.presto.spi.function.StaticMethodPointer; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.function.Function; - -import static com.google.common.base.Preconditions.checkArgument; - -public class FunctionDescriptorParser -{ - private FunctionDescriptorParser() {} - public static ComplexTypeFunctionDescriptor parseFunctionDescriptor(ScalarFunctionDescriptor descriptor) - { - if (descriptor.outputToInputTransformationFunction().length > 1) { - throw new IllegalArgumentException("outputToInputTransformationFunction must contain at most 1 element."); - } - return new ComplexTypeFunctionDescriptor( - descriptor.isAccessingInputValues(), - parseLambdaDescriptors(descriptor.lambdaDescriptors()), - descriptor.argumentIndicesContainingMapOrArray().length == 1 ? - Optional.of(ImmutableSet.copyOf(Arrays.stream(descriptor.argumentIndicesContainingMapOrArray()[0].value()).iterator())) : Optional.empty(), - descriptor.outputToInputTransformationFunction().length == 1 ? - Optional.of(parseSubfieldTransformationFunction(descriptor.outputToInputTransformationFunction()[0])) : - Optional.empty()); - } - - private static Function, Set> parseSubfieldTransformationFunction(StaticMethodPointer staticMethodPointer) - { - Method subfieldTransformationMethod; - try { - subfieldTransformationMethod = ((Class) staticMethodPointer.clazz()).getDeclaredMethod(staticMethodPointer.method(), Set.class); - } - catch (NoSuchMethodException e) { - return null; - } - checkSubfieldTransformFunctionTypeSignature(subfieldTransformationMethod); - - return (Set subfields) -> { - try { - return (Set) subfieldTransformationMethod.invoke(null, subfields); - } - catch (IllegalAccessException | InvocationTargetException e) { - return ComplexTypeFunctionDescriptor.allSubfieldsRequired(subfields); - } - }; - } - - private static void checkSubfieldTransformFunctionTypeSignature(Method subfieldTransformationMethod) - { - { - String errorMessage = "Subfield transformation function must accept a single parameter of type java.util.Set"; - Type[] inputTypes = subfieldTransformationMethod.getGenericParameterTypes(); - checkArgument(inputTypes.length == 1, errorMessage); - checkTypeIsSetOfSubfields(inputTypes[0], errorMessage); - } - { - String errorMessage = "Subfield transformation function return type must be java.util.Set"; - Type type = subfieldTransformationMethod.getGenericReturnType(); - checkTypeIsSetOfSubfields(type, errorMessage); - } - } - - private static void checkTypeIsSetOfSubfields(Type type, String errorMessage) - { - final ParameterizedType setType = (ParameterizedType) type; - checkArgument(setType.getRawType().equals(Set.class), errorMessage); - checkArgument(setType.getActualTypeArguments()[0].equals(Subfield.class), errorMessage); - } - - private static List parseLambdaDescriptors(ScalarFunctionLambdaDescriptor[] lambdaDescriptors) - { - ImmutableList.Builder lambdaDescriptorBuilder = ImmutableList.builder(); - for (ScalarFunctionLambdaDescriptor lambdaDescriptor : lambdaDescriptors) { - lambdaDescriptorBuilder.add( - new LambdaDescriptor(lambdaDescriptor.callArgumentIndex(), - parseLambdaArgumentDescriptors(lambdaDescriptor.lambdaArgumentDescriptors()))); - } - return lambdaDescriptorBuilder.build(); - } - - private static Map parseLambdaArgumentDescriptors(ScalarFunctionLambdaArgumentDescriptor[] lambdaArgumentToCallArgumentIndexMapEntries) - { - ImmutableMap.Builder lambdaArgumentToCallArgumentIndexMap = ImmutableMap.builder(); - for (ScalarFunctionLambdaArgumentDescriptor entry : lambdaArgumentToCallArgumentIndexMapEntries) { - lambdaArgumentToCallArgumentIndexMap.put(entry.lambdaArgumentIndex(), - new LambdaArgumentDescriptor(entry.callArgumentIndex(), parseSubfieldTransformationFunction(entry.lambdaArgumentToInputTransformationFunction()))); - } - return lambdaArgumentToCallArgumentIndexMap.build(); - } -} diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/ScalarImplementationHeader.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/ScalarImplementationHeader.java index 3680d5bbfb974..0a83dc4233d49 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/ScalarImplementationHeader.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/ScalarImplementationHeader.java @@ -16,7 +16,6 @@ import com.facebook.presto.common.QualifiedObjectName; import com.facebook.presto.common.function.OperatorType; import com.facebook.presto.operator.scalar.ScalarHeader; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; import com.facebook.presto.spi.function.ScalarFunction; import com.facebook.presto.spi.function.ScalarOperator; import com.facebook.presto.spi.function.SqlFunctionVisibility; @@ -29,12 +28,10 @@ import static com.facebook.presto.metadata.BuiltInTypeAndFunctionNamespaceManager.DEFAULT_NAMESPACE; import static com.facebook.presto.operator.annotations.FunctionsParserHelper.parseDescription; -import static com.facebook.presto.operator.scalar.annotations.FunctionDescriptorParser.parseFunctionDescriptor; import static com.facebook.presto.spi.function.SqlFunctionVisibility.HIDDEN; import static com.google.common.base.CaseFormat.LOWER_CAMEL; import static com.google.common.base.CaseFormat.LOWER_UNDERSCORE; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.ImmutableList.builder; import static java.util.Objects.requireNonNull; public class ScalarImplementationHeader @@ -80,29 +77,19 @@ public static List fromAnnotatedElement(AnnotatedEle ScalarOperator scalarOperator = annotated.getAnnotation(ScalarOperator.class); Optional description = parseDescription(annotated); - ImmutableList.Builder builder = builder(); + ImmutableList.Builder builder = ImmutableList.builder(); if (scalarFunction != null) { - ComplexTypeFunctionDescriptor functionDescriptor = parseFunctionDescriptor(scalarFunction.descriptor()); String baseName = scalarFunction.value().isEmpty() ? camelToSnake(annotatedName(annotated)) : scalarFunction.value(); - builder.add(new ScalarImplementationHeader(baseName, new ScalarHeader(description, scalarFunction.visibility(), scalarFunction.deterministic(), - scalarFunction.calledOnNullInput(), functionDescriptor))); + builder.add(new ScalarImplementationHeader(baseName, new ScalarHeader(description, scalarFunction.visibility(), scalarFunction.deterministic(), scalarFunction.calledOnNullInput()))); for (String alias : scalarFunction.alias()) { - builder.add(new ScalarImplementationHeader(alias, new ScalarHeader(description, scalarFunction.visibility(), scalarFunction.deterministic(), - scalarFunction.calledOnNullInput(), functionDescriptor))); + builder.add(new ScalarImplementationHeader(alias, new ScalarHeader(description, scalarFunction.visibility(), scalarFunction.deterministic(), scalarFunction.calledOnNullInput()))); } } if (scalarOperator != null) { - builder.add(new ScalarImplementationHeader( - scalarOperator.value(), - new ScalarHeader( - description, - HIDDEN, - true, - scalarOperator.value().isCalledOnNullInput(), - parseFunctionDescriptor(scalarOperator.descriptor())))); + builder.add(new ScalarImplementationHeader(scalarOperator.value(), new ScalarHeader(description, HIDDEN, true, scalarOperator.value().isCalledOnNullInput()))); } List result = builder.build(); diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/SqlInvokedScalarFromAnnotationsParser.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/SqlInvokedScalarFromAnnotationsParser.java index 92c8db2502ff9..fa6eeb8d8e6f5 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/SqlInvokedScalarFromAnnotationsParser.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/annotations/SqlInvokedScalarFromAnnotationsParser.java @@ -17,7 +17,6 @@ import com.facebook.presto.common.type.TypeSignature; import com.facebook.presto.spi.PrestoException; import com.facebook.presto.spi.function.CodegenScalarFunction; -import com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor; import com.facebook.presto.spi.function.Description; import com.facebook.presto.spi.function.Parameter; import com.facebook.presto.spi.function.RoutineCharacteristics; @@ -176,8 +175,7 @@ else if (method.isAnnotationPresent(SqlParameters.class)) { body, notVersioned(), SCALAR, - Optional.empty(), - ComplexTypeFunctionDescriptor.defaultFunctionDescriptor())) + Optional.empty())) .collect(toImmutableList()); } diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/function/CodegenScalarFunction.java b/presto-spi/src/main/java/com/facebook/presto/spi/function/CodegenScalarFunction.java index 28351daf6ca87..90f8c390a6fd1 100644 --- a/presto-spi/src/main/java/com/facebook/presto/spi/function/CodegenScalarFunction.java +++ b/presto-spi/src/main/java/com/facebook/presto/spi/function/CodegenScalarFunction.java @@ -33,6 +33,4 @@ boolean deterministic() default true; boolean calledOnNullInput() default false; - - ScalarFunctionDescriptor descriptor() default @ScalarFunctionDescriptor; } diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/function/IntArray.java b/presto-spi/src/main/java/com/facebook/presto/spi/function/IntArray.java deleted file mode 100644 index ffd3332a6c6e5..0000000000000 --- a/presto-spi/src/main/java/com/facebook/presto/spi/function/IntArray.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.spi.function; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Retention(RUNTIME) -@Target({METHOD, TYPE}) -public @interface IntArray { - int[] value() default {}; -} diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunction.java b/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunction.java index 58ef8d5dac96e..273f060278c38 100644 --- a/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunction.java +++ b/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunction.java @@ -34,6 +34,4 @@ boolean deterministic() default true; boolean calledOnNullInput() default false; - - ScalarFunctionDescriptor descriptor() default @ScalarFunctionDescriptor; } diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunctionDescriptor.java b/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunctionDescriptor.java deleted file mode 100644 index 1b1cc0bc96a2b..0000000000000 --- a/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunctionDescriptor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.spi.function; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Retention(RUNTIME) -@Target({METHOD, TYPE}) -public @interface ScalarFunctionDescriptor -{ - /** - * Indicates whether the function accessing subfields. - */ - boolean isAccessingInputValues() default true; - - /** - * Set of indices of the function arguments containing map or array arguments. Those arguments are important because all accessed subfields collected so far relate only to - * those map or array arguments and will be passed only to those arguments during the expression analysis phase. - * If argumentIndicesContainingMapOrArray is empty array, it indicates that all function arguments of the map or array types (similarly to - * Optional.empty() value in ComplexTypeFunctionDescriptor.argumentIndicesContainingMapOrArray). For the vast majority of function, this value should - * be used. - * If argumentIndicesContainingMapOrArray is a non-empty array, it must contain a single value of @IntArray type containing the array of the arguments where - * accessed subfields need to be passed to. - */ - IntArray[] argumentIndicesContainingMapOrArray() default {}; - - /** - * Contains the transformation function to convert the output back to the input elements of the array or map. - */ - StaticMethodPointer[] outputToInputTransformationFunction() default {@StaticMethodPointer(clazz = ComplexTypeFunctionDescriptor.class, method = "allSubfieldsRequired")}; - - /** - * Contains the description of all lambdas that this function accepts. - * If function does not accept any lambda parameter, then lambdaDescriptors should be an empty list. - */ - ScalarFunctionLambdaDescriptor[] lambdaDescriptors() default {}; -} diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunctionLambdaArgumentDescriptor.java b/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunctionLambdaArgumentDescriptor.java deleted file mode 100644 index 11d5748aadaac..0000000000000 --- a/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunctionLambdaArgumentDescriptor.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.spi.function; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Retention(RUNTIME) -@Target({METHOD, TYPE}) -public @interface ScalarFunctionLambdaArgumentDescriptor -{ - /** - * Index of the argument in the lambda argument list. Example: for the lambda (x, y) -> x + y, lambdaArgumentIndex for x and y are 0 and 1 respectively. - */ - int lambdaArgumentIndex(); - - /** - * Index of the function argument that contains the function input (Array or Map), to which this lambda argument relate to. - */ - int callArgumentIndex(); - - /** - * Contains the transformation function between the subfields of this lambda argument and the input of the function. - * - * The reason this transformation is needed because the input of the function is the Array or Map, while the lambda arguments are the element of the array or key/value of - * the map. Specifically for map, the transformation function for the lambda argument of the map key will be different from the transformation of the map value. - * If transformation succeeded, then the returned value contains the transformed set of lambda subfields. Otherwise, the function must return Optional.empty() - * value. - */ - StaticMethodPointer lambdaArgumentToInputTransformationFunction() default @StaticMethodPointer( - clazz = ComplexTypeFunctionDescriptor.class, method = "prependAllSubscripts"); -} diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunctionLambdaDescriptor.java b/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunctionLambdaDescriptor.java deleted file mode 100644 index 51ec612b5d248..0000000000000 --- a/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarFunctionLambdaDescriptor.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.spi.function; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Retention(RUNTIME) -@Target({METHOD, TYPE}) -public @interface ScalarFunctionLambdaDescriptor -{ - /** - * Index of the argument in the Call expression of the lambda function that this LambdaDescriptor represents - */ - int callArgumentIndex(); - - /** - * Map of lambda argument descriptors where the key corresponds to the index in the list of lambda argument and value is the descriptor of the argument. - */ - ScalarFunctionLambdaArgumentDescriptor[] lambdaArgumentDescriptors(); -} diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarOperator.java b/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarOperator.java index d72cc295db6c3..96c5958b10701 100644 --- a/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarOperator.java +++ b/presto-spi/src/main/java/com/facebook/presto/spi/function/ScalarOperator.java @@ -27,6 +27,4 @@ public @interface ScalarOperator { OperatorType value(); - - ScalarFunctionDescriptor descriptor() default @ScalarFunctionDescriptor; } diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/function/SqlInvokedFunction.java b/presto-spi/src/main/java/com/facebook/presto/spi/function/SqlInvokedFunction.java index 184ee64c5c8e3..17e720a580277 100644 --- a/presto-spi/src/main/java/com/facebook/presto/spi/function/SqlInvokedFunction.java +++ b/presto-spi/src/main/java/com/facebook/presto/spi/function/SqlInvokedFunction.java @@ -27,7 +27,6 @@ import java.util.Objects; import java.util.Optional; -import static com.facebook.presto.spi.function.ComplexTypeFunctionDescriptor.defaultFunctionDescriptor; import static com.facebook.presto.spi.function.FunctionKind.AGGREGATE; import static com.facebook.presto.spi.function.FunctionKind.SCALAR; import static com.facebook.presto.spi.function.FunctionVersion.notVersioned; @@ -53,7 +52,6 @@ public class SqlInvokedFunction private final SqlFunctionId functionId; private final FunctionVersion functionVersion; private final Optional functionHandle; - private final ComplexTypeFunctionDescriptor descriptor; /** * Metadata required for Aggregation Functions @@ -79,7 +77,6 @@ public SqlInvokedFunction( this.functionVersion = notVersioned(); this.functionHandle = Optional.empty(); this.aggregationMetadata = Optional.empty(); - this.descriptor = defaultFunctionDescriptor(); } // This constructor creates a SCALAR SqlInvokedFunction @@ -92,7 +89,7 @@ public SqlInvokedFunction( String body, FunctionVersion version) { - this(functionName, parameters, emptyList(), returnType, description, routineCharacteristics, body, version, SCALAR, Optional.empty(), defaultFunctionDescriptor()); + this(functionName, parameters, emptyList(), returnType, description, routineCharacteristics, body, version, SCALAR, Optional.empty()); } public SqlInvokedFunction( @@ -106,9 +103,8 @@ public SqlInvokedFunction( FunctionKind kind, Optional aggregationMetadata) { - this(functionName, parameters, emptyList(), returnType, description, routineCharacteristics, body, version, kind, aggregationMetadata, defaultFunctionDescriptor()); + this(functionName, parameters, emptyList(), returnType, description, routineCharacteristics, body, version, kind, aggregationMetadata); } - public SqlInvokedFunction( QualifiedObjectName functionName, List parameters, @@ -119,8 +115,7 @@ public SqlInvokedFunction( String body, FunctionVersion version, FunctionKind kind, - Optional aggregationMetadata, - ComplexTypeFunctionDescriptor descriptor) + Optional aggregationMetadata) { this.parameters = requireNonNull(parameters, "parameters is null"); this.description = requireNonNull(description, "description is null"); @@ -135,7 +130,6 @@ public SqlInvokedFunction( this.functionId = new SqlFunctionId(functionName, argumentTypes); this.functionVersion = requireNonNull(version, "version is null"); this.functionHandle = version.hasVersion() ? Optional.of(new SqlFunctionHandle(this.functionId, version.toString())) : Optional.empty(); - this.descriptor = requireNonNull(descriptor, "descriptor is null"); this.aggregationMetadata = requireNonNull(aggregationMetadata, "aggregationMetadata is null"); if ((kind == AGGREGATE && !aggregationMetadata.isPresent()) || (kind != AGGREGATE && aggregationMetadata.isPresent())) { diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/function/StaticMethodPointer.java b/presto-spi/src/main/java/com/facebook/presto/spi/function/StaticMethodPointer.java deleted file mode 100644 index 537de62267d33..0000000000000 --- a/presto-spi/src/main/java/com/facebook/presto/spi/function/StaticMethodPointer.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.spi.function; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Retention(RUNTIME) -@Target({METHOD, TYPE}) -public @interface StaticMethodPointer -{ - Class clazz(); - String method(); -}