Edits history of script submission #22651 for ' Get SQL Statement (databricks)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get SQL Statement
     * Fetch the status and (when SUCCEEDED) the result of a previously submitted SQL statement by its statement_id.
     */
    export async function main(auth: RT.Databricks, statement_id: string) {
      const base = auth.workspace_url.replace(/\/$/, "")
      const url = new URL(`${base}/api/2.0/sql/statements/${statement_id}`)
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 5 days ago