Databricks command line Interface

Shambhu Rai 1,411 Reputation points
2023-08-17T07:00:50.3533333+00:00

HI Expert,

how to run a sql query on Databricks cluster without using context id using postman. Everytime i have to fire the query on context id to get the key and then fire it using Postman

User's image

here is the link

https://docs.databricks.com/api/azure/workspace/commandexecution/create

Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,559 questions
Azure Data Explorer
Azure Data Explorer
An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.
576 questions
Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,514 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,624 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 33,071 Reputation points Volunteer Moderator
    2023-08-17T11:54:33.6566667+00:00

    First, you need to create an access token from the Databricks workspace. This token will be used to authenticate your requests.

    Open Postman and create a POST request. Set the URL to your Databricks cluster endpoint, specifically pointing to the API that allows for SQL query execution, usually something like https://<databricks-instance>/api/2.0/sql/execute. Replace <databricks-instance> with your actual instance URL.

    In the Headers section, add a Content-Type field with the value application/json, and Authorization with the value Bearer <your-access-token>, replacing <your-access-token> with the token generated earlier.

    In the Body section, select the raw option and input the SQL query in JSON format. It might look something like this:

     {
    
            "clusterId": "<your-cluster-id>",
    
            "language": "sql",
    
            "query": "<your-sql-query>"
    
        }
    

    Replace <your-cluster-id> with the ID of your cluster and <your-sql-query> with the SQL query you want to run.

    Click "Send" to execute the request. The result of the SQL query will be returned in the response.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.