def test_sql_generation_from_infoclass(self): func = api.wrap_udf('test.so', ['string'], 'string', 'info_test') repr(func) func.register('info_test', 'udf_testing') result = func('hello world') assert (ibis.impala.compile(result) == "SELECT udf_testing.info_test('hello world') AS `tmp`")
def udf_creation_to_op(udf_ll, udfcon, test_data_db, name, symbol, inputs, output): func = api.wrap_udf(udf_ll, inputs, output, symbol, name) udfcon.create_function(func, database=test_data_db) func.register(name, test_data_db) assert udfcon.exists_udf(name, test_data_db) return func
def test_udf_varargs(udfcon, alltypes, udf_ll, test_data_db): t = alltypes name = f'add_numbers_{util.guid()[:4]}' input_sig = rules.varargs(rules.double) func = api.wrap_udf(udf_ll, input_sig, 'double', 'AddNumbers', name=name) func.register(name, test_data_db) udfcon.create_function(func, database=test_data_db) expr = func(t.double_col, t.double_col) expr.execute()
def test_create_udf(self): func = api.wrap_udf( '/foo/bar.so', self.inputs, self.output, so_symbol='testFunc', name=self.name, ) stmt = ddl.CreateUDF(func) result = stmt.compile() expected = ("CREATE FUNCTION `test_name`(string, string) " "returns bigint " "location '/foo/bar.so' symbol='testFunc'") assert result == expected
def test_drop_database_with_udfs_and_udas(udfcon, temp_database, wrapped_count_uda): uda1 = wrapped_count_uda udf1 = api.wrap_udf( udf_ll, ['boolean'], 'boolean', 'Identity', f'udf_{util.guid()}', ) db = temp_database udfcon.create_database(db) udfcon.create_function(uda1, database=db) udfcon.create_function(udf1, database=db)
def test_create_udf_type_conversions(self): inputs = ['string', 'int8', 'int16', 'int32'] func = api.wrap_udf( '/foo/bar.so', inputs, self.output, so_symbol='testFunc', name=self.name, ) stmt = ddl.CreateUDF(func) # stmt = ddl.CreateFunction('/foo/bar.so', 'testFunc', # , # self.output, self.name) result = stmt.compile() expected = ("CREATE FUNCTION `test_name`(string, tinyint, " "smallint, int) returns bigint " "location '/foo/bar.so' symbol='testFunc'") assert result == expected