Implement a Snowflake Query Client
DatadogSoftware Engineer · OnsiteLast updated
This question evaluates API client design, asynchronous query lifecycle management, result retrieval, robust error handling, and secure credential handling for a cloud data warehouse.
Build a lightweight query client for a Snowflake-like data warehouse.
Implement a QueryClient that can:
- Connect to the warehouse using configuration provided at runtime.
- Start an asynchronous SQL query with a method such as
startQuery(sql, params), returning a uniquequeryId. - Check query progress with
getQueryStatus(queryId), returning states such asQUEUED,RUNNING,SUCCEEDED,FAILED, orCANCELED. - Retrieve query results after successful completion.
- Handle common errors such as invalid SQL, missing credentials, network failures, timeout, and unknown query IDs.
You may assume a mock warehouse SDK or HTTP API is provided; focus on designing and implementing the client wrapper cleanly.
Follow-up questions:
- How would you manage secrets such as database credentials securely?
- How would you extend the client to support batch query submission and batch status polling?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.