4 import pandas.testing
as tm
6 pytest.importorskip(
'rbc')
10 def new_mth(self, con):
13 except Exception
as msg:
16 ).__name__ ==
'TDBException' and msg.error_msg.startswith(
17 'Runtime UDF and UDTF function registration is disabled'
19 print(
'Ignoring `%s` failure' % (msg.error_msg))
23 new_mth.__name__ = mth.__name__
27 @pytest.mark.usefixtures(
"heavydb_server")
30 con.execute(
'drop table if exists test_udf_incr')
31 con.execute(
'create table test_udf_incr (i4 integer, f8 double)')
32 con.execute(
'insert into test_udf_incr values (1, 2.3);')
33 con.execute(
'insert into test_udf_incr values (2, 3.4);')
35 @catch_udf_support_disabled
37 @
con(
'int32(int32)',
'double(double)')
43 result = list(con.execute(
'select i4, incr(i4) from test_udf_incr'))
44 expected = [(1, 2), (2, 3)]
45 assert result == expected
47 result = list(con.execute(
'select f8, incr(f8) from test_udf_incr'))
48 expected = [(2.3, 3.3), (3.4, 4.4)]
49 assert result == expected
51 con.execute(
'drop table if exists test_udf_incr')
53 @catch_udf_support_disabled
55 @
con(
'int32(int32)',
'double(double)')
62 '''select i4 as qty, incr_read_sql(i4) as price
63 from test_udf_incr''',
66 expected = pd.DataFrame(
68 "qty": np.array([1, 2], dtype=np.int64),
69 "price": np.array([2, 3], dtype=np.int64),
72 tm.assert_frame_equal(result, expected)
75 '''select f8 as qty, incr_read_sql(f8) as price
76 from test_udf_incr''',
79 expected = pd.DataFrame(
81 "qty": np.array([2.3, 3.4], dtype=np.float64),
82 "price": np.array([3.3, 4.4], dtype=np.float64),
85 tm.assert_frame_equal(result, expected)
87 con.execute(
'drop table if exists test_udf_incr')
def test_udf_incr_read_sql
def catch_udf_support_disabled