Skip to content

Latest commit

 

History

History
141 lines (98 loc) · 11.3 KB

File metadata and controls

141 lines (98 loc) · 11.3 KB
graph LR
    DB_API_Cursor_Base["DB-API Cursor Base"]
    Hive_Cursor["Hive Cursor"]
    Presto_Cursor["Presto Cursor"]
    Trino_Cursor["Trino Cursor"]
    Parameter_Escaper["Parameter Escaper"]
    Thrift_API_Client["Thrift API Client"]
    HTTP_Client["HTTP Client"]
    Exception_Management["Exception Management"]
    Hive_Cursor -- "inherits from" --> DB_API_Cursor_Base
    Hive_Cursor -- "calls methods of" --> DB_API_Cursor_Base
    Presto_Cursor -- "inherits from" --> DB_API_Cursor_Base
    Presto_Cursor -- "calls methods of" --> DB_API_Cursor_Base
    Trino_Cursor -- "inherits from" --> Presto_Cursor
    Trino_Cursor -- "calls methods of" --> Presto_Cursor
    Hive_Cursor -- "interacts with" --> Thrift_API_Client
    Hive_Cursor -- "sends requests to" --> Thrift_API_Client
    Presto_Cursor -- "interacts with" --> HTTP_Client
    Presto_Cursor -- "sends requests to" --> HTTP_Client
    Trino_Cursor -- "interacts with" --> HTTP_Client
    Trino_Cursor -- "sends requests to" --> HTTP_Client
    Hive_Cursor -- "uses for parameter formatting" --> Parameter_Escaper
    Presto_Cursor -- "uses for parameter formatting" --> Parameter_Escaper
    Trino_Cursor -- "uses for parameter formatting" --> Parameter_Escaper
    DB_API_Cursor_Base -- "raises" --> Exception_Management
    Parameter_Escaper -- "raises" --> Exception_Management
    Hive_Cursor -- "raises" --> Exception_Management
    Presto_Cursor -- "raises" --> Exception_Management
    Trino_Cursor -- "raises" --> Exception_Management
Loading

CodeBoardingDemoContact

Component Details

This system provides a set of DB-API compliant database cursors for various data sources like Hive, Presto, and Trino. It establishes a common base for cursor functionalities, handles SQL parameter escaping, manages interactions with specific database APIs (Thrift for Hive, HTTP for Presto/Trino), and incorporates a centralized exception management system to ensure robust database operations.

DB-API Cursor Base

This component provides the fundamental interface and common logic for all database cursors in PyHive, adhering to the Python DB-API specification. It manages the cursor's internal state, handles generic fetching mechanisms like fetchone and executemany, and defines abstract methods that concrete cursor implementations must provide.

Related Classes/Methods:

Hive Cursor

This component implements the DB-API cursor specifically for HiveServer2. It handles the execution of SQL queries, manages the Thrift operation handle, and retrieves results by interacting with the HiveServer2 Thrift API.

Related Classes/Methods:

Presto Cursor

This component implements the DB-API cursor for Presto. It manages HTTP-based query execution, sends requests to the Presto REST API, and processes the JSON responses to retrieve query results and metadata.

Related Classes/Methods:

Trino Cursor

This component extends the Presto cursor to provide specific functionalities for Trino. It primarily customizes the HTTP headers and response processing to align with Trino's API, while leveraging the core logic from the Presto cursor.

Related Classes/Methods:

Parameter Escaper

This component is responsible for safely formatting and escaping parameters for SQL queries. It provides methods to handle various data types such as numbers, strings, sequences, and datetime objects, with specialized implementations for Hive, Presto, and Trino to ensure correct syntax and prevent SQL injection.

Related Classes/Methods:

Thrift API Client

This component encapsulates the interactions with the HiveServer2 Thrift API. It is responsible for constructing and sending Thrift requests (e.g., for closing operations or executing statements) and processing the Thrift responses, ensuring proper communication with the Hive server.

Related Classes/Methods:

  • TCLIService.ttypes.TCloseOperationReq (full file reference)
  • TCLIService.ttypes.TExecuteStatementReq (full file reference)

HTTP Client

This component handles the underlying HTTP communication for Presto and Trino. It is responsible for sending HTTP requests (e.g., POST for query execution, GET for polling, DELETE for cancellation) and processing the HTTP responses, including status codes and JSON payloads.

Related Classes/Methods: None

Exception Management

This component defines and manages various database-related exceptions, such as ProgrammingError, OperationalError, DatabaseError, and NotSupportedError. It is responsible for raising appropriate exceptions based on error conditions encountered during database operations.

Related Classes/Methods: