Skip to content

Commit f411e24

Browse files
committed
Refactor omnisci fixture
1 parent 9a5e61d commit f411e24

30 files changed

+1143
-1142
lines changed

rbc/tests/__init__.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__all__ = ['omnisci_fixture', 'sql_execute']
1+
__all__ = ['heavydb_fixture', 'sql_execute']
22

33

44
import os
@@ -23,97 +23,97 @@ def assert_equal(actual, desired):
2323

2424

2525
def sql_execute(query):
26-
"""Execute a SQL statement to omniscidb server using global instance.
26+
"""Execute a SQL statement to heavydb server using global instance.
2727
2828
Use when the query does not require registration of new UDF/UDTFs.
2929
"""
30-
rbc_omnisci = pytest.importorskip('rbc.omniscidb')
31-
omnisci = next(rbc_omnisci.global_omnisci_singleton)
32-
return omnisci.sql_execute(query)
30+
rbc_heavydb = pytest.importorskip('rbc.heavydb')
31+
heavydb = next(rbc_heavydb.global_heavydb_singleton)
32+
return heavydb.sql_execute(query)
3333

3434

35-
def omnisci_fixture(caller_globals, minimal_version=(0, 0),
35+
def heavydb_fixture(caller_globals, minimal_version=(0, 0),
3636
suffices=['', '10', 'null', 'array', 'arraynull'],
3737
load_columnar=True, load_test_data=True, debug=False):
3838
"""Usage from a rbc/tests/test_xyz.py file:
3939
4040
.. code-block:: python
4141
4242
import pytest
43-
from rbc.tests import omnisci_fixture
43+
from rbc.tests import heavydb_fixture
4444
4545
@pytest.fixture(scope='module')
4646
def omnisci():
47-
from o in omnisci_fixture(globals()):
47+
from o in heavydb_fixture(globals()):
4848
# do some customization here
4949
yield o
5050
5151
This fixture creates the following tables:
5252
53-
f'{omnisci.table_name}' - contains columns f8, f4, i8, i4, i2, i1,
53+
f'{heavydb.table_name}' - contains columns f8, f4, i8, i4, i2, i1,
5454
b with row size 5.
5555
56-
f'{omnisci.table_name}10' - contains columns f8, f4, i8, i4, i2,
56+
f'{heavydb.table_name}10' - contains columns f8, f4, i8, i4, i2,
5757
i1, b with row size 10.
5858
59-
f'{omnisci.table_name}null' - contains columns f8, f4, i8, i4, i2,
59+
f'{heavydb.table_name}null' - contains columns f8, f4, i8, i4, i2,
6060
i1, b with row size 5, contains null
6161
values
6262
63-
f'{omnisci.table_name}array' - contains arrays f8, f4, i8, i4, i2,
63+
f'{heavydb.table_name}array' - contains arrays f8, f4, i8, i4, i2,
6464
i1, b with row size 5
6565
66-
f'{omnisci.table_name}arraynull' - contains arrays f8, f4, i8, i4, i2,
66+
f'{heavydb.table_name}arraynull' - contains arrays f8, f4, i8, i4, i2,
6767
i1, b with row size 5, contains null
6868
values.
6969
"""
70-
rbc_omnisci = pytest.importorskip('rbc.omniscidb')
71-
available_version, reason = rbc_omnisci.is_available()
70+
rbc_heavydb = pytest.importorskip('rbc.heavydb')
71+
available_version, reason = rbc_heavydb.is_available()
7272

7373
def require_version(version, message=None, label=None):
7474
"""Execute pytest.skip(...) if version is older than available_version.
7575
76-
Some tests can be run only when using omniscidb server built
77-
from a particular branch of omniscidb. So, when the specified
78-
version and the omniscidb version match exactly and these
76+
Some tests can be run only when using heavydb server built
77+
from a particular branch of heavydb. So, when the specified
78+
version and the heavydb version match exactly and these
7979
correspond to the current development version, if the
8080
specified label does not match with the value of envrinment
8181
variable OMNISCIDB_DEV_LABEL, then the corresponing test will
82-
be skipped. Use label 'docker-dev' when using omniscidb dev
82+
be skipped. Use label 'docker-dev' when using heavydb dev
8383
docker image.
8484
8585
"""
86-
# The available version (of the omniscidb server) has date and
86+
# The available version (of the heavydb server) has date and
8787
# hash bits, however, these are useless for determining the
8888
# version ordering (in the case of available_version[:3] ==
8989
# version) because the date corresponds to the date of
9090
# building the server and the hash corresponds to some commit
91-
# of some repository (omniscidb or omniscidb-internal) and it
91+
# of some repository (heavydb or heavydb-internal) and it
9292
# does not provide easy date information.
9393
#
9494
# The condition available_version[:3] == version can appear in
9595
# the following cases (given in the order of from newer to
9696
# older):
97-
# 1. omniscidb is built against a omniscidb-internal PR branch
97+
# 1. heavydb is built against a heavydb-internal PR branch
9898
# (assuming it is rebased against master)
99-
# 2. omniscidb is built against omniscidb-internal master branch
100-
# 3. omniscidb is built against omniscidb master branch
101-
# 4. omniscidb is built against omniscidb dev docker
102-
# 5. omniscidb is built against omniscidb/omniscidb-internal release tag
99+
# 2. heavydb is built against heavydb-internal master branch
100+
# 3. heavydb is built against heavydb master branch
101+
# 4. heavydb is built against heavydb dev docker
102+
# 5. heavydb is built against heavydb/heavydb-internal release tag
103103
#
104104
# rbc testing suite may use features that exists in the head
105105
# of the above list but not in the tail of it. So we have a
106106
# problem of deciding if a particular test should be disabled
107107
# or not for a given case while there is no reliable way to
108-
# tell from omniscidb version if the server has the particular
108+
# tell from heavydb version if the server has the particular
109109
# feature or not. To resolve this, we use label concept as
110110
# explained in the doc-string.
111111
#
112112

113113
if not available_version:
114114
pytest.skip(reason)
115115

116-
# Requires update when omniscidb-internal bumps up version number:
116+
# Requires update when heavydb-internal bumps up version number:
117117
current_development_version = (6, 0, 0)
118118
if available_version[:3] > current_development_version:
119119
warnings.warn(f'{available_version}) is newer than development version'
@@ -163,8 +163,8 @@ def require_version(version, message=None, label=None):
163163
filename = caller_globals['__file__']
164164
table_name = os.path.splitext(os.path.basename(filename))[0]
165165

166-
config = rbc_omnisci.get_client_config(debug=debug)
167-
m = rbc_omnisci.RemoteOmnisci(**config)
166+
config = rbc_heavydb.get_client_config(debug=debug)
167+
m = rbc_heavydb.RemoteHeavyDB(**config)
168168

169169
if not load_test_data:
170170
yield m
@@ -176,7 +176,7 @@ def require_version(version, message=None, label=None):
176176
# todo: TEXT ENCODING DICT, TEXT ENCODING NONE, TIMESTAMP, TIME,
177177
# DATE, DECIMAL/NUMERIC, GEOMETRY: POINT, LINESTRING, POLYGON,
178178
# MULTIPOLYGON, See
179-
# https://www.omnisci.com/docs/latest/5_datatypes.html
179+
# https://docs.heavy.ai/sql/data-definition-ddl/datatypes-and-fixed-encoding
180180
colnames = ['f4', 'f8', 'i1', 'i2', 'i4', 'i8', 'b']
181181
table_defn = ',\n'.join('%s %s' % (n, t)
182182
for t, n in zip(sqltypes, colnames))

0 commit comments

Comments
 (0)