diff --git a/ci/scripts/sql/nexmark/q14.drop.sql b/ci/scripts/sql/nexmark/q14.drop.sql index d716883571b12..6cd0e12d317a0 100644 --- a/ci/scripts/sql/nexmark/q14.drop.sql +++ b/ci/scripts/sql/nexmark/q14.drop.sql @@ -1,3 +1,4 @@ -- noinspection SqlNoDataSourceInspectionForFile -- noinspection SqlResolveForFile DROP SINK nexmark_q14; +DROP FUNCTION count_char; \ No newline at end of file diff --git a/ci/scripts/sql/nexmark/q14.sql b/ci/scripts/sql/nexmark/q14.sql index c64b503fae6af..3b77e0e179577 100644 --- a/ci/scripts/sql/nexmark/q14.sql +++ b/ci/scripts/sql/nexmark/q14.sql @@ -1,5 +1,12 @@ -- noinspection SqlNoDataSourceInspectionForFile -- noinspection SqlResolveForFile + +CREATE FUNCTION count_char(s varchar, c varchar) RETURNS int LANGUAGE rust AS $$ + fn count_char(s: &str, c: &str) -> i32 { + s.matches(c).count() as i32 + } +$$; + CREATE SINK nexmark_q14 AS SELECT auction, bidder, @@ -15,11 +22,8 @@ SELECT auction, THEN 'nightTime' ELSE 'otherTime' END AS bidTimeType, - date_time - -- extra - -- TODO: count_char is an UDF, add it back when we support similar functionality. - -- https://github.com/nexmark/nexmark/blob/master/nexmark-flink/src/main/java/com/github/nexmark/flink/udf/CountChar.java - -- count_char(extra, 'c') AS c_counts + date_time, + count_char(extra, 'c') AS c_counts FROM bid WHERE 0.908 * price > 1000000 AND 0.908 * price < 50000000 diff --git a/e2e_test/streaming/nexmark/sinks/q14.slt.part b/e2e_test/streaming/nexmark/sinks/q14.slt.part index 77047c7f3c81c..617c548a5f783 100644 --- a/e2e_test/streaming/nexmark/sinks/q14.slt.part +++ b/e2e_test/streaming/nexmark/sinks/q14.slt.part @@ -1,3 +1,10 @@ +statement ok +CREATE FUNCTION count_char(s varchar, c varchar) RETURNS int LANGUAGE rust AS $$ + fn count_char(s: &str, c: &str) -> i32 { + s.matches(c).count() as i32 + } +$$; + statement ok CREATE SINK nexmark_q14 AS SELECT @@ -15,11 +22,8 @@ SELECT THEN 'nightTime' ELSE 'otherTime' END AS bidTimeType, - date_time - -- extra - -- TODO: count_char is an UDF, add it back when we support similar functionality. - -- https://github.com/nexmark/nexmark/blob/master/nexmark-flink/src/main/java/com/github/nexmark/flink/udf/CountChar.java - -- count_char(extra, 'c') AS c_counts + date_time, + count_char(extra, 'c') AS c_counts FROM bid WHERE 0.908 * price > 1000000 AND 0.908 * price < 50000000 WITH ( connector = 'blackhole', type = 'append-only', force_append_only = 'true'); diff --git a/e2e_test/streaming/nexmark/views/q14.slt.part b/e2e_test/streaming/nexmark/views/q14.slt.part index 1182afb1e1989..7751d0f81969a 100644 --- a/e2e_test/streaming/nexmark/views/q14.slt.part +++ b/e2e_test/streaming/nexmark/views/q14.slt.part @@ -1,3 +1,10 @@ +statement ok +CREATE FUNCTION count_char(s varchar, c varchar) RETURNS int LANGUAGE rust AS $$ + fn count_char(s: &str, c: &str) -> i32 { + s.matches(c).count() as i32 + } +$$; + statement ok CREATE MATERIALIZED VIEW nexmark_q14 AS SELECT @@ -15,10 +22,7 @@ SELECT THEN 'nightTime' ELSE 'otherTime' END AS bidTimeType, - date_time - -- extra - -- TODO: count_char is an UDF, add it back when we support similar functionality. - -- https://github.com/nexmark/nexmark/blob/master/nexmark-flink/src/main/java/com/github/nexmark/flink/udf/CountChar.java - -- count_char(extra, 'c') AS c_counts + date_time, + count_char(extra, 'c') AS c_counts FROM bid WHERE 0.908 * price > 1000000 AND 0.908 * price < 50000000; diff --git a/e2e_test/udf/wasm/src/lib.rs b/e2e_test/udf/wasm/src/lib.rs index 522dd471daf50..556022f9c6e1f 100644 --- a/e2e_test/udf/wasm/src/lib.rs +++ b/e2e_test/udf/wasm/src/lib.rs @@ -1,6 +1,11 @@ use arrow_udf::function; use rust_decimal::Decimal; +#[function("count_char(varchar, varchar) -> int")] +fn count_char(s: &str, c: &str) -> i32 { + s.matches(c).count() as i32 +} + #[function("int_42() -> int")] fn int_42() -> i32 { 42 diff --git a/src/frontend/planner_test/tests/testdata/input/nexmark.yaml b/src/frontend/planner_test/tests/testdata/input/nexmark.yaml index 9cc9ee747e33c..c96bacc3a41b2 100644 --- a/src/frontend/planner_test/tests/testdata/input/nexmark.yaml +++ b/src/frontend/planner_test/tests/testdata/input/nexmark.yaml @@ -336,8 +336,7 @@ END AS bidTimeType, date_time, extra - -- TODO: count_char is an UDF, add it back when we support similar functionality. - -- https://github.com/nexmark/nexmark/blob/master/nexmark-flink/src/main/java/com/github/nexmark/flink/udf/CountChar.java + -- ignore UDF in planner test -- count_char(extra, 'c') AS c_counts FROM bid WHERE 0.908 * price > 1000000 AND 0.908 * price < 50000000; diff --git a/src/frontend/planner_test/tests/testdata/input/nexmark_source.yaml b/src/frontend/planner_test/tests/testdata/input/nexmark_source.yaml index a88a5d138a615..9cda437345fe2 100644 --- a/src/frontend/planner_test/tests/testdata/input/nexmark_source.yaml +++ b/src/frontend/planner_test/tests/testdata/input/nexmark_source.yaml @@ -338,8 +338,7 @@ END AS bidTimeType, date_time, extra - -- TODO: count_char is an UDF, add it back when we support similar functionality. - -- https://github.com/nexmark/nexmark/blob/master/nexmark-flink/src/main/java/com/github/nexmark/flink/udf/CountChar.java + -- ignore UDF in planner test -- count_char(extra, 'c') AS c_counts FROM bid WHERE 0.908 * price > 1000000 AND 0.908 * price < 50000000; diff --git a/src/frontend/planner_test/tests/testdata/input/nexmark_temporal_filter.yaml b/src/frontend/planner_test/tests/testdata/input/nexmark_temporal_filter.yaml index 10f3bafc559df..7ae9091a83a32 100644 --- a/src/frontend/planner_test/tests/testdata/input/nexmark_temporal_filter.yaml +++ b/src/frontend/planner_test/tests/testdata/input/nexmark_temporal_filter.yaml @@ -321,8 +321,7 @@ END AS bidTimeType, date_time, extra - -- TODO: count_char is an UDF, add it back when we support similar functionality. - -- https://github.com/nexmark/nexmark/blob/master/nexmark-flink/src/main/java/com/github/nexmark/flink/udf/CountChar.java + -- ignore UDF in planner test -- count_char(extra, 'c') AS c_counts FROM bid WHERE 0.908 * price > 1000000 AND 0.908 * price < 50000000; diff --git a/src/frontend/planner_test/tests/testdata/input/nexmark_watermark.yaml b/src/frontend/planner_test/tests/testdata/input/nexmark_watermark.yaml index e78287613d5e3..65845ce054aa6 100644 --- a/src/frontend/planner_test/tests/testdata/input/nexmark_watermark.yaml +++ b/src/frontend/planner_test/tests/testdata/input/nexmark_watermark.yaml @@ -305,8 +305,7 @@ END AS bidTimeType, date_time, extra - -- TODO: count_char is an UDF, add it back when we support similar functionality. - -- https://github.com/nexmark/nexmark/blob/master/nexmark-flink/src/main/java/com/github/nexmark/flink/udf/CountChar.java + -- ignore UDF in planner test -- count_char(extra, 'c') AS c_counts FROM bid WHERE 0.908 * price > 1000000 AND 0.908 * price < 50000000; diff --git a/src/frontend/planner_test/tests/testdata/output/nexmark.yaml b/src/frontend/planner_test/tests/testdata/output/nexmark.yaml index ca19eb4dade14..59bd43f020b1f 100644 --- a/src/frontend/planner_test/tests/testdata/output/nexmark.yaml +++ b/src/frontend/planner_test/tests/testdata/output/nexmark.yaml @@ -1185,8 +1185,7 @@ END AS bidTimeType, date_time, extra - -- TODO: count_char is an UDF, add it back when we support similar functionality. - -- https://github.com/nexmark/nexmark/blob/master/nexmark-flink/src/main/java/com/github/nexmark/flink/udf/CountChar.java + -- ignore UDF in planner test -- count_char(extra, 'c') AS c_counts FROM bid WHERE 0.908 * price > 1000000 AND 0.908 * price < 50000000; diff --git a/src/frontend/planner_test/tests/testdata/output/nexmark_source.yaml b/src/frontend/planner_test/tests/testdata/output/nexmark_source.yaml index c60d6e61acae2..32c30f2e76d44 100644 --- a/src/frontend/planner_test/tests/testdata/output/nexmark_source.yaml +++ b/src/frontend/planner_test/tests/testdata/output/nexmark_source.yaml @@ -1003,8 +1003,7 @@ END AS bidTimeType, date_time, extra - -- TODO: count_char is an UDF, add it back when we support similar functionality. - -- https://github.com/nexmark/nexmark/blob/master/nexmark-flink/src/main/java/com/github/nexmark/flink/udf/CountChar.java + -- ignore UDF in planner test -- count_char(extra, 'c') AS c_counts FROM bid WHERE 0.908 * price > 1000000 AND 0.908 * price < 50000000; diff --git a/src/frontend/planner_test/tests/testdata/output/nexmark_temporal_filter.yaml b/src/frontend/planner_test/tests/testdata/output/nexmark_temporal_filter.yaml index d1ed31b042f87..f77e975780c8a 100644 --- a/src/frontend/planner_test/tests/testdata/output/nexmark_temporal_filter.yaml +++ b/src/frontend/planner_test/tests/testdata/output/nexmark_temporal_filter.yaml @@ -957,8 +957,7 @@ END AS bidTimeType, date_time, extra - -- TODO: count_char is an UDF, add it back when we support similar functionality. - -- https://github.com/nexmark/nexmark/blob/master/nexmark-flink/src/main/java/com/github/nexmark/flink/udf/CountChar.java + -- ignore UDF in planner test -- count_char(extra, 'c') AS c_counts FROM bid WHERE 0.908 * price > 1000000 AND 0.908 * price < 50000000; diff --git a/src/frontend/planner_test/tests/testdata/output/nexmark_watermark.yaml b/src/frontend/planner_test/tests/testdata/output/nexmark_watermark.yaml index dfaba49beb633..12593221419d6 100644 --- a/src/frontend/planner_test/tests/testdata/output/nexmark_watermark.yaml +++ b/src/frontend/planner_test/tests/testdata/output/nexmark_watermark.yaml @@ -1208,8 +1208,7 @@ END AS bidTimeType, date_time, extra - -- TODO: count_char is an UDF, add it back when we support similar functionality. - -- https://github.com/nexmark/nexmark/blob/master/nexmark-flink/src/main/java/com/github/nexmark/flink/udf/CountChar.java + -- ignore UDF in planner test -- count_char(extra, 'c') AS c_counts FROM bid WHERE 0.908 * price > 1000000 AND 0.908 * price < 50000000;