Skip to content

Commit 786dc1e

Browse files
committed
Added the unit test for column_queue
Fixed __version__ Fix
1 parent 0ddca9d commit 786dc1e

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

conftest.py renamed to databricks_sql_connector_core/conftest.py

+4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
@pytest.fixture(scope="session")
66
def host():
7+
return "adb-6436897454825492.12.azuredatabricks.net"
78
return os.getenv("DATABRICKS_SERVER_HOSTNAME")
89

910

1011
@pytest.fixture(scope="session")
1112
def http_path():
13+
return "/sql/1.0/warehouses/2f03dd43e35e2aa0"
1214
return os.getenv("DATABRICKS_HTTP_PATH")
1315

1416

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

2527
@pytest.fixture(scope="session")
2628
def catalog():
29+
return "main"
2730
return os.getenv("DATABRICKS_CATALOG")
2831

2932

3033
@pytest.fixture(scope="session")
3134
def schema():
35+
return "default"
3236
return os.getenv("DATABRICKS_SCHEMA", "default")
3337

3438

databricks_sql_connector_core/tests/e2e/common/predicates.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ def pysql_has_version(compare, version):
1818
1919
Expected use:
2020
from common.predicates import pysql_has_version
21-
from databricks import sql as pysql
21+
from databricks_sql_connector_core import sql as pysql
2222
...
2323
@unittest.skipIf(pysql_has_version('<', '2'))
2424
def test_some_pyhive_v1_stuff():
2525
...
2626
"""
27-
from databricks import sql
27+
from databricks_sql_connector_core import sql
2828
return compare_module_version(sql, compare, version)
2929

3030

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import unittest
2+
import pytest
3+
import pyarrow as pa
4+
from databricks_sql_connector_core.sql.utils import ColumnQueue
5+
6+
7+
class TestColumnQueueSuite:
8+
@pytest.fixture(scope="function")
9+
def setup(self):
10+
columnar_table = [[0, 3, 6, 9], [1, 4, 7, 10], [2, 5, 8, 11]]
11+
column_names = [f"col_{i}" for i in range(len(columnar_table))]
12+
return ColumnQueue(columnar_table, column_names)
13+
14+
def test_fetchmany_respects_n_rows(self, setup):
15+
column_queue = setup
16+
assert column_queue.next_n_rows(2) == [[0, 3], [1, 4], [2, 5]]
17+
assert column_queue.next_n_rows(2) == [[6, 9], [7, 10], [8, 11]]
18+
19+
def test_fetch_remaining_rows_respects_n_rows(self, setup):
20+
column_queue = setup
21+
assert column_queue.next_n_rows(2) == [[0, 3], [1, 4], [2, 5]]
22+
assert column_queue.remaining_rows() == [[6, 9], [7, 10], [8, 11]]
23+
24+

setup_script.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def build_and_install_library(directory_name):
77
# Change directory to one level down
88
os.chdir(directory_name)
99

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

0 commit comments

Comments
 (0)