Skip to content

Complete Fetch Phase (for INLINE disposition and JSON_ARRAY format) #594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 48 commits into
base: metadata-sea
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
d97463b
move guid_to_hex_id import to utils
varun-edachali-dbx Jun 9, 2025
139e246
reduce diff in guid utils import
varun-edachali-dbx Jun 9, 2025
e3ee4e4
move arrow_schema_bytes back into ExecuteResult
varun-edachali-dbx Jun 9, 2025
f448a8f
maintain log
varun-edachali-dbx Jun 9, 2025
82ca1ee
remove un-necessary assignment
varun-edachali-dbx Jun 9, 2025
e96a078
remove un-necessary tuple response
varun-edachali-dbx Jun 9, 2025
27158b1
remove un-ncessary verbose mocking
varun-edachali-dbx Jun 9, 2025
d3200c4
move Queue construction to ResultSert
varun-edachali-dbx Jun 10, 2025
8a014f0
move description to List[Tuple]
varun-edachali-dbx Jun 10, 2025
39c41ab
frmatting (black)
varun-edachali-dbx Jun 10, 2025
2cd04df
reduce diff (remove explicit tuple conversion)
varun-edachali-dbx Jun 10, 2025
067a019
remove has_more_rows from ExecuteResponse
varun-edachali-dbx Jun 10, 2025
48c83e0
remove un-necessary has_more_rows aclc
varun-edachali-dbx Jun 10, 2025
281a9e9
default has_more_rows to True
varun-edachali-dbx Jun 10, 2025
192901d
return has_more_rows from ExecResponse conversion during GetRespMetadata
varun-edachali-dbx Jun 10, 2025
55f5c45
remove unnecessary replacement
varun-edachali-dbx Jun 10, 2025
edc36b5
better mocked backend naming
varun-edachali-dbx Jun 10, 2025
81280e7
remove has_more_rows test in ExecuteResponse
varun-edachali-dbx Jun 10, 2025
c1d3be2
introduce replacement of original has_more_rows read test
varun-edachali-dbx Jun 10, 2025
5ee4136
call correct method in test_use_arrow_schema
varun-edachali-dbx Jun 10, 2025
b881ab0
call correct method in test_fall_back_to_hive_schema
varun-edachali-dbx Jun 10, 2025
53bf715
re-introduce result response read test
varun-edachali-dbx Jun 10, 2025
45a32be
simplify test
varun-edachali-dbx Jun 10, 2025
e3fe299
remove excess fetch_results mocks
varun-edachali-dbx Jun 10, 2025
e8038d3
more minimal changes to thrift_backend tests
varun-edachali-dbx Jun 10, 2025
2f6ec19
move back to old table types
varun-edachali-dbx Jun 10, 2025
73bc282
remove outdated arrow_schema_bytes return
varun-edachali-dbx Jun 10, 2025
4e07f1e
align SeaResultSet with new structure
varun-edachali-dbx Jun 11, 2025
65e7c6b
correct sea res set tests
varun-edachali-dbx Jun 11, 2025
71b451a
minimal fetch phase intro
varun-edachali-dbx Jun 11, 2025
170f339
Merge branch 'exec-resp-norm' into fetch-json-inline
varun-edachali-dbx Jun 11, 2025
40f79b5
Merge branch 'sea-res-set' into fetch-json-inline
varun-edachali-dbx Jun 11, 2025
c038d5a
working JSON + INLINE
varun-edachali-dbx Jun 11, 2025
716304b
rmeove redundant queue init
varun-edachali-dbx Jun 11, 2025
e96e5b8
large query results
varun-edachali-dbx Jun 11, 2025
23963fc
align SeaResultSet with ext-links-sea
varun-edachali-dbx Jun 16, 2025
dd43715
remove redundant methods
varun-edachali-dbx Jun 16, 2025
34a7f66
update unit tests
varun-edachali-dbx Jun 16, 2025
715cc13
remove accidental venv changes
varun-edachali-dbx Jun 16, 2025
a0705bc
add fetchmany_arrow and fetchall_arrow
varun-edachali-dbx Jun 17, 2025
1b90c4a
Merge branch 'metadata-sea' into fetch-json-inline
varun-edachali-dbx Jun 17, 2025
f7c11b9
remove accidental changes in sea backend tests
varun-edachali-dbx Jun 17, 2025
2903473
remove unimplemented methods test
varun-edachali-dbx Jun 17, 2025
b300709
Merge branch 'metadata-sea' into fetch-json-inline
varun-edachali-dbx Jun 17, 2025
021ff4c
remove unimplemented method tests
varun-edachali-dbx Jun 17, 2025
adecd53
modify example scripts to include fetch calls
varun-edachali-dbx Jun 17, 2025
bfc1f01
fix sea connector tests
varun-edachali-dbx Jun 17, 2025
27564ca
Merge branch 'metadata-sea' into fetch-json-inline
varun-edachali-dbx Jun 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 105 additions & 56 deletions examples/experimental/sea_connector_test.py
Original file line number Diff line number Diff line change
@@ -1,66 +1,115 @@
"""
Main script to run all SEA connector tests.

This script runs all the individual test modules and displays
a summary of test results with visual indicators.
"""
import os
import sys
import logging
from databricks.sql.client import Connection
import subprocess
from typing import List, Tuple

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

def test_sea_session():
"""
Test opening and closing a SEA session using the connector.

This function connects to a Databricks SQL endpoint using the SEA backend,
opens a session, and then closes it.

Required environment variables:
- DATABRICKS_SERVER_HOSTNAME: Databricks server hostname
- DATABRICKS_HTTP_PATH: HTTP path for the SQL endpoint
- DATABRICKS_TOKEN: Personal access token for authentication
"""

server_hostname = os.environ.get("DATABRICKS_SERVER_HOSTNAME")
http_path = os.environ.get("DATABRICKS_HTTP_PATH")
access_token = os.environ.get("DATABRICKS_TOKEN")
catalog = os.environ.get("DATABRICKS_CATALOG")

if not all([server_hostname, http_path, access_token]):
logger.error("Missing required environment variables.")
logger.error("Please set DATABRICKS_SERVER_HOSTNAME, DATABRICKS_HTTP_PATH, and DATABRICKS_TOKEN.")
sys.exit(1)

logger.info(f"Connecting to {server_hostname}")
logger.info(f"HTTP Path: {http_path}")
if catalog:
logger.info(f"Using catalog: {catalog}")

try:
logger.info("Creating connection with SEA backend...")
connection = Connection(
server_hostname=server_hostname,
http_path=http_path,
access_token=access_token,
catalog=catalog,
schema="default",
use_sea=True,
user_agent_entry="SEA-Test-Client" # add custom user agent
TEST_MODULES = [
"test_sea_session",
"test_sea_sync_query",
"test_sea_async_query",
"test_sea_metadata",
]


def run_test_module(module_name: str) -> bool:
"""Run a test module and return success status."""
module_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "tests", f"{module_name}.py"
)

# Simply run the module as a script - each module handles its own test execution
result = subprocess.run(
[sys.executable, module_path], capture_output=True, text=True
)

# Log the output from the test module
if result.stdout:
for line in result.stdout.strip().split("\n"):
logger.info(line)

if result.stderr:
for line in result.stderr.strip().split("\n"):
logger.error(line)

return result.returncode == 0


def run_tests() -> List[Tuple[str, bool]]:
"""Run all tests and return results."""
results = []

for module_name in TEST_MODULES:
try:
logger.info(f"\n{'=' * 50}")
logger.info(f"Running test: {module_name}")
logger.info(f"{'-' * 50}")

success = run_test_module(module_name)
results.append((module_name, success))

status = "✅ PASSED" if success else "❌ FAILED"
logger.info(f"Test {module_name}: {status}")

except Exception as e:
logger.error(f"Error loading or running test {module_name}: {str(e)}")
import traceback

logger.error(traceback.format_exc())
results.append((module_name, False))

return results


def print_summary(results: List[Tuple[str, bool]]) -> None:
"""Print a summary of test results."""
logger.info(f"\n{'=' * 50}")
logger.info("TEST SUMMARY")
logger.info(f"{'-' * 50}")

passed = sum(1 for _, success in results if success)
total = len(results)

for module_name, success in results:
status = "✅ PASSED" if success else "❌ FAILED"
logger.info(f"{status} - {module_name}")

logger.info(f"{'-' * 50}")
logger.info(f"Total: {total} | Passed: {passed} | Failed: {total - passed}")
logger.info(f"{'=' * 50}")


if __name__ == "__main__":
# Check if required environment variables are set
required_vars = [
"DATABRICKS_SERVER_HOSTNAME",
"DATABRICKS_HTTP_PATH",
"DATABRICKS_TOKEN",
]
missing_vars = [var for var in required_vars if not os.environ.get(var)]

if missing_vars:
logger.error(
f"Missing required environment variables: {', '.join(missing_vars)}"
)

logger.info(f"Successfully opened SEA session with ID: {connection.get_session_id_hex()}")
logger.info(f"backend type: {type(connection.session.backend)}")

# Close the connection
logger.info("Closing the SEA session...")
connection.close()
logger.info("Successfully closed SEA session")

except Exception as e:
logger.error(f"Error testing SEA session: {str(e)}")
import traceback
logger.error(traceback.format_exc())
logger.error("Please set these variables before running the tests.")
sys.exit(1)

logger.info("SEA session test completed successfully")

if __name__ == "__main__":
test_sea_session()
# Run all tests
results = run_tests()

# Print summary
print_summary(results)

# Exit with appropriate status code
all_passed = all(success for _, success in results)
sys.exit(0 if all_passed else 1)
Empty file.
Loading
Loading