github-actions[bot] commented on code in PR #62624: URL: https://github.com/apache/doris/pull/62624#discussion_r3166459669
########## regression-test/suites/pythonudf_p0/test_pythonudf_no_input.groovy: ########## @@ -0,0 +1,66 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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. + +suite("test_pythonudf_no_input") { + def runtime_version = getPythonUdfRuntimeVersion() + def table_name = "test_pythonudf_no_input_tbl" + + try { + sql """ DROP FUNCTION IF EXISTS py_const_no_input(); """ + sql """ DROP TABLE IF EXISTS ${table_name}; """ + + sql """ + CREATE FUNCTION py_const_no_input() + RETURNS INT + PROPERTIES ( + "type" = "PYTHON_UDF", + "symbol" = "evaluate", + "runtime_version" = "${runtime_version}" + ) + AS \$\$ +def evaluate(): + return 7 +\$\$; + """ + + assert sql(""" SELECT py_const_no_input(); """)[0][0] == 7 + + sql """ + CREATE TABLE ${table_name} ( + id INT + ) ENGINE=OLAP + DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES("replication_num" = "1"); + """ + + sql """ INSERT INTO ${table_name} VALUES (1), (2), (3); """ + + def rows = sql(""" + SELECT id, py_const_no_input() AS v + FROM ${table_name} + ORDER BY id + """) + + assert rows.size() == 3 : "Expected 3 rows, got ${rows.size()}" + assert rows.collect { it[0] as int } == [1, 2, 3] + assert rows.every { (it[1] as int) == 7 } + } finally { + try_sql(""" DROP FUNCTION IF EXISTS py_const_no_input(); """) + try_sql(""" DROP TABLE IF EXISTS ${table_name}; """) Review Comment: The regression-test standard in `AGENTS.md` says tables should be dropped before use, not after, so the environment remains available for debugging failed runs. This test already drops `test_pythonudf_no_input_tbl` before creating it; please remove the `DROP TABLE` from the `finally` block (the function cleanup is fine to keep if desired). ########## regression-test/suites/pythonudtf_p0/test_pythonudtf_no_input.groovy: ########## @@ -0,0 +1,70 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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. + +suite("test_pythonudtf_no_input") { + def runtime_version = getPythonUdfRuntimeVersion() + def table_name = "test_pythonudtf_no_input_tbl" + + try { + sql """ DROP FUNCTION IF EXISTS py_emit_no_input(); """ + sql """ DROP TABLE IF EXISTS ${table_name}; """ + + sql """ + CREATE TABLES FUNCTION py_emit_no_input() + RETURNS ARRAY<STRING> + PROPERTIES ( + "type" = "PYTHON_UDF", + "symbol" = "emit_values", + "runtime_version" = "${runtime_version}" + ) + AS \$\$ +def emit_values(): + yield ('left',) + yield ('right',) +\$\$; + """ + + sql """ + CREATE TABLE ${table_name} ( + id INT + ) ENGINE=OLAP + DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES("replication_num" = "1"); + """ + + sql """ INSERT INTO ${table_name} VALUES (1), (2); """ + + def rows = sql(""" + SELECT id, value + FROM ${table_name} + LATERAL VIEW py_emit_no_input() tmp AS value + ORDER BY id, value + """) + + assert rows.size() == 4 : "Expected 4 rows, got ${rows.size()}" + assert rows.collect { [(it[0] as int), it[1].toString()] } == [ + [1, "left"], + [1, "right"], + [2, "left"], + [2, "right"] + ] + } finally { + try_sql(""" DROP FUNCTION IF EXISTS py_emit_no_input(); """) + try_sql(""" DROP TABLE IF EXISTS ${table_name}; """) Review Comment: Same regression-test standard issue here: newly added cases should not drop the test table after execution. Since the table is already dropped before creation, please leave it in place after the test so failed-run state is preserved for debugging. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
