Skip to content

Commit

Permalink
add to_text_encoding_none test (#525)
Browse files Browse the repository at this point in the history
* add to_text_encoding_none test
  • Loading branch information
guilhermeleobas authored Jan 26, 2023
1 parent 500d460 commit d8eb7e6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions rbc/tests/heavydb/test_text_encoding_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
import itertools
from rbc.tests import heavydb_fixture
from rbc.heavydb import TextEncodingNone


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -114,6 +115,24 @@ def fn_copy(mgr, t):
str = mgr.getString(db_id, dict_id, t)
return mgr.getOrAddTransient(mgr.TRANSIENT_DICT_DB_ID, mgr.TRANSIENT_DICT_ID, str)

@heavydb('TextEncodingNone(RowFunctionManager, TextEncodingDict)', devices=['cpu'])
def to_text_encoding_none_1(mgr, t):
db_id = mgr.getDictDbId('to_text_encoding_none_1', 0)
dict_id = mgr.getDictId('to_text_encoding_none_1', 0)
str = mgr.getString(db_id, dict_id, t)
return str

@heavydb('TextEncodingNone(RowFunctionManager, TextEncodingDict)', devices=['cpu'])
def to_text_encoding_none_2(mgr, t):
db_id = mgr.getDictDbId('to_text_encoding_none_2', 0)
dict_id = mgr.getDictId('to_text_encoding_none_2', 0)
str = mgr.getString(db_id, dict_id, t)
n = len(str)
r = TextEncodingNone(n)
for i in range(n):
r[i] = str[i]
return r


@pytest.fixture(scope="module")
def create_columns(heavydb):
Expand Down Expand Up @@ -510,6 +529,19 @@ def test_udf_copy_dict_encoded_string(heavydb, col):
assert list(result) == [('fun',), ('bar',), ('foo',), ('barr',), ('foooo',)]


@pytest.mark.parametrize('col', ['t1'])
@pytest.mark.parametrize('fn', ['to_text_encoding_none_1', 'to_text_encoding_none_2'])
def test_to_text_encoding_none(heavydb, fn, col):
if heavydb.version[:2] < (6, 3):
pytest.skip('Requires HeavyDB version 6.3 or newer')

table = f"{heavydb.base_name}text"
query = f"SELECT {fn}({col}) from {table}"
_, result = heavydb.sql_execute(query)

assert list(result) == [('fun',), ('bar',), ('foo',), ('barr',), ('foooo',)]


def test_row_function_manager(heavydb):
if heavydb.version[:2] < (6, 3):
pytest.skip('Requires HeavyDB version 6.3 or newer')
Expand Down

0 comments on commit d8eb7e6

Please sign in to comment.