Katkat

Implement a Snowflake Query Client

DatadogSoftware Engineer · Onsite

Last 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:

  1. Connect to the warehouse using configuration provided at runtime.
  2. Start an asynchronous SQL query with a method such as startQuery(sql, params), returning a unique queryId.
  3. Check query progress with getQueryStatus(queryId), returning states such as QUEUED, RUNNING, SUCCEEDED, FAILED, or CANCELED.
  4. Retrieve query results after successful completion.
  5. 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?