@pulumi/databricks
Version:
A Pulumi package for creating and managing databricks cloud resources.
247 lines (246 loc) • 9.18 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "./types/input";
import * as outputs from "./types/output";
/**
* To manage [SQLA resources](https://docs.databricks.com/sql/get-started/concepts.html) you must have `databricksSqlAccess` on your databricks.Group or databricks_user.
*
* > documentation for this resource is a work in progress.
*
* A query may have one or more visualizations.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as databricks from "@pulumi/databricks";
*
* const sharedDir = new databricks.Directory("shared_dir", {path: "/Shared/Queries"});
* const q1 = new databricks.SqlQuery("q1", {
* dataSourceId: example.dataSourceId,
* name: "My Query Name",
* query: ` SELECT {{ p1 }} AS p1
* WHERE 1=1
* AND p2 in ({{ p2 }})
* AND event_date > date '{{ p3 }}'
* `,
* parent: pulumi.interpolate`folders/${sharedDir.objectId}`,
* runAsRole: "viewer",
* parameters: [
* {
* name: "p1",
* title: "Title for p1",
* text: {
* value: "default",
* },
* },
* {
* name: "p2",
* title: "Title for p2",
* "enum": {
* options: [
* "default",
* "foo",
* "bar",
* ],
* value: "default",
* multiple: {
* prefix: "\"",
* suffix: "\"",
* separator: ",",
* },
* },
* },
* {
* name: "p3",
* title: "Title for p3",
* date: {
* value: "2022-01-01",
* },
* },
* ],
* tags: [
* "t1",
* "t2",
* ],
* });
* ```
*
* Example permission to share query with all users:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as databricks from "@pulumi/databricks";
*
* const q1 = new databricks.Permissions("q1", {
* sqlQueryId: q1DatabricksSqlQuery.id,
* accessControls: [
* {
* groupName: users.displayName,
* permissionLevel: "CAN_RUN",
* },
* {
* groupName: team.displayName,
* permissionLevel: "CAN_EDIT",
* },
* ],
* });
* ```
*
* ## Troubleshooting
*
* In case you see `Error: cannot create sql query: Internal Server Error` during `pulumi up`; double check that you are using the correct `dataSourceId`
*
* Operations on `databricks.SqlQuery` schedules are ⛔️ deprecated. You can create, update or delete a schedule for SQLA and other Databricks resources using the databricks.Job resource.
*
* ## Related Resources
*
* The following resources are often used in the same context:
*
* * End to end workspace management guide.
* * databricks.SqlDashboard to manage Databricks SQL [Dashboards](https://docs.databricks.com/sql/user/dashboards/index.html).
* * databricks.SqlEndpoint to manage Databricks SQL [Endpoints](https://docs.databricks.com/sql/admin/sql-endpoints.html).
* * databricks.SqlGlobalConfig to configure the security policy, databricks_instance_profile, and [data access properties](https://docs.databricks.com/sql/admin/data-access-configuration.html) for all databricks.SqlEndpoint of workspace.
* * databricks.SqlPermissions to manage data object access control lists in Databricks workspaces for things like tables, views, databases, and [more](https://docs.databricks.com/security/access-control/table-acls/object-privileges.html).
* * databricks.Job to schedule Databricks SQL queries (as well as dashboards and alerts) using Databricks Jobs.
*
* ## Import
*
* You can import a `databricks_sql_query` resource with ID like the following:
*
* bash
*
* ```sh
* $ pulumi import databricks:index/sqlQuery:SqlQuery this <query-id>
* ```
*/
export declare class SqlQuery extends pulumi.CustomResource {
/**
* Get an existing SqlQuery resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name: string, id: pulumi.Input<pulumi.ID>, state?: SqlQueryState, opts?: pulumi.CustomResourceOptions): SqlQuery;
/**
* Returns true if the given object is an instance of SqlQuery. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj: any): obj is SqlQuery;
readonly createdAt: pulumi.Output<string>;
/**
* Data source ID of a SQL warehouse
*/
readonly dataSourceId: pulumi.Output<string>;
/**
* General description that conveys additional information about this query such as usage notes.
*/
readonly description: pulumi.Output<string | undefined>;
/**
* The title of this query that appears in list views, widget headings, and on the query page.
*/
readonly name: pulumi.Output<string>;
readonly parameters: pulumi.Output<outputs.SqlQueryParameter[] | undefined>;
/**
* The identifier of the workspace folder containing the object.
*/
readonly parent: pulumi.Output<string | undefined>;
/**
* The text of the query to be run.
*/
readonly query: pulumi.Output<string>;
/**
* Run as role. Possible values are `viewer`, `owner`.
*/
readonly runAsRole: pulumi.Output<string | undefined>;
/**
* @deprecated Operations on `databricks.SqlQuery` schedules are deprecated. Please use `databricks.Job` resource to schedule a `sqlTask`.
*/
readonly schedule: pulumi.Output<outputs.SqlQuerySchedule | undefined>;
readonly tags: pulumi.Output<string[] | undefined>;
readonly updatedAt: pulumi.Output<string>;
/**
* Create a SqlQuery resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: SqlQueryArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering SqlQuery resources.
*/
export interface SqlQueryState {
createdAt?: pulumi.Input<string>;
/**
* Data source ID of a SQL warehouse
*/
dataSourceId?: pulumi.Input<string>;
/**
* General description that conveys additional information about this query such as usage notes.
*/
description?: pulumi.Input<string>;
/**
* The title of this query that appears in list views, widget headings, and on the query page.
*/
name?: pulumi.Input<string>;
parameters?: pulumi.Input<pulumi.Input<inputs.SqlQueryParameter>[]>;
/**
* The identifier of the workspace folder containing the object.
*/
parent?: pulumi.Input<string>;
/**
* The text of the query to be run.
*/
query?: pulumi.Input<string>;
/**
* Run as role. Possible values are `viewer`, `owner`.
*/
runAsRole?: pulumi.Input<string>;
/**
* @deprecated Operations on `databricks.SqlQuery` schedules are deprecated. Please use `databricks.Job` resource to schedule a `sqlTask`.
*/
schedule?: pulumi.Input<inputs.SqlQuerySchedule>;
tags?: pulumi.Input<pulumi.Input<string>[]>;
updatedAt?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a SqlQuery resource.
*/
export interface SqlQueryArgs {
createdAt?: pulumi.Input<string>;
/**
* Data source ID of a SQL warehouse
*/
dataSourceId: pulumi.Input<string>;
/**
* General description that conveys additional information about this query such as usage notes.
*/
description?: pulumi.Input<string>;
/**
* The title of this query that appears in list views, widget headings, and on the query page.
*/
name?: pulumi.Input<string>;
parameters?: pulumi.Input<pulumi.Input<inputs.SqlQueryParameter>[]>;
/**
* The identifier of the workspace folder containing the object.
*/
parent?: pulumi.Input<string>;
/**
* The text of the query to be run.
*/
query: pulumi.Input<string>;
/**
* Run as role. Possible values are `viewer`, `owner`.
*/
runAsRole?: pulumi.Input<string>;
/**
* @deprecated Operations on `databricks.SqlQuery` schedules are deprecated. Please use `databricks.Job` resource to schedule a `sqlTask`.
*/
schedule?: pulumi.Input<inputs.SqlQuerySchedule>;
tags?: pulumi.Input<pulumi.Input<string>[]>;
updatedAt?: pulumi.Input<string>;
}