@@ -109,14 +109,43 @@ TEST_F(PythonUDFMetaTest, CheckEmptyRuntimeVersion) {
109109 EXPECT_TRUE (status.to_string ().find (" runtime version is empty" ) != std::string::npos);
110110}
111111
112- TEST_F (PythonUDFMetaTest, CheckEmptyInputTypes ) {
112+ TEST_F (PythonUDFMetaTest, CheckEmptyInputTypesAllowedForUdf ) {
113113 PythonUDFMeta meta;
114114 meta.name = " test_udf" ;
115115 meta.symbol = " test_func" ;
116116 meta.runtime_version = " 3.9.16" ;
117117 meta.input_types = {};
118118 meta.return_type = nullable_int32_;
119119 meta.type = PythonUDFLoadType::INLINE;
120+ meta.client_type = PythonClientType::UDF;
121+
122+ Status status = meta.check ();
123+ EXPECT_TRUE (status.ok ()) << status.to_string ();
124+ }
125+
126+ TEST_F (PythonUDFMetaTest, CheckEmptyInputTypesAllowedForUdtf) {
127+ PythonUDFMeta meta;
128+ meta.name = " test_udtf" ;
129+ meta.symbol = " test_func" ;
130+ meta.runtime_version = " 3.9.16" ;
131+ meta.input_types = {};
132+ meta.return_type = nullable_string_;
133+ meta.type = PythonUDFLoadType::INLINE;
134+ meta.client_type = PythonClientType::UDTF;
135+
136+ Status status = meta.check ();
137+ EXPECT_TRUE (status.ok ()) << status.to_string ();
138+ }
139+
140+ TEST_F (PythonUDFMetaTest, CheckEmptyInputTypesRejectedForUdaf) {
141+ PythonUDFMeta meta;
142+ meta.name = " test_udaf" ;
143+ meta.symbol = " test_func" ;
144+ meta.runtime_version = " 3.9.16" ;
145+ meta.input_types = {};
146+ meta.return_type = nullable_int32_;
147+ meta.type = PythonUDFLoadType::INLINE;
148+ meta.client_type = PythonClientType::UDAF;
120149
121150 Status status = meta.check ();
122151 EXPECT_FALSE (status.ok ());
@@ -401,6 +430,27 @@ TEST_F(PythonUDFMetaTest, SerializeToJsonMultipleInputTypes) {
401430 EXPECT_TRUE (doc.HasMember (" input_types" ));
402431}
403432
433+ TEST_F (PythonUDFMetaTest, SerializeToJsonEmptyInputTypesForUdf) {
434+ PythonUDFMeta meta;
435+ meta.name = " zero_arg_udf" ;
436+ meta.symbol = " func" ;
437+ meta.runtime_version = " 3.9.16" ;
438+ meta.input_types = {};
439+ meta.return_type = nullable_int32_;
440+ meta.type = PythonUDFLoadType::INLINE;
441+ meta.client_type = PythonClientType::UDF;
442+
443+ std::string json_str;
444+ Status status = meta.serialize_to_json (&json_str);
445+ EXPECT_TRUE (status.ok ()) << status.to_string ();
446+
447+ rapidjson::Document doc;
448+ doc.Parse (json_str.c_str ());
449+ EXPECT_FALSE (doc.HasParseError ());
450+ EXPECT_TRUE (doc.HasMember (" input_types" ));
451+ EXPECT_FALSE (std::string (doc[" input_types" ].GetString ()).empty ());
452+ }
453+
404454// ============================================================================
405455// PythonUDFMeta convert_types_to_schema() tests
406456// ============================================================================
@@ -429,6 +479,17 @@ TEST_F(PythonUDFMetaTest, ConvertTypesToSchemaSingleType) {
429479 EXPECT_EQ (schema->num_fields (), 1 );
430480}
431481
482+ TEST_F (PythonUDFMetaTest, ConvertTypesToSchemaEmpty) {
483+ DataTypes types = {};
484+ std::shared_ptr<arrow::Schema> schema;
485+
486+ Status status = PythonUDFMeta::convert_types_to_schema (types, TimezoneUtils::default_time_zone,
487+ &schema);
488+ EXPECT_TRUE (status.ok ()) << status.to_string ();
489+ EXPECT_NE (schema, nullptr );
490+ EXPECT_EQ (schema->num_fields (), 0 );
491+ }
492+
432493// ============================================================================
433494// PythonUDFMeta serialize_arrow_schema() tests
434495// ============================================================================
0 commit comments