OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tests.test_runtime_udf.TestRuntimeUDF Class Reference

Public Member Functions

def load_test_udf_incr
 
def test_udf_incr
 
def test_udf_incr_read_sql
 

Detailed Description

Definition at line 28 of file test_runtime_udf.py.

Member Function Documentation

def tests.test_runtime_udf.TestRuntimeUDF.load_test_udf_incr (   self,
  con 
)

Definition at line 29 of file test_runtime_udf.py.

Referenced by tests.test_runtime_udf.TestRuntimeUDF.test_udf_incr(), and tests.test_runtime_udf.TestRuntimeUDF.test_udf_incr_read_sql().

29 
30  def load_test_udf_incr(self, con):
31  con.execute('drop table if exists test_udf_incr')
32  con.execute('create table test_udf_incr (i4 integer, f8 double)')
33  con.execute('insert into test_udf_incr values (1, 2.3);')
34  con.execute('insert into test_udf_incr values (2, 3.4);')

+ Here is the caller graph for this function:

def tests.test_runtime_udf.TestRuntimeUDF.test_udf_incr (   self,
  con 
)

Definition at line 36 of file test_runtime_udf.py.

References run_benchmark_import.con, and tests.test_runtime_udf.TestRuntimeUDF.load_test_udf_incr().

36 
37  def test_udf_incr(self, con):
38  @con('int32(int32)', 'double(double)')
39  def incr(x):
40  return x + 1
41 
42  self.load_test_udf_incr(con)
43 
44  result = list(con.execute('select i4, incr(i4) from test_udf_incr'))
45  expected = [(1, 2), (2, 3)]
46  assert result == expected
47 
48  result = list(con.execute('select f8, incr(f8) from test_udf_incr'))
49  expected = [(2.3, 3.3), (3.4, 4.4)]
50  assert result == expected
51 
52  con.execute('drop table if exists test_udf_incr')

+ Here is the call graph for this function:

def tests.test_runtime_udf.TestRuntimeUDF.test_udf_incr_read_sql (   self,
  con 
)

Definition at line 54 of file test_runtime_udf.py.

References run_benchmark_import.con, and tests.test_runtime_udf.TestRuntimeUDF.load_test_udf_incr().

54 
55  def test_udf_incr_read_sql(self, con):
56  @con('int32(int32)', 'double(double)')
57  def incr_read_sql(x):
58  return x + 1
59 
60  self.load_test_udf_incr(con)
61 
62  result = pd.read_sql(
63  '''select i4 as qty, incr_read_sql(i4) as price
64  from test_udf_incr''',
65  con,
66  )
67  expected = pd.DataFrame(
68  {
69  "qty": np.array([1, 2], dtype=np.int64),
70  "price": np.array([2, 3], dtype=np.int64),
71  }
72  )[['qty', 'price']]
73  tm.assert_frame_equal(result, expected)
74 
75  result = pd.read_sql(
76  '''select f8 as qty, incr_read_sql(f8) as price
77  from test_udf_incr''',
78  con,
79  )
80  expected = pd.DataFrame(
81  {
82  "qty": np.array([2.3, 3.4], dtype=np.float64),
83  "price": np.array([3.3, 4.4], dtype=np.float64),
84  }
85  )[['qty', 'price']]
86  tm.assert_frame_equal(result, expected)
87 
88  con.execute('drop table if exists test_udf_incr')

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: