Skip to content

Commit 0a7a6ab

Browse files
SEA: Fetch Phase (#650)
* Separate Session related functionality from Connection class (#571) * decouple session class from existing Connection ensure maintenance of current APIs of Connection while delegating responsibility Signed-off-by: varun-edachali-dbx <[email protected]> * add open property to Connection to ensure maintenance of existing API Signed-off-by: varun-edachali-dbx <[email protected]> * update unit tests to address ThriftBackend through session instead of through Connection Signed-off-by: varun-edachali-dbx <[email protected]> * chore: move session specific tests from test_client to test_session Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) as in CONTRIBUTING.md Signed-off-by: varun-edachali-dbx <[email protected]> * use connection open property instead of long chain through session Signed-off-by: varun-edachali-dbx <[email protected]> * trigger integration workflow Signed-off-by: varun-edachali-dbx <[email protected]> * fix: ensure open attribute of Connection never fails in case the openSession takes long, the initialisation of the session will not complete immediately. This could make the session attribute inaccessible. If the Connection is deleted in this time, the open() check will throw because the session attribute does not exist. Thus, we default to the Connection being closed in this case. This was not an issue before because open was a direct attribute of the Connection class. Caught in the integration tests. Signed-off-by: varun-edachali-dbx <[email protected]> * fix: de-complicate earlier connection open logic earlier, one of the integration tests was failing because 'session was not an attribute of Connection'. This is likely tied to a local configuration issue related to unittest that was causing an error in the test suite itself. The tests are now passing without checking for the session attribute. https://github.com/databricks/databricks-sql-python/pull/567/commits/c676f9b0281cc3e4fe9c6d8216cc62fc75eade3b Signed-off-by: varun-edachali-dbx <[email protected]> * Revert "fix: de-complicate earlier connection open logic" This reverts commit d6b1b196c98a6e9d8e593a88c34bbde010519ef4. Signed-off-by: varun-edachali-dbx <[email protected]> * [empty commit] attempt to trigger ci e2e workflow Signed-off-by: varun-edachali-dbx <[email protected]> * Update CODEOWNERS (#562) new codeowners Signed-off-by: varun-edachali-dbx <[email protected]> * Enhance Cursor close handling and context manager exception management to prevent server side resource leaks (#554) * Enhance Cursor close handling and context manager exception management * tests * fmt * Fix Cursor.close() to properly handle CursorAlreadyClosedError * Remove specific test message from Cursor.close() error handling * Improve error handling in connection and cursor context managers to ensure proper closure during exceptions, including KeyboardInterrupt. Add tests for nested cursor management and verify operation closure on server-side errors. * add * add Signed-off-by: varun-edachali-dbx <[email protected]> * PECOBLR-86 improve logging on python driver (#556) * PECOBLR-86 Improve logging for debug level Signed-off-by: Sai Shree Pradhan <[email protected]> * PECOBLR-86 Improve logging for debug level Signed-off-by: Sai Shree Pradhan <[email protected]> * fixed format Signed-off-by: Sai Shree Pradhan <[email protected]> * used lazy logging Signed-off-by: Sai Shree Pradhan <[email protected]> * changed debug to error logs Signed-off-by: Sai Shree Pradhan <[email protected]> * used lazy logging Signed-off-by: Sai Shree Pradhan <[email protected]> --------- Signed-off-by: Sai Shree Pradhan <[email protected]> Signed-off-by: varun-edachali-dbx <[email protected]> * Revert "Merge remote-tracking branch 'upstream/sea-migration' into decouple-session" This reverts commit dbb2ec52306b91072a2ee842270c7113aece9aff, reversing changes made to 7192f117279d4f0adcbafcdf2238c18663324515. Signed-off-by: varun-edachali-dbx <[email protected]> * Reapply "Merge remote-tracking branch 'upstream/sea-migration' into decouple-session" This reverts commit bdb83817f49e1d88a01679b11da8e55e8e80b42f. Signed-off-by: varun-edachali-dbx <[email protected]> * fix: separate session opening logic from instantiation ensures correctness of self.session.open call in Connection Signed-off-by: varun-edachali-dbx <[email protected]> * fix: use is_open attribute to denote session availability Signed-off-by: varun-edachali-dbx <[email protected]> * fix: access thrift backend through session Signed-off-by: varun-edachali-dbx <[email protected]> * chore: use get_handle() instead of private session attribute in client Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * fix: remove accidentally removed assertions Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> Signed-off-by: Sai Shree Pradhan <[email protected]> Co-authored-by: Jothi Prakash <[email protected]> Co-authored-by: Madhav Sainanee <[email protected]> Co-authored-by: Sai Shree Pradhan <[email protected]> * Introduce Backend Interface (DatabricksClient) (#573) NOTE: the `test_complex_types` e2e test was not working at the time of this merge. The test must be triggered when the test is back up and running as intended. * remove excess logs, assertions, instantiations large merge artifacts Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) + remove excess log (merge artifact) Signed-off-by: varun-edachali-dbx <[email protected]> * fix typing Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary check Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary replace call Signed-off-by: varun-edachali-dbx <[email protected]> * introduce __str__ methods for CommandId and SessionId Signed-off-by: varun-edachali-dbx <[email protected]> * docstrings for DatabricksClient interface Signed-off-by: varun-edachali-dbx <[email protected]> * stronger typing of Cursor and ExecuteResponse Signed-off-by: varun-edachali-dbx <[email protected]> * remove utility functions from backend interface, fix circular import Signed-off-by: varun-edachali-dbx <[email protected]> * rename info to properties Signed-off-by: varun-edachali-dbx <[email protected]> * newline for cleanliness Signed-off-by: varun-edachali-dbx <[email protected]> * fix circular import Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * to_hex_id -> get_hex_id Signed-off-by: varun-edachali-dbx <[email protected]> * better comment on protocol version getter Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * move guid to hex id to new utils module Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * move staging allowed local path to connection props Signed-off-by: varun-edachali-dbx <[email protected]> * add strong return type for execute_command Signed-off-by: varun-edachali-dbx <[email protected]> * skip auth, error handling in databricksclient interface Signed-off-by: varun-edachali-dbx <[email protected]> * chore: docstring + line width Signed-off-by: varun-edachali-dbx <[email protected]> * get_id -> get_guid Signed-off-by: varun-edachali-dbx <[email protected]> * chore: docstring Signed-off-by: varun-edachali-dbx <[email protected]> * fix: to_hex_id -> to_hex_guid Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> * Implement ResultSet Abstraction (backend interfaces for fetch phase) (#574) * ensure backend client returns a ResultSet type in backend tests Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * newline for cleanliness Signed-off-by: varun-edachali-dbx <[email protected]> * fix circular import Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * to_hex_id -> get_hex_id Signed-off-by: varun-edachali-dbx <[email protected]> * better comment on protocol version getter Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * stricter typing for cursor Signed-off-by: varun-edachali-dbx <[email protected]> * correct typing Signed-off-by: varun-edachali-dbx <[email protected]> * correct tests and merge artifacts Signed-off-by: varun-edachali-dbx <[email protected]> * remove accidentally modified workflow files remnants of old merge Signed-off-by: varun-edachali-dbx <[email protected]> * chore: remove accidentally modified workflow files Signed-off-by: varun-edachali-dbx <[email protected]> * add back accidentally removed docstrings Signed-off-by: varun-edachali-dbx <[email protected]> * clean up docstrings Signed-off-by: varun-edachali-dbx <[email protected]> * log hex Signed-off-by: varun-edachali-dbx <[email protected]> * remove unnecessary _replace call Signed-off-by: varun-edachali-dbx <[email protected]> * add __str__ for CommandId Signed-off-by: varun-edachali-dbx <[email protected]> * take TOpenSessionResp in get_protocol_version to maintain existing interface Signed-off-by: varun-edachali-dbx <[email protected]> * active_op_handle -> active_mmand_id Signed-off-by: varun-edachali-dbx <[email protected]> * ensure None returned for close_command Signed-off-by: varun-edachali-dbx <[email protected]> * account for ResultSet return in new pydocs Signed-off-by: varun-edachali-dbx <[email protected]> * pydoc for types Signed-off-by: varun-edachali-dbx <[email protected]> * move common state to ResultSet aprent Signed-off-by: varun-edachali-dbx <[email protected]> * stronger typing in resultSet behaviour Signed-off-by: varun-edachali-dbx <[email protected]> * remove redundant patch in test Signed-off-by: varun-edachali-dbx <[email protected]> * add has_been_closed_server_side assertion Signed-off-by: varun-edachali-dbx <[email protected]> * remove redundancies in tests Signed-off-by: varun-edachali-dbx <[email protected]> * more robust close check Signed-off-by: varun-edachali-dbx <[email protected]> * use normalised state in e2e test Signed-off-by: varun-edachali-dbx <[email protected]> * simplify corrected test Signed-off-by: varun-edachali-dbx <[email protected]> * add line gaps after multi-line pydocs for consistency Signed-off-by: varun-edachali-dbx <[email protected]> * use normalised CommandState type in ExecuteResponse Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> * Introduce Sea HTTP Client and test script (#583) * introduce http client (temp) and sea test file Signed-off-by: varun-edachali-dbx <[email protected]> * reduce verbosity Signed-off-by: varun-edachali-dbx <[email protected]> * redundant comment Signed-off-by: varun-edachali-dbx <[email protected]> * reduce redundancy, params and data separate Signed-off-by: varun-edachali-dbx <[email protected]> * rename client Signed-off-by: varun-edachali-dbx <[email protected]> * fix type issues Signed-off-by: varun-edachali-dbx <[email protected]> * reduce repetition in request calls Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary elifs Signed-off-by: varun-edachali-dbx <[email protected]> * add newline at EOF Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> * Introduce `SeaDatabricksClient` (Session Implementation) (#582) * [squashed from prev branch] introduce sea client with session open and close functionality Signed-off-by: varun-edachali-dbx <[email protected]> * remove accidental changes to workflows (merge artifacts) Signed-off-by: varun-edachali-dbx <[email protected]> * pass test_input to get_protocol_version instead of session_id to maintain previous API Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black + line gaps after multi-line pydocs) Signed-off-by: varun-edachali-dbx <[email protected]> * use factory for backend instantiation Signed-off-by: varun-edachali-dbx <[email protected]> * fix type issues Signed-off-by: varun-edachali-dbx <[email protected]> * remove redundant comments Signed-off-by: varun-edachali-dbx <[email protected]> * introduce models for requests and responses Signed-off-by: varun-edachali-dbx <[email protected]> * remove http client and test script to prevent diff from showing up post http-client merge Signed-off-by: varun-edachali-dbx <[email protected]> * Introduce Sea HTTP Client and test script (#583) * introduce http client (temp) and sea test file Signed-off-by: varun-edachali-dbx <[email protected]> * reduce verbosity Signed-off-by: varun-edachali-dbx <[email protected]> * redundant comment Signed-off-by: varun-edachali-dbx <[email protected]> * reduce redundancy, params and data separate Signed-off-by: varun-edachali-dbx <[email protected]> * rename client Signed-off-by: varun-edachali-dbx <[email protected]> * fix type issues Signed-off-by: varun-edachali-dbx <[email protected]> * reduce repetition in request calls Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary elifs Signed-off-by: varun-edachali-dbx <[email protected]> * add newline at EOF Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> * CustomHttpClient -> SeaHttpClient Signed-off-by: varun-edachali-dbx <[email protected]> * redundant comment in backend client Signed-off-by: varun-edachali-dbx <[email protected]> * regex for warehouse_id instead of .split, remove excess imports and behaviour Signed-off-by: varun-edachali-dbx <[email protected]> * remove redundant attributes Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * [nit] reduce nested code Signed-off-by: varun-edachali-dbx <[email protected]> * line gap after multi-line pydoc Signed-off-by: varun-edachali-dbx <[email protected]> * redundant imports Signed-off-by: varun-edachali-dbx <[email protected]> * move sea backend and models into separate sea/ dir Signed-off-by: varun-edachali-dbx <[email protected]> * move http client into separate sea/ dir Signed-off-by: varun-edachali-dbx <[email protected]> * change commands to include ones in docs Signed-off-by: varun-edachali-dbx <[email protected]> * add link to sql-ref-parameters for session-confs Signed-off-by: varun-edachali-dbx <[email protected]> * add client side filtering for session confs, add note on warehouses over endoints Signed-off-by: varun-edachali-dbx <[email protected]> * test unimplemented methods and max_download_threads prop Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> * Normalise Execution Response (clean backend interfaces) (#587) * [squash from exec-sea] bring over execution phase changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess test Signed-off-by: varun-edachali-dbx <[email protected]> * add docstring Signed-off-by: varun-edachali-dbx <[email protected]> * remvoe exec func in sea backend Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess files Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess models Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess sea backend tests Signed-off-by: varun-edachali-dbx <[email protected]> * cleanup Signed-off-by: varun-edachali-dbx <[email protected]> * re-introduce get_schema_desc Signed-off-by: varun-edachali-dbx <[email protected]> * remove SeaResultSet Signed-off-by: varun-edachali-dbx <[email protected]> * clean imports and attributes Signed-off-by: varun-edachali-dbx <[email protected]> * pass CommandId to ExecResp Signed-off-by: varun-edachali-dbx <[email protected]> * remove changes in types Signed-off-by: varun-edachali-dbx <[email protected]> * add back essential types (ExecResponse, from_sea_state) Signed-off-by: varun-edachali-dbx <[email protected]> * fix fetch types Signed-off-by: varun-edachali-dbx <[email protected]> * excess imports Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff by maintaining logs Signed-off-by: varun-edachali-dbx <[email protected]> * fix int test types Signed-off-by: varun-edachali-dbx <[email protected]> * move guid_to_hex_id import to utils Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff in guid utils import Signed-off-by: varun-edachali-dbx <[email protected]> * move arrow_schema_bytes back into ExecuteResult Signed-off-by: varun-edachali-dbx <[email protected]> * maintain log Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary assignment Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary tuple response Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-ncessary verbose mocking Signed-off-by: varun-edachali-dbx <[email protected]> * move Queue construction to ResultSert Signed-off-by: varun-edachali-dbx <[email protected]> * move description to List[Tuple] Signed-off-by: varun-edachali-dbx <[email protected]> * frmatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff (remove explicit tuple conversion) Signed-off-by: varun-edachali-dbx <[email protected]> * remove has_more_rows from ExecuteResponse Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary has_more_rows aclc Signed-off-by: varun-edachali-dbx <[email protected]> * default has_more_rows to True Signed-off-by: varun-edachali-dbx <[email protected]> * return has_more_rows from ExecResponse conversion during GetRespMetadata Signed-off-by: varun-edachali-dbx <[email protected]> * remove unnecessary replacement Signed-off-by: varun-edachali-dbx <[email protected]> * better mocked backend naming Signed-off-by: varun-edachali-dbx <[email protected]> * remove has_more_rows test in ExecuteResponse Signed-off-by: varun-edachali-dbx <[email protected]> * introduce replacement of original has_more_rows read test Signed-off-by: varun-edachali-dbx <[email protected]> * call correct method in test_use_arrow_schema Signed-off-by: varun-edachali-dbx <[email protected]> * call correct method in test_fall_back_to_hive_schema Signed-off-by: varun-edachali-dbx <[email protected]> * re-introduce result response read test Signed-off-by: varun-edachali-dbx <[email protected]> * simplify test Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess fetch_results mocks Signed-off-by: varun-edachali-dbx <[email protected]> * more minimal changes to thrift_backend tests Signed-off-by: varun-edachali-dbx <[email protected]> * move back to old table types Signed-off-by: varun-edachali-dbx <[email protected]> * remove outdated arrow_schema_bytes return Signed-off-by: varun-edachali-dbx <[email protected]> * remove duplicate import Signed-off-by: varun-edachali-dbx <[email protected]> * rephrase model docstrings to explicitly denote that they are representations and not used over the wire Signed-off-by: varun-edachali-dbx <[email protected]> * has_more_rows -> is_direct_results Signed-off-by: varun-edachali-dbx <[email protected]> * switch docstring format to align with Connection class Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> * Introduce models for `SeaDatabricksClient` (#595) * [squash from exec-sea] bring over execution phase changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess test Signed-off-by: varun-edachali-dbx <[email protected]> * add docstring Signed-off-by: varun-edachali-dbx <[email protected]> * remvoe exec func in sea backend Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess files Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess models Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess sea backend tests Signed-off-by: varun-edachali-dbx <[email protected]> * cleanup Signed-off-by: varun-edachali-dbx <[email protected]> * re-introduce get_schema_desc Signed-off-by: varun-edachali-dbx <[email protected]> * remove SeaResultSet Signed-off-by: varun-edachali-dbx <[email protected]> * clean imports and attributes Signed-off-by: varun-edachali-dbx <[email protected]> * pass CommandId to ExecResp Signed-off-by: varun-edachali-dbx <[email protected]> * remove changes in types Signed-off-by: varun-edachali-dbx <[email protected]> * add back essential types (ExecResponse, from_sea_state) Signed-off-by: varun-edachali-dbx <[email protected]> * fix fetch types Signed-off-by: varun-edachali-dbx <[email protected]> * excess imports Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff by maintaining logs Signed-off-by: varun-edachali-dbx <[email protected]> * fix int test types Signed-off-by: varun-edachali-dbx <[email protected]> * [squashed from exec-sea] init execution func Signed-off-by: varun-edachali-dbx <[email protected]> * remove irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove ResultSetFilter functionality Signed-off-by: varun-edachali-dbx <[email protected]> * remove more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * even more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove sea response as init option Signed-off-by: varun-edachali-dbx <[email protected]> * exec test example scripts Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * [squashed from sea-exec] merge sea stuffs Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess removed docstring Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess changes in backend Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess imports Signed-off-by: varun-edachali-dbx <[email protected]> * remove accidentally removed _get_schema_desc Signed-off-by: varun-edachali-dbx <[email protected]> * remove unnecessary init with sea_response tests Signed-off-by: varun-edachali-dbx <[email protected]> * rmeove unnecessary changes Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * improved models and filters from cloudfetch-sea branch Signed-off-by: varun-edachali-dbx <[email protected]> * filters stuff (align with JDBC) Signed-off-by: varun-edachali-dbx <[email protected]> * backend from cloudfetch-sea Signed-off-by: varun-edachali-dbx <[email protected]> * remove filtering, metadata ops Signed-off-by: varun-edachali-dbx <[email protected]> * raise NotImplementedErrror for metadata ops Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary backend cahnges Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-needed GetChunksResponse only relevant in Fetch phase Signed-off-by: varun-edachali-dbx <[email protected]> * reduce code duplication Signed-off-by: varun-edachali-dbx <[email protected]> * more clear docstrings Signed-off-by: varun-edachali-dbx <[email protected]> * introduce strongly typed ChunkInfo Signed-off-by: varun-edachali-dbx <[email protected]> * remove is_volume_operation from response Signed-off-by: varun-edachali-dbx <[email protected]> * add is_volume_op and more ResultData fields Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> * Introduce preliminary SEA Result Set (#588) * [squash from exec-sea] bring over execution phase changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess test Signed-off-by: varun-edachali-dbx <[email protected]> * add docstring Signed-off-by: varun-edachali-dbx <[email protected]> * remvoe exec func in sea backend Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess files Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess models Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess sea backend tests Signed-off-by: varun-edachali-dbx <[email protected]> * cleanup Signed-off-by: varun-edachali-dbx <[email protected]> * re-introduce get_schema_desc Signed-off-by: varun-edachali-dbx <[email protected]> * remove SeaResultSet Signed-off-by: varun-edachali-dbx <[email protected]> * clean imports and attributes Signed-off-by: varun-edachali-dbx <[email protected]> * pass CommandId to ExecResp Signed-off-by: varun-edachali-dbx <[email protected]> * remove changes in types Signed-off-by: varun-edachali-dbx <[email protected]> * add back essential types (ExecResponse, from_sea_state) Signed-off-by: varun-edachali-dbx <[email protected]> * fix fetch types Signed-off-by: varun-edachali-dbx <[email protected]> * excess imports Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff by maintaining logs Signed-off-by: varun-edachali-dbx <[email protected]> * fix int test types Signed-off-by: varun-edachali-dbx <[email protected]> * [squashed from exec-sea] init execution func Signed-off-by: varun-edachali-dbx <[email protected]> * remove irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove ResultSetFilter functionality Signed-off-by: varun-edachali-dbx <[email protected]> * remove more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * even more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove sea response as init option Signed-off-by: varun-edachali-dbx <[email protected]> * move guid_to_hex_id import to utils Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff in guid utils import Signed-off-by: varun-edachali-dbx <[email protected]> * move arrow_schema_bytes back into ExecuteResult Signed-off-by: varun-edachali-dbx <[email protected]> * maintain log Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary assignment Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary tuple response Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-ncessary verbose mocking Signed-off-by: varun-edachali-dbx <[email protected]> * move Queue construction to ResultSert Signed-off-by: varun-edachali-dbx <[email protected]> * move description to List[Tuple] Signed-off-by: varun-edachali-dbx <[email protected]> * frmatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff (remove explicit tuple conversion) Signed-off-by: varun-edachali-dbx <[email protected]> * remove has_more_rows from ExecuteResponse Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary has_more_rows aclc Signed-off-by: varun-edachali-dbx <[email protected]> * default has_more_rows to True Signed-off-by: varun-edachali-dbx <[email protected]> * return has_more_rows from ExecResponse conversion during GetRespMetadata Signed-off-by: varun-edachali-dbx <[email protected]> * remove unnecessary replacement Signed-off-by: varun-edachali-dbx <[email protected]> * better mocked backend naming Signed-off-by: varun-edachali-dbx <[email protected]> * remove has_more_rows test in ExecuteResponse Signed-off-by: varun-edachali-dbx <[email protected]> * introduce replacement of original has_more_rows read test Signed-off-by: varun-edachali-dbx <[email protected]> * call correct method in test_use_arrow_schema Signed-off-by: varun-edachali-dbx <[email protected]> * call correct method in test_fall_back_to_hive_schema Signed-off-by: varun-edachali-dbx <[email protected]> * re-introduce result response read test Signed-off-by: varun-edachali-dbx <[email protected]> * simplify test Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess fetch_results mocks Signed-off-by: varun-edachali-dbx <[email protected]> * more minimal changes to thrift_backend tests Signed-off-by: varun-edachali-dbx <[email protected]> * move back to old table types Signed-off-by: varun-edachali-dbx <[email protected]> * remove outdated arrow_schema_bytes return Signed-off-by: varun-edachali-dbx <[email protected]> * align SeaResultSet with new structure Signed-off-by: varun-edachali-dbx <[email protected]> * correct sea res set tests Signed-off-by: varun-edachali-dbx <[email protected]> * remove duplicate import Signed-off-by: varun-edachali-dbx <[email protected]> * rephrase model docstrings to explicitly denote that they are representations and not used over the wire Signed-off-by: varun-edachali-dbx <[email protected]> * has_more_rows -> is_direct_results Signed-off-by: varun-edachali-dbx <[email protected]> * switch docstring format to align with Connection class Signed-off-by: varun-edachali-dbx <[email protected]> * has_more_rows -> is_direct_results Signed-off-by: varun-edachali-dbx <[email protected]> * fix type errors with arrow_schema_bytes Signed-off-by: varun-edachali-dbx <[email protected]> * spaces after multi line pydocs Signed-off-by: varun-edachali-dbx <[email protected]> * remove duplicate queue init (merge artifact) Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff (remove newlines) Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary changes covered by #588 anyway Signed-off-by: varun-edachali-dbx <[email protected]> * Revert "remove un-necessary changes" This reverts commit a70a6cee277db44d6951604e890f91cae9f92f32. Signed-off-by: varun-edachali-dbx <[email protected]> * b"" -> None Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> * remove invalid ExecuteResponse import Signed-off-by: varun-edachali-dbx <[email protected]> * Separate Session related functionality from Connection class (#571) * decouple session class from existing Connection ensure maintenance of current APIs of Connection while delegating responsibility Signed-off-by: varun-edachali-dbx <[email protected]> * add open property to Connection to ensure maintenance of existing API Signed-off-by: varun-edachali-dbx <[email protected]> * update unit tests to address ThriftBackend through session instead of through Connection Signed-off-by: varun-edachali-dbx <[email protected]> * chore: move session specific tests from test_client to test_session Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) as in CONTRIBUTING.md Signed-off-by: varun-edachali-dbx <[email protected]> * use connection open property instead of long chain through session Signed-off-by: varun-edachali-dbx <[email protected]> * trigger integration workflow Signed-off-by: varun-edachali-dbx <[email protected]> * fix: ensure open attribute of Connection never fails in case the openSession takes long, the initialisation of the session will not complete immediately. This could make the session attribute inaccessible. If the Connection is deleted in this time, the open() check will throw because the session attribute does not exist. Thus, we default to the Connection being closed in this case. This was not an issue before because open was a direct attribute of the Connection class. Caught in the integration tests. Signed-off-by: varun-edachali-dbx <[email protected]> * fix: de-complicate earlier connection open logic earlier, one of the integration tests was failing because 'session was not an attribute of Connection'. This is likely tied to a local configuration issue related to unittest that was causing an error in the test suite itself. The tests are now passing without checking for the session attribute. https://github.com/databricks/databricks-sql-python/pull/567/commits/c676f9b0281cc3e4fe9c6d8216cc62fc75eade3b Signed-off-by: varun-edachali-dbx <[email protected]> * Revert "fix: de-complicate earlier connection open logic" This reverts commit d6b1b196c98a6e9d8e593a88c34bbde010519ef4. Signed-off-by: varun-edachali-dbx <[email protected]> * [empty commit] attempt to trigger ci e2e workflow Signed-off-by: varun-edachali-dbx <[email protected]> * Update CODEOWNERS (#562) new codeowners Signed-off-by: varun-edachali-dbx <[email protected]> * Enhance Cursor close handling and context manager exception management to prevent server side resource leaks (#554) * Enhance Cursor close handling and context manager exception management * tests * fmt * Fix Cursor.close() to properly handle CursorAlreadyClosedError * Remove specific test message from Cursor.close() error handling * Improve error handling in connection and cursor context managers to ensure proper closure during exceptions, including KeyboardInterrupt. Add tests for nested cursor management and verify operation closure on server-side errors. * add * add Signed-off-by: varun-edachali-dbx <[email protected]> * PECOBLR-86 improve logging on python driver (#556) * PECOBLR-86 Improve logging for debug level Signed-off-by: Sai Shree Pradhan <[email protected]> * PECOBLR-86 Improve logging for debug level Signed-off-by: Sai Shree Pradhan <[email protected]> * fixed format Signed-off-by: Sai Shree Pradhan <[email protected]> * used lazy logging Signed-off-by: Sai Shree Pradhan <[email protected]> * changed debug to error logs Signed-off-by: Sai Shree Pradhan <[email protected]> * used lazy logging Signed-off-by: Sai Shree Pradhan <[email protected]> --------- Signed-off-by: Sai Shree Pradhan <[email protected]> Signed-off-by: varun-edachali-dbx <[email protected]> * Revert "Merge remote-tracking branch 'upstream/sea-migration' into decouple-session" This reverts commit dbb2ec52306b91072a2ee842270c7113aece9aff, reversing changes made to 7192f117279d4f0adcbafcdf2238c18663324515. Signed-off-by: varun-edachali-dbx <[email protected]> * Reapply "Merge remote-tracking branch 'upstream/sea-migration' into decouple-session" This reverts commit bdb83817f49e1d88a01679b11da8e55e8e80b42f. Signed-off-by: varun-edachali-dbx <[email protected]> * fix: separate session opening logic from instantiation ensures correctness of self.session.open call in Connection Signed-off-by: varun-edachali-dbx <[email protected]> * fix: use is_open attribute to denote session availability Signed-off-by: varun-edachali-dbx <[email protected]> * fix: access thrift backend through session Signed-off-by: varun-edachali-dbx <[email protected]> * chore: use get_handle() instead of private session attribute in client Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * fix: remove accidentally removed assertions Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> Signed-off-by: Sai Shree Pradhan <[email protected]> Co-authored-by: Jothi Prakash <[email protected]> Co-authored-by: Madhav Sainanee <[email protected]> Co-authored-by: Sai Shree Pradhan <[email protected]> * Introduce Backend Interface (DatabricksClient) (#573) NOTE: the `test_complex_types` e2e test was not working at the time of this merge. The test must be triggered when the test is back up and running as intended. * remove excess logs, assertions, instantiations large merge artifacts Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) + remove excess log (merge artifact) Signed-off-by: varun-edachali-dbx <[email protected]> * fix typing Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary check Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary replace call Signed-off-by: varun-edachali-dbx <[email protected]> * introduce __str__ methods for CommandId and SessionId Signed-off-by: varun-edachali-dbx <[email protected]> * docstrings for DatabricksClient interface Signed-off-by: varun-edachali-dbx <[email protected]> * stronger typing of Cursor and ExecuteResponse Signed-off-by: varun-edachali-dbx <[email protected]> * remove utility functions from backend interface, fix circular import Signed-off-by: varun-edachali-dbx <[email protected]> * rename info to properties Signed-off-by: varun-edachali-dbx <[email protected]> * newline for cleanliness Signed-off-by: varun-edachali-dbx <[email protected]> * fix circular import Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * to_hex_id -> get_hex_id Signed-off-by: varun-edachali-dbx <[email protected]> * better comment on protocol version getter Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * move guid to hex id to new utils module Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * move staging allowed local path to connection props Signed-off-by: varun-edachali-dbx <[email protected]> * add strong return type for execute_command Signed-off-by: varun-edachali-dbx <[email protected]> * skip auth, error handling in databricksclient interface Signed-off-by: varun-edachali-dbx <[email protected]> * chore: docstring + line width Signed-off-by: varun-edachali-dbx <[email protected]> * get_id -> get_guid Signed-off-by: varun-edachali-dbx <[email protected]> * chore: docstring Signed-off-by: varun-edachali-dbx <[email protected]> * fix: to_hex_id -> to_hex_guid Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> * Implement ResultSet Abstraction (backend interfaces for fetch phase) (#574) * ensure backend client returns a ResultSet type in backend tests Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * newline for cleanliness Signed-off-by: varun-edachali-dbx <[email protected]> * fix circular import Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * to_hex_id -> get_hex_id Signed-off-by: varun-edachali-dbx <[email protected]> * better comment on protocol version getter Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * stricter typing for cursor Signed-off-by: varun-edachali-dbx <[email protected]> * correct typing Signed-off-by: varun-edachali-dbx <[email protected]> * correct tests and merge artifacts Signed-off-by: varun-edachali-dbx <[email protected]> * remove accidentally modified workflow files remnants of old merge Signed-off-by: varun-edachali-dbx <[email protected]> * chore: remove accidentally modified workflow files Signed-off-by: varun-edachali-dbx <[email protected]> * add back accidentally removed docstrings Signed-off-by: varun-edachali-dbx <[email protected]> * clean up docstrings Signed-off-by: varun-edachali-dbx <[email protected]> * log hex Signed-off-by: varun-edachali-dbx <[email protected]> * remove unnecessary _replace call Signed-off-by: varun-edachali-dbx <[email protected]> * add __str__ for CommandId Signed-off-by: varun-edachali-dbx <[email protected]> * take TOpenSessionResp in get_protocol_version to maintain existing interface Signed-off-by: varun-edachali-dbx <[email protected]> * active_op_handle -> active_mmand_id Signed-off-by: varun-edachali-dbx <[email protected]> * ensure None returned for close_command Signed-off-by: varun-edachali-dbx <[email protected]> * account for ResultSet return in new pydocs Signed-off-by: varun-edachali-dbx <[email protected]> * pydoc for types Signed-off-by: varun-edachali-dbx <[email protected]> * move common state to ResultSet aprent Signed-off-by: varun-edachali-dbx <[email protected]> * stronger typing in resultSet behaviour Signed-off-by: varun-edachali-dbx <[email protected]> * remove redundant patch in test Signed-off-by: varun-edachali-dbx <[email protected]> * add has_been_closed_server_side assertion Signed-off-by: varun-edachali-dbx <[email protected]> * remove redundancies in tests Signed-off-by: varun-edachali-dbx <[email protected]> * more robust close check Signed-off-by: varun-edachali-dbx <[email protected]> * use normalised state in e2e test Signed-off-by: varun-edachali-dbx <[email protected]> * simplify corrected test Signed-off-by: varun-edachali-dbx <[email protected]> * add line gaps after multi-line pydocs for consistency Signed-off-by: varun-edachali-dbx <[email protected]> * use normalised CommandState type in ExecuteResponse Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary initialisation assertions Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary line break s Signed-off-by: varun-edachali-dbx <[email protected]> * more un-necessary line breaks Signed-off-by: varun-edachali-dbx <[email protected]> * constrain diff of test_closing_connection_closes_commands Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff of test_closing_connection_closes_commands Signed-off-by: varun-edachali-dbx <[email protected]> * use pytest-like assertions for test_closing_connection_closes_commands Signed-off-by: varun-edachali-dbx <[email protected]> * ensure command_id is not None Signed-off-by: varun-edachali-dbx <[email protected]> * line breaks after multi-line pyfocs Signed-off-by: varun-edachali-dbx <[email protected]> * ensure non null operationHandle for commandId creation Signed-off-by: varun-edachali-dbx <[email protected]> * use command_id methods instead of explicit guid_to_hex_id conversion Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary artifacts in test_session, add back assertion Signed-off-by: varun-edachali-dbx <[email protected]> * Implement SeaDatabricksClient (Complete Execution Spec) (#590) * [squash from exec-sea] bring over execution phase changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess test Signed-off-by: varun-edachali-dbx <[email protected]> * add docstring Signed-off-by: varun-edachali-dbx <[email protected]> * remvoe exec func in sea backend Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess files Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess models Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess sea backend tests Signed-off-by: varun-edachali-dbx <[email protected]> * cleanup Signed-off-by: varun-edachali-dbx <[email protected]> * re-introduce get_schema_desc Signed-off-by: varun-edachali-dbx <[email protected]> * remove SeaResultSet Signed-off-by: varun-edachali-dbx <[email protected]> * clean imports and attributes Signed-off-by: varun-edachali-dbx <[email protected]> * pass CommandId to ExecResp Signed-off-by: varun-edachali-dbx <[email protected]> * remove changes in types Signed-off-by: varun-edachali-dbx <[email protected]> * add back essential types (ExecResponse, from_sea_state) Signed-off-by: varun-edachali-dbx <[email protected]> * fix fetch types Signed-off-by: varun-edachali-dbx <[email protected]> * excess imports Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff by maintaining logs Signed-off-by: varun-edachali-dbx <[email protected]> * fix int test types Signed-off-by: varun-edachali-dbx <[email protected]> * [squashed from exec-sea] init execution func Signed-off-by: varun-edachali-dbx <[email protected]> * remove irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove ResultSetFilter functionality Signed-off-by: varun-edachali-dbx <[email protected]> * remove more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * even more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove sea response as init option Signed-off-by: varun-edachali-dbx <[email protected]> * exec test example scripts Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * [squashed from sea-exec] merge sea stuffs Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess removed docstring Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess changes in backend Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess imports Signed-off-by: varun-edachali-dbx <[email protected]> * remove accidentally removed _get_schema_desc Signed-off-by: varun-edachali-dbx <[email protected]> * remove unnecessary init with sea_response tests Signed-off-by: varun-edachali-dbx <[email protected]> * rmeove unnecessary changes Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * improved models and filters from cloudfetch-sea branch Signed-off-by: varun-edachali-dbx <[email protected]> * filters stuff (align with JDBC) Signed-off-by: varun-edachali-dbx <[email protected]> * backend from cloudfetch-sea Signed-off-by: varun-edachali-dbx <[email protected]> * remove filtering, metadata ops Signed-off-by: varun-edachali-dbx <[email protected]> * raise NotImplementedErrror for metadata ops Signed-off-by: varun-edachali-dbx <[email protected]> * change to valid table name Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary changes covered by #588 Signed-off-by: varun-edachali-dbx <[email protected]> * simplify test module Signed-off-by: varun-edachali-dbx <[email protected]> * logging -> debug level Signed-off-by: varun-edachali-dbx <[email protected]> * change table name in log Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary backend cahnges Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-needed GetChunksResponse Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-needed GetChunksResponse only relevant in Fetch phase Signed-off-by: varun-edachali-dbx <[email protected]> * reduce code duplication in response parsing Signed-off-by: varun-edachali-dbx <[email protected]> * reduce code duplication Signed-off-by: varun-edachali-dbx <[email protected]> * more clear docstrings Signed-off-by: varun-edachali-dbx <[email protected]> * introduce strongly typed ChunkInfo Signed-off-by: varun-edachali-dbx <[email protected]> * remove is_volume_operation from response Signed-off-by: varun-edachali-dbx <[email protected]> * add is_volume_op and more ResultData fields Signed-off-by: varun-edachali-dbx <[email protected]> * add test scripts Signed-off-by: varun-edachali-dbx <[email protected]> * Revert "Merge branch 'exec-models-sea' into exec-phase-sea" This reverts commit be1997e0d6b6cf0f5499db2381971ec3a015a2f7, reversing changes made to 37813ba6d1fe06d7f9f10d510a059b88dc552496. * change logging level Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove _get_schema_bytes (for now) Signed-off-by: varun-edachali-dbx <[email protected]> * redundant comments Signed-off-by: varun-edachali-dbx <[email protected]> * remove fetch phase methods Signed-off-by: varun-edachali-dbx <[email protected]> * reduce code repetititon + introduce gaps after multi line pydocs Signed-off-by: varun-edachali-dbx <[email protected]> * remove unused imports Signed-off-by: varun-edachali-dbx <[email protected]> * move description extraction to helper func Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * add more unit tests Signed-off-by: varun-edachali-dbx <[email protected]> * streamline unit tests Signed-off-by: varun-edachali-dbx <[email protected]> * test getting the list of allowed configurations Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff Signed-off-by: varun-edachali-dbx <[email protected]> * house constants in enums for readability and immutability Signed-off-by: varun-edachali-dbx <[email protected]> * add note on hybrid disposition Signed-off-by: varun-edachali-dbx <[email protected]> * remove redundant note on arrow_schema_bytes Signed-off-by: varun-edachali-dbx <[email protected]> * remove invalid import Signed-off-by: varun-edachali-dbx <[email protected]> * add strong typing for manifest in _extract_description Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary column skipping Signed-off-by: varun-edachali-dbx <[email protected]> * remove parsing in backend Signed-off-by: varun-edachali-dbx <[email protected]> * fix: convert sea statement id to CommandId type Signed-off-by: varun-edachali-dbx <[email protected]> * make polling interval a separate constant Signed-off-by: varun-edachali-dbx <[email protected]> * align state checking with Thrift implementation Signed-off-by: varun-edachali-dbx <[email protected]> * update unit tests according to changes Signed-off-by: varun-edachali-dbx <[email protected]> * add unit tests for added methods Signed-off-by: varun-edachali-dbx <[email protected]> * add spec to description extraction docstring, add strong typing to params Signed-off-by: varun-edachali-dbx <[email protected]> * add strong typing for backend parameters arg Signed-off-by: varun-edachali-dbx <[email protected]> --------- Signed-off-by: varun-edachali-dbx <[email protected]> * add from __future__ import annotations to remove string literals around forward refs, remove some unused imports Signed-off-by: varun-edachali-dbx <[email protected]> * move docstring of DatabricksClient within class Signed-off-by: varun-edachali-dbx <[email protected]> * move ThriftResultSet import to top of file Signed-off-by: varun-edachali-dbx <[email protected]> * make backend/utils __init__ file empty Signed-off-by: varun-edachali-dbx <[email protected]> * use from __future__ import annotations to remove string literals around Cursor Signed-off-by: varun-edachali-dbx <[email protected]> * use lazy logging Signed-off-by: varun-edachali-dbx <[email protected]> * replace getters with property tag Signed-off-by: varun-edachali-dbx <[email protected]> * set active_command_id to None, not active_op_handle Signed-off-by: varun-edachali-dbx <[email protected]> * align test_session with pytest instead of unittest Signed-off-by: varun-edachali-dbx <[email protected]> * remove duplicate test, correct active_command_id attribute Signed-off-by: varun-edachali-dbx <[email protected]> * SeaDatabricksClient: Add Metadata Commands (#593) * [squash from exec-sea] bring over execution phase changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess test Signed-off-by: varun-edachali-dbx <[email protected]> * add docstring Signed-off-by: varun-edachali-dbx <[email protected]> * remvoe exec func in sea backend Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess files Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess models Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess sea backend tests Signed-off-by: varun-edachali-dbx <[email protected]> * cleanup Signed-off-by: varun-edachali-dbx <[email protected]> * re-introduce get_schema_desc Signed-off-by: varun-edachali-dbx <[email protected]> * remove SeaResultSet Signed-off-by: varun-edachali-dbx <[email protected]> * clean imports and attributes Signed-off-by: varun-edachali-dbx <[email protected]> * pass CommandId to ExecResp Signed-off-by: varun-edachali-dbx <[email protected]> * remove changes in types Signed-off-by: varun-edachali-dbx <[email protected]> * add back essential types (ExecResponse, from_sea_state) Signed-off-by: varun-edachali-dbx <[email protected]> * fix fetch types Signed-off-by: varun-edachali-dbx <[email protected]> * excess imports Signed-off-by: varun-edachali-dbx <[email protected]> * reduce diff by maintaining logs Signed-off-by: varun-edachali-dbx <[email protected]> * fix int test types Signed-off-by: varun-edachali-dbx <[email protected]> * [squashed from exec-sea] init execution func Signed-off-by: varun-edachali-dbx <[email protected]> * remove irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove ResultSetFilter functionality Signed-off-by: varun-edachali-dbx <[email protected]> * remove more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * even more irrelevant changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove sea response as init option Signed-off-by: varun-edachali-dbx <[email protected]> * exec test example scripts Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * [squashed from sea-exec] merge sea stuffs Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess removed docstring Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess changes in backend Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess imports Signed-off-by: varun-edachali-dbx <[email protected]> * remove accidentally removed _get_schema_desc Signed-off-by: varun-edachali-dbx <[email protected]> * remove unnecessary init with sea_response tests Signed-off-by: varun-edachali-dbx <[email protected]> * rmeove unnecessary changes Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * improved models and filters from cloudfetch-sea branch Signed-off-by: varun-edachali-dbx <[email protected]> * filters stuff (align with JDBC) Signed-off-by: varun-edachali-dbx <[email protected]> * backend from cloudfetch-sea Signed-off-by: varun-edachali-dbx <[email protected]> * remove filtering, metadata ops Signed-off-by: varun-edachali-dbx <[email protected]> * raise NotImplementedErrror for metadata ops Signed-off-by: varun-edachali-dbx <[email protected]> * add metadata commands Signed-off-by: varun-edachali-dbx <[email protected]> * formatting (black) Signed-off-by: varun-edachali-dbx <[email protected]> * add metadata command unit tests Signed-off-by: varun-edachali-dbx <[email protected]> * change to valid table name Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary changes covered by #588 Signed-off-by: varun-edachali-dbx <[email protected]> * simplify test module Signed-off-by: varun-edachali-dbx <[email protected]> * logging -> debug level Signed-off-by: varun-edachali-dbx <[email protected]> * change table name in log Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary backend cahnges Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-needed GetChunksResponse Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-needed GetChunksResponse only relevant in Fetch phase Signed-off-by: varun-edachali-dbx <[email protected]> * reduce code duplication in response parsing Signed-off-by: varun-edachali-dbx <[email protected]> * reduce code duplication Signed-off-by: varun-edachali-dbx <[email protected]> * more clear docstrings Signed-off-by: varun-edachali-dbx <[email protected]> * introduce strongly typed ChunkInfo Signed-off-by: varun-edachali-dbx <[email protected]> * remove is_volume_operation from response Signed-off-by: varun-edachali-dbx <[email protected]> * add is_volume_op and more ResultData fields Signed-off-by: varun-edachali-dbx <[email protected]> * add test scripts Signed-off-by: varun-edachali-dbx <[email protected]> * Revert "Merge branch 'sea-migration' into exec-models-sea" This reverts commit 8bd12d829ea13abf8fc1507fff8cb21751001c67, reversing changes made to 030edf8df3db487b7af8d910ee51240d1339229e. * Revert "Merge branch 'exec-models-sea' into exec-phase-sea" This reverts commit be1997e0d6b6cf0f5499db2381971ec3a015a2f7, reversing changes made to 37813ba6d1fe06d7f9f10d510a059b88dc552496. * change logging level Signed-off-by: varun-edachali-dbx <[email protected]> * remove un-necessary changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove excess changes Signed-off-by: varun-edachali-dbx <[email protected]> * remove _get_schema_bytes (for now) Signed-off-by: varun-edachali-dbx <[email protected]> * redundant comments S…
1 parent 71d306f commit 0a7a6ab

35 files changed

+3102
-525
lines changed

examples/experimental/tests/test_sea_async_query.py

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,20 @@ def test_sea_async_query_with_cloud_fetch():
5252
f"Successfully opened SEA session with ID: {connection.get_session_id_hex()}"
5353
)
5454

55-
# Execute a simple query asynchronously
55+
# Execute a query that generates large rows to force multiple chunks
56+
requested_row_count = 5000
5657
cursor = connection.cursor()
58+
query = f"""
59+
SELECT
60+
id,
61+
concat('value_', repeat('a', 10000)) as test_value
62+
FROM range(1, {requested_row_count} + 1) AS t(id)
63+
"""
64+
5765
logger.info(
58-
"Executing asynchronous query with cloud fetch: SELECT 1 as test_value"
66+
f"Executing asynchronous query with cloud fetch to generate {requested_row_count} rows"
5967
)
60-
cursor.execute_async("SELECT 1 as test_value")
68+
cursor.execute_async(query)
6169
logger.info(
6270
"Asynchronous query submitted successfully with cloud fetch enabled"
6371
)
@@ -70,8 +78,25 @@ def test_sea_async_query_with_cloud_fetch():
7078

7179
logger.info("Query is no longer pending, getting results...")
7280
cursor.get_async_execution_result()
81+
82+
results = [cursor.fetchone()]
83+
results.extend(cursor.fetchmany(10))
84+
results.extend(cursor.fetchall())
85+
actual_row_count = len(results)
86+
87+
logger.info(
88+
f"Requested {requested_row_count} rows, received {actual_row_count} rows"
89+
)
90+
91+
# Verify total row count
92+
if actual_row_count != requested_row_count:
93+
logger.error(
94+
f"FAIL: Row count mismatch. Expected {requested_row_count}, got {actual_row_count}"
95+
)
96+
return False
97+
7398
logger.info(
74-
"Successfully retrieved asynchronous query results with cloud fetch enabled"
99+
"PASS: Received correct number of rows with cloud fetch and all fetch methods work correctly"
75100
)
76101

77102
# Close resources
@@ -131,12 +156,20 @@ def test_sea_async_query_without_cloud_fetch():
131156
f"Successfully opened SEA session with ID: {connection.get_session_id_hex()}"
132157
)
133158

134-
# Execute a simple query asynchronously
159+
# For non-cloud fetch, use a smaller row count to avoid exceeding inline limits
160+
requested_row_count = 100
135161
cursor = connection.cursor()
162+
query = f"""
163+
SELECT
164+
id,
165+
concat('value_', repeat('a', 100)) as test_value
166+
FROM range(1, {requested_row_count} + 1) AS t(id)
167+
"""
168+
136169
logger.info(
137-
"Executing asynchronous query without cloud fetch: SELECT 1 as test_value"
170+
f"Executing asynchronous query without cloud fetch to generate {requested_row_count} rows"
138171
)
139-
cursor.execute_async("SELECT 1 as test_value")
172+
cursor.execute_async(query)
140173
logger.info(
141174
"Asynchronous query submitted successfully with cloud fetch disabled"
142175
)
@@ -149,8 +182,24 @@ def test_sea_async_query_without_cloud_fetch():
149182

150183
logger.info("Query is no longer pending, getting results...")
151184
cursor.get_async_execution_result()
185+
results = [cursor.fetchone()]
186+
results.extend(cursor.fetchmany(10))
187+
results.extend(cursor.fetchall())
188+
actual_row_count = len(results)
189+
190+
logger.info(
191+
f"Requested {requested_row_count} rows, received {actual_row_count} rows"
192+
)
193+
194+
# Verify total row count
195+
if actual_row_count != requested_row_count:
196+
logger.error(
197+
f"FAIL: Row count mismatch. Expected {requested_row_count}, got {actual_row_count}"
198+
)
199+
return False
200+
152201
logger.info(
153-
"Successfully retrieved asynchronous query results with cloud fetch disabled"
202+
"PASS: Received correct number of rows without cloud fetch and all fetch methods work correctly"
154203
)
155204

156205
# Close resources

examples/experimental/tests/test_sea_sync_query.py

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,34 @@ def test_sea_sync_query_with_cloud_fetch():
5050
f"Successfully opened SEA session with ID: {connection.get_session_id_hex()}"
5151
)
5252

53-
# Execute a simple query
53+
# Execute a query that generates large rows to force multiple chunks
54+
requested_row_count = 10000
5455
cursor = connection.cursor()
56+
query = f"""
57+
SELECT
58+
id,
59+
concat('value_', repeat('a', 10000)) as test_value
60+
FROM range(1, {requested_row_count} + 1) AS t(id)
61+
"""
62+
63+
logger.info(
64+
f"Executing synchronous query with cloud fetch to generate {requested_row_count} rows"
65+
)
66+
cursor.execute(query)
67+
results = [cursor.fetchone()]
68+
results.extend(cursor.fetchmany(10))
69+
results.extend(cursor.fetchall())
70+
actual_row_count = len(results)
5571
logger.info(
56-
"Executing synchronous query with cloud fetch: SELECT 1 as test_value"
72+
f"{actual_row_count} rows retrieved against {requested_row_count} requested"
5773
)
58-
cursor.execute("SELECT 1 as test_value")
59-
logger.info("Query executed successfully with cloud fetch enabled")
74+
75+
# Verify total row count
76+
if actual_row_count != requested_row_count:
77+
logger.error(
78+
f"FAIL: Row count mismatch. Expected {requested_row_count}, got {actual_row_count}"
79+
)
80+
return False
6081

6182
# Close resources
6283
cursor.close()
@@ -115,13 +136,30 @@ def test_sea_sync_query_without_cloud_fetch():
115136
f"Successfully opened SEA session with ID: {connection.get_session_id_hex()}"
116137
)
117138

118-
# Execute a simple query
139+
# For non-cloud fetch, use a smaller row count to avoid exceeding inline limits
140+
requested_row_count = 100
119141
cursor = connection.cursor()
120142
logger.info(
121-
"Executing synchronous query without cloud fetch: SELECT 1 as test_value"
143+
f"Executing synchronous query without cloud fetch: SELECT {requested_row_count} rows"
144+
)
145+
cursor.execute(
146+
"SELECT id, 'test_value_' || CAST(id as STRING) as test_value FROM range(1, 101)"
122147
)
123-
cursor.execute("SELECT 1 as test_value")
124-
logger.info("Query executed successfully with cloud fetch disabled")
148+
149+
results = [cursor.fetchone()]
150+
results.extend(cursor.fetchmany(10))
151+
results.extend(cursor.fetchall())
152+
actual_row_count = len(results)
153+
logger.info(
154+
f"{actual_row_count} rows retrieved against {requested_row_count} requested"
155+
)
156+
157+
# Verify total row count
158+
if actual_row_count != requested_row_count:
159+
logger.error(
160+
f"FAIL: Row count mismatch. Expected {requested_row_count}, got {actual_row_count}"
161+
)
162+
return False
125163

126164
# Close resources
127165
cursor.close()

src/databricks/sql/backend/sea/backend.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
import re
66
from typing import Any, Dict, Tuple, List, Optional, Union, TYPE_CHECKING, Set
77

8-
from databricks.sql.backend.sea.models.base import ResultManifest, StatementStatus
8+
from databricks.sql.backend.sea.models.base import (
9+
ExternalLink,
10+
ResultManifest,
11+
StatementStatus,
12+
)
13+
from databricks.sql.backend.sea.models.responses import GetChunksResponse
914
from databricks.sql.backend.sea.utils.constants import (
1015
ALLOWED_SESSION_CONF_TO_DEFAULT_VALUES_MAP,
1116
ResultFormat,
@@ -19,7 +24,7 @@
1924
if TYPE_CHECKING:
2025
from databricks.sql.client import Cursor
2126

22-
from databricks.sql.result_set import SeaResultSet
27+
from databricks.sql.backend.sea.result_set import SeaResultSet
2328

2429
from databricks.sql.backend.databricks_client import DatabricksClient
2530
from databricks.sql.backend.types import (
@@ -110,6 +115,7 @@ class SeaDatabricksClient(DatabricksClient):
110115
STATEMENT_PATH = BASE_PATH + "statements"
111116
STATEMENT_PATH_WITH_ID = STATEMENT_PATH + "/{}"
112117
CANCEL_STATEMENT_PATH_WITH_ID = STATEMENT_PATH + "/{}/cancel"
118+
CHUNK_PATH_WITH_ID_AND_INDEX = STATEMENT_PATH + "/{}/result/chunks/{}"
113119

114120
# SEA constants
115121
POLL_INTERVAL_SECONDS = 0.2
@@ -296,7 +302,7 @@ def close_session(self, session_id: SessionId) -> None:
296302

297303
def _extract_description_from_manifest(
298304
self, manifest: ResultManifest
299-
) -> Optional[List]:
305+
) -> List[Tuple]:
300306
"""
301307
Extract column description from a manifest object, in the format defined by
302308
the spec: https://peps.python.org/pep-0249/#description
@@ -311,9 +317,6 @@ def _extract_description_from_manifest(
311317
schema_data = manifest.schema
312318
columns_data = schema_data.get("columns", [])
313319

314-
if not columns_data:
315-
return None
316-
317320
columns = []
318321
for col_data in columns_data:
319322
# Format: (name, type_code, display_size, internal_size, precision, scale, null_ok)
@@ -337,7 +340,7 @@ def _extract_description_from_manifest(
337340
)
338341
)
339342

340-
return columns if columns else None
343+
return columns
341344

342345
def _results_message_to_execute_response(
343346
self, response: Union[ExecuteStatementResponse, GetStatementResponse]
@@ -358,7 +361,7 @@ def _results_message_to_execute_response(
358361

359362
# Check for compression
360363
lz4_compressed = (
361-
response.manifest.result_compression == ResultCompression.LZ4_FRAME
364+
response.manifest.result_compression == ResultCompression.LZ4_FRAME.value
362365
)
363366

364367
execute_response = ExecuteResponse(
@@ -647,6 +650,27 @@ def get_execution_result(
647650
response = self._poll_query(command_id)
648651
return self._response_to_result_set(response, cursor)
649652

653+
def get_chunk_links(
654+
self, statement_id: str, chunk_index: int
655+
) -> List[ExternalLink]:
656+
"""
657+
Get links for chunks starting from the specified index.
658+
Args:
659+
statement_id: The statement ID
660+
chunk_index: The starting chunk index
661+
Returns:
662+
ExternalLink: External link for the chunk
663+
"""
664+
665+
response_data = self._http_client._make_request(
666+
method="GET",
667+
path=self.CHUNK_PATH_WITH_ID_AND_INDEX.format(statement_id, chunk_index),
668+
)
669+
response = GetChunksResponse.from_dict(response_data)
670+
671+
links = response.external_links or []
672+
return links
673+
650674
# == Metadata Operations ==
651675

652676
def get_catalogs(

src/databricks/sql/backend/sea/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
ExecuteStatementResponse,
2727
GetStatementResponse,
2828
CreateSessionResponse,
29+
GetChunksResponse,
2930
)
3031

3132
__all__ = [
@@ -47,4 +48,5 @@
4748
"ExecuteStatementResponse",
4849
"GetStatementResponse",
4950
"CreateSessionResponse",
51+
"GetChunksResponse",
5052
]

src/databricks/sql/backend/sea/models/responses.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,37 @@ class CreateSessionResponse:
160160
def from_dict(cls, data: Dict[str, Any]) -> "CreateSessionResponse":
161161
"""Create a CreateSessionResponse from a dictionary."""
162162
return cls(session_id=data.get("session_id", ""))
163+
164+
165+
@dataclass
166+
class GetChunksResponse:
167+
"""
168+
Response from getting chunks for a statement.
169+
170+
The response model can be found in the docs, here:
171+
https://docs.databricks.com/api/workspace/statementexecution/getstatementresultchunkn
172+
"""
173+
174+
data: Optional[List[List[Any]]] = None
175+
external_links: Optional[List[ExternalLink]] = None
176+
byte_count: Optional[int] = None
177+
chunk_index: Optional[int] = None
178+
next_chunk_index: Optional[int] = None
179+
next_chunk_internal_link: Optional[str] = None
180+
row_count: Optional[int] = None
181+
row_offset: Optional[int] = None
182+
183+
@classmethod
184+
def from_dict(cls, data: Dict[str, Any]) -> "GetChunksResponse":
185+
"""Create a GetChunksResponse from a dictionary."""
186+
result = _parse_result({"result": data})
187+
return cls(
188+
data=result.data,
189+
external_links=result.external_links,
190+
byte_count=result.byte_count,
191+
chunk_index=result.chunk_index,
192+
next_chunk_index=result.next_chunk_index,
193+
next_chunk_internal_link=result.next_chunk_internal_link,
194+
row_count=result.row_count,
195+
row_offset=result.row_offset,
196+
)

0 commit comments

Comments
 (0)