Skip to content

Commit e732e96

Browse files
Normalise type code (#652)
* 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 …
1 parent a0d7cd1 commit e732e96

File tree

10 files changed

+266
-150
lines changed

10 files changed

+266
-150
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
WaitTimeout,
2020
MetadataCommands,
2121
)
22+
from databricks.sql.backend.sea.utils.normalize import normalize_sea_type_to_thrift
2223
from databricks.sql.thrift_api.TCLIService import ttypes
2324

2425
if TYPE_CHECKING:
@@ -322,6 +323,11 @@ def _extract_description_from_manifest(
322323
# Format: (name, type_code, display_size, internal_size, precision, scale, null_ok)
323324
name = col_data.get("name", "")
324325
type_name = col_data.get("type_name", "")
326+
327+
# Normalize SEA type to Thrift conventions before any processing
328+
type_name = normalize_sea_type_to_thrift(type_name, col_data)
329+
330+
# Now strip _TYPE suffix and convert to lowercase
325331
type_name = (
326332
type_name[:-5] if type_name.endswith("_TYPE") else type_name
327333
).lower()

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,19 @@ def _convert_json_types(self, row: List[str]) -> List[Any]:
9292
converted_row = []
9393

9494
for i, value in enumerate(row):
95+
column_name = self.description[i][0]
9596
column_type = self.description[i][1]
9697
precision = self.description[i][4]
9798
scale = self.description[i][5]
9899

99-
try:
100-
converted_value = SqlTypeConverter.convert_value(
101-
value, column_type, precision=precision, scale=scale
102-
)
103-
converted_row.append(converted_value)
104-
except Exception as e:
105-
logger.warning(
106-
f"Error converting value '{value}' to {column_type}: {e}"
107-
)
108-
converted_row.append(value)
100+
converted_value = SqlTypeConverter.convert_value(
101+
value,
102+
column_type,
103+
column_name=column_name,
104+
precision=precision,
105+
scale=scale,
106+
)
107+
converted_row.append(converted_value)
109108

110109
return converted_row
111110

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

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,60 +50,65 @@ def _convert_decimal(
5050

5151
class SqlType:
5252
"""
53-
SQL type constants
53+
SQL type constants based on Thrift TTypeId values.
5454
55-
The list of types can be found in the SEA REST API Reference:
56-
https://docs.databricks.com/api/workspace/statementexecution/executestatement
55+
These correspond to the normalized type names that come from the SEA backend
56+
after normalize_sea_type_to_thrift processing (lowercase, without _TYPE suffix).
5757
"""
5858

5959
# Numeric types
60-
BYTE = "byte"
61-
SHORT = "short"
62-
INT = "int"
63-
LONG = "long"
64-
FLOAT = "float"
65-
DOUBLE = "double"
66-
DECIMAL = "decimal"
60+
TINYINT = "tinyint" # Maps to TTypeId.TINYINT_TYPE
61+
SMALLINT = "smallint" # Maps to TTypeId.SMALLINT_TYPE
62+
INT = "int" # Maps to TTypeId.INT_TYPE
63+
BIGINT = "bigint" # Maps to TTypeId.BIGINT_TYPE
64+
FLOAT = "float" # Maps to TTypeId.FLOAT_TYPE
65+
DOUBLE = "double" # Maps to TTypeId.DOUBLE_TYPE
66+
DECIMAL = "decimal" # Maps to TTypeId.DECIMAL_TYPE
6767

6868
# Boolean type
69-
BOOLEAN = "boolean"
69+
BOOLEAN = "boolean" # Maps to TTypeId.BOOLEAN_TYPE
7070

7171
# Date/Time types
72-
DATE = "date"
73-
TIMESTAMP = "timestamp"
74-
INTERVAL = "interval"
72+
DATE = "date" # Maps to TTypeId.DATE_TYPE
73+
TIMESTAMP = "timestamp" # Maps to TTypeId.TIMESTAMP_TYPE
74+
INTERVAL_YEAR_MONTH = (
75+
"interval_year_month" # Maps to TTypeId.INTERVAL_YEAR_MONTH_TYPE
76+
)
77+
INTERVAL_DAY_TIME = "interval_day_time" # Maps to TTypeId.INTERVAL_DAY_TIME_TYPE
7578

7679
# String types
77-
CHAR = "char"
78-
STRING = "string"
80+
CHAR = "char" # Maps to TTypeId.CHAR_TYPE
81+
VARCHAR = "varchar" # Maps to TTypeId.VARCHAR_TYPE
82+
STRING = "string" # Maps to TTypeId.STRING_TYPE
7983

8084
# Binary type
81-
BINARY = "binary"
85+
BINARY = "binary" # Maps to TTypeId.BINARY_TYPE
8286

8387
# Complex types
84-
ARRAY = "array"
85-
MAP = "map"
86-
STRUCT = "struct"
88+
ARRAY = "array" # Maps to TTypeId.ARRAY_TYPE
89+
MAP = "map" # Maps to TTypeId.MAP_TYPE
90+
STRUCT = "struct" # Maps to TTypeId.STRUCT_TYPE
8791

8892
# Other types
89-
NULL = "null"
90-
USER_DEFINED_TYPE = "user_defined_type"
93+
NULL = "null" # Maps to TTypeId.NULL_TYPE
94+
UNION = "union" # Maps to TTypeId.UNION_TYPE
95+
USER_DEFINED = "user_defined" # Maps to TTypeId.USER_DEFINED_TYPE
9196

9297

9398
class SqlTypeConverter:
9499
"""
95100
Utility class for converting SQL types to Python types.
96-
Based on the types supported by the Databricks SDK.
101+
Based on the Thrift TTypeId types after normalization.
97102
"""
98103

99104
# SQL type to conversion function mapping
100105
# TODO: complex types
101106
TYPE_MAPPING: Dict[str, Callable] = {
102107
# Numeric types
103-
SqlType.BYTE: lambda v: int(v),
104-
SqlType.SHORT: lambda v: int(v),
108+
SqlType.TINYINT: lambda v: int(v),
109+
SqlType.SMALLINT: lambda v: int(v),
105110
SqlType.INT: lambda v: int(v),
106-
SqlType.LONG: lambda v: int(v),
111+
SqlType.BIGINT: lambda v: int(v),
107112
SqlType.FLOAT: lambda v: float(v),
108113
SqlType.DOUBLE: lambda v: float(v),
109114
SqlType.DECIMAL: _convert_decimal,
@@ -112,30 +117,34 @@ class SqlTypeConverter:
112117
# Date/Time types
113118
SqlType.DATE: lambda v: datetime.date.fromisoformat(v),
114119
SqlType.TIMESTAMP: lambda v: parser.parse(v),
115-
SqlType.INTERVAL: lambda v: v, # Keep as string for now
120+
SqlType.INTERVAL_YEAR_MONTH: lambda v: v, # Keep as string for now
121+
SqlType.INTERVAL_DAY_TIME: lambda v: v, # Keep as string for now
116122
# String types - no conversion needed
117123
SqlType.CHAR: lambda v: v,
124+
SqlType.VARCHAR: lambda v: v,
118125
SqlType.STRING: lambda v: v,
119126
# Binary type
120127
SqlType.BINARY: lambda v: bytes.fromhex(v),
121128
# Other types
122129
SqlType.NULL: lambda v: None,
123130
# Complex types and user-defined types return as-is
124-
SqlType.USER_DEFINED_TYPE: lambda v: v,
131+
SqlType.USER_DEFINED: lambda v: v,
125132
}
126133

127134
@staticmethod
128135
def convert_value(
129136
value: str,
130137
sql_type: str,
138+
column_name: Optional[str],
131139
**kwargs,
132140
) -> object:
133141
"""
134142
Convert a string value to the appropriate Python type based on SQL type.
135143
136144
Args:
137145
value: The string value to convert
138-
sql_type: The SQL type (e.g., 'int', 'decimal')
146+
sql_type: The SQL type (e.g., 'tinyint', 'decimal')
147+
column_name: The name of the column being converted
139148
**kwargs: Additional keyword arguments for the conversion function
140149
141150
Returns:
@@ -155,6 +164,10 @@ def convert_value(
155164
return converter_func(value, precision, scale)
156165
else:
157166
return converter_func(value)
158-
except (ValueError, TypeError, decimal.InvalidOperation) as e:
159-
logger.warning(f"Error converting value '{value}' to {sql_type}: {e}")
167+
except Exception as e:
168+
warning_message = f"Error converting value '{value}' to {sql_type}"
169+
if column_name:
170+
warning_message += f" in column {column_name}"
171+
warning_message += f": {e}"
172+
logger.warning(warning_message)
160173
return value
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
Type normalization utilities for SEA backend.
3+
4+
This module provides functionality to normalize SEA type names to match
5+
Thrift type naming conventions.
6+
"""
7+
8+
from typing import Dict, Any
9+
10+
# SEA types that need to be translated to Thrift types
11+
# The list of all SEA types is available in the REST reference at:
12+
# https://docs.databricks.com/api/workspace/statementexecution/executestatement
13+
# The list of all Thrift types can be found in the ttypes.TTypeId definition
14+
# The SEA types that do not align with Thrift are explicitly mapped below
15+
SEA_TO_THRIFT_TYPE_MAP = {
16+
"BYTE": "TINYINT",
17+
"SHORT": "SMALLINT",
18+
"LONG": "BIGINT",
19+
"INTERVAL": "INTERVAL", # Default mapping, will be overridden if type_interval_type is present
20+
}
21+
22+
23+
def normalize_sea_type_to_thrift(type_name: str, col_data: Dict[str, Any]) -> str:
24+
"""
25+
Normalize SEA type names to match Thrift type naming conventions.
26+
27+
Args:
28+
type_name: The type name from SEA (e.g., "BYTE", "LONG", "INTERVAL")
29+
col_data: The full column data dictionary from manifest (for accessing type_interval_type)
30+
31+
Returns:
32+
Normalized type name matching Thrift conventions
33+
"""
34+
# Early return if type doesn't need mapping
35+
if type_name not in SEA_TO_THRIFT_TYPE_MAP:
36+
return type_name
37+
38+
normalized_type = SEA_TO_THRIFT_TYPE_MAP[type_name]
39+
40+
# Special handling for interval types
41+
if type_name == "INTERVAL":
42+
type_interval_type = col_data.get("type_interval_type")
43+
if type_interval_type:
44+
return (
45+
"INTERVAL_YEAR_MONTH"
46+
if any(t in type_interval_type.upper() for t in ["YEAR", "MONTH"])
47+
else "INTERVAL_DAY_TIME"
48+
)
49+
50+
return normalized_type

tests/unit/test_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,7 @@ def test_negative_fetch_throws_exception(self):
262262
mock_backend = Mock()
263263
mock_backend.fetch_results.return_value = (Mock(), False, 0)
264264

265-
result_set = ThriftResultSet(
266-
Mock(), Mock(), mock_backend
267-
)
265+
result_set = ThriftResultSet(Mock(), Mock(), mock_backend)
268266

269267
with self.assertRaises(ValueError) as e:
270268
result_set.fetchmany(-1)

tests/unit/test_downloader.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ class DownloaderTests(unittest.TestCase):
2626
def _setup_time_mock_for_download(self, mock_time, end_time):
2727
"""Helper to setup time mock that handles logging system calls."""
2828
call_count = [0]
29+
2930
def time_side_effect():
3031
call_count[0] += 1
3132
if call_count[0] <= 2: # First two calls (validation, start_time)
3233
return 1000
3334
else: # All subsequent calls (logging, duration calculation)
3435
return end_time
36+
3537
mock_time.side_effect = time_side_effect
3638

3739
@patch("time.time", return_value=1000)
@@ -104,7 +106,7 @@ def test_run_get_response_not_ok(self, mock_time):
104106
@patch("time.time")
105107
def test_run_uncompressed_successful(self, mock_time):
106108
self._setup_time_mock_for_download(mock_time, 1000.5)
107-
109+
108110
http_client = DatabricksHttpClient.get_instance()
109111
file_bytes = b"1234567890" * 10
110112
settings = Mock(link_expiry_buffer_secs=0, download_timeout=0, use_proxy=False)
@@ -133,7 +135,7 @@ def test_run_uncompressed_successful(self, mock_time):
133135
@patch("time.time")
134136
def test_run_compressed_successful(self, mock_time):
135137
self._setup_time_mock_for_download(mock_time, 1000.2)
136-
138+
137139
http_client = DatabricksHttpClient.get_instance()
138140
file_bytes = b"1234567890" * 10
139141
compressed_bytes = b'\x04"M\x18h@d\x00\x00\x00\x00\x00\x00\x00#\x14\x00\x00\x00\xaf1234567890\n\x00BP67890\x00\x00\x00\x00'

tests/unit/test_sea_backend.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,66 @@ def test_extract_description_from_manifest(self, sea_client):
550550
assert description[1][1] == "int" # type_code
551551
assert description[1][6] is None # null_ok
552552

553+
def test_extract_description_from_manifest_with_type_normalization(
554+
self, sea_client
555+
):
556+
"""Test _extract_description_from_manifest with SEA to Thrift type normalization."""
557+
manifest_obj = MagicMock()
558+
manifest_obj.schema = {
559+
"columns": [
560+
{
561+
"name": "byte_col",
562+
"type_name": "BYTE",
563+
},
564+
{
565+
"name": "short_col",
566+
"type_name": "SHORT",
567+
},
568+
{
569+
"name": "long_col",
570+
"type_name": "LONG",
571+
},
572+
{
573+
"name": "interval_ym_col",
574+
"type_name": "INTERVAL",
575+
"type_interval_type": "YEAR TO MONTH",
576+
},
577+
{
578+
"name": "interval_dt_col",
579+
"type_name": "INTERVAL",
580+
"type_interval_type": "DAY TO SECOND",
581+
},
582+
{
583+
"name": "interval_default_col",
584+
"type_name": "INTERVAL",
585+
# No type_interval_type field
586+
},
587+
]
588+
}
589+
590+
description = sea_client._extract_description_from_manifest(manifest_obj)
591+
assert description is not None
592+
assert len(description) == 6
593+
594+
# Check normalized types
595+
assert description[0][0] == "byte_col"
596+
assert description[0][1] == "tinyint" # BYTE -> tinyint
597+
598+
assert description[1][0] == "short_col"
599+
assert description[1][1] == "smallint" # SHORT -> smallint
600+
601+
assert description[2][0] == "long_col"
602+
assert description[2][1] == "bigint" # LONG -> bigint
603+
604+
assert description[3][0] == "interval_ym_col"
605+
assert description[3][1] == "interval_year_month" # INTERVAL with YEAR/MONTH
606+
607+
assert description[4][0] == "interval_dt_col"
608+
assert description[4][1] == "interval_day_time" # INTERVAL with DAY/TIME
609+
610+
assert description[5][0] == "interval_default_col"
611+
assert description[5][1] == "interval" # INTERVAL without subtype
612+
553613
def test_filter_session_configuration(self):
554614
"""Test that _filter_session_configuration converts all values to strings."""
555615
session_config = {

0 commit comments

Comments
 (0)