Skip to content

Commit

Permalink
Added the unit test for column_queue
Browse files Browse the repository at this point in the history
Fixed __version__

Fix
  • Loading branch information
jprakash-db committed Aug 20, 2024
1 parent 0ddca9d commit 786dc1e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions conftest.py → databricks_sql_connector_core/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

@pytest.fixture(scope="session")
def host():
return "adb-6436897454825492.12.azuredatabricks.net"
return os.getenv("DATABRICKS_SERVER_HOSTNAME")


@pytest.fixture(scope="session")
def http_path():
return "/sql/1.0/warehouses/2f03dd43e35e2aa0"
return os.getenv("DATABRICKS_HTTP_PATH")


Expand All @@ -24,11 +26,13 @@ def ingestion_user():

@pytest.fixture(scope="session")
def catalog():
return "main"
return os.getenv("DATABRICKS_CATALOG")


@pytest.fixture(scope="session")
def schema():
return "default"
return os.getenv("DATABRICKS_SCHEMA", "default")


Expand Down
4 changes: 2 additions & 2 deletions databricks_sql_connector_core/tests/e2e/common/predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def pysql_has_version(compare, version):
Expected use:
from common.predicates import pysql_has_version
from databricks import sql as pysql
from databricks_sql_connector_core import sql as pysql
...
@unittest.skipIf(pysql_has_version('<', '2'))
def test_some_pyhive_v1_stuff():
...
"""
from databricks import sql
from databricks_sql_connector_core import sql
return compare_module_version(sql, compare, version)


Expand Down
24 changes: 24 additions & 0 deletions databricks_sql_connector_core/tests/unit/test_column_queue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import unittest
import pytest
import pyarrow as pa
from databricks_sql_connector_core.sql.utils import ColumnQueue


class TestColumnQueueSuite:
@pytest.fixture(scope="function")
def setup(self):
columnar_table = [[0, 3, 6, 9], [1, 4, 7, 10], [2, 5, 8, 11]]
column_names = [f"col_{i}" for i in range(len(columnar_table))]
return ColumnQueue(columnar_table, column_names)

def test_fetchmany_respects_n_rows(self, setup):
column_queue = setup
assert column_queue.next_n_rows(2) == [[0, 3], [1, 4], [2, 5]]
assert column_queue.next_n_rows(2) == [[6, 9], [7, 10], [8, 11]]

def test_fetch_remaining_rows_respects_n_rows(self, setup):
column_queue = setup
assert column_queue.next_n_rows(2) == [[0, 3], [1, 4], [2, 5]]
assert column_queue.remaining_rows() == [[6, 9], [7, 10], [8, 11]]


1 change: 1 addition & 0 deletions setup_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def build_and_install_library(directory_name):
# Change directory to one level down
os.chdir(directory_name)

# chal jaa
# Build the library using Poetry
subprocess.run(['poetry', 'build'], check=True)

Expand Down

0 comments on commit 786dc1e

Please sign in to comment.