databricks.SqlQuery
Explore with Pulumi AI
To manage SQLA resources you must have databricks_sql_access
on your databricks.Group or databricks_user.
Note: documentation for this resource is a work in progress.
A query may have one or more visualizations.
Example Usage
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",
],
});
import pulumi
import pulumi_databricks as databricks
shared_dir = databricks.Directory("shared_dir", path="/Shared/Queries")
q1 = databricks.SqlQuery("q1",
data_source_id=example["dataSourceId"],
name="My Query Name",
query=""" SELECT {{ p1 }} AS p1
WHERE 1=1
AND p2 in ({{ p2 }})
AND event_date > date '{{ p3 }}'
""",
parent=shared_dir.object_id.apply(lambda object_id: f"folders/{object_id}"),
run_as_role="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",
])
package main
import (
"fmt"
"github.com/pulumi/pulumi-databricks/sdk/go/databricks"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
sharedDir, err := databricks.NewDirectory(ctx, "shared_dir", &databricks.DirectoryArgs{
Path: pulumi.String("/Shared/Queries"),
})
if err != nil {
return err
}
_, err = databricks.NewSqlQuery(ctx, "q1", &databricks.SqlQueryArgs{
DataSourceId: pulumi.Any(example.DataSourceId),
Name: pulumi.String("My Query Name"),
Query: pulumi.String(" SELECT {{ p1 }} AS p1\n WHERE 1=1\n AND p2 in ({{ p2 }})\n AND event_date > date '{{ p3 }}'\n"),
Parent: sharedDir.ObjectId.ApplyT(func(objectId int) (string, error) {
return fmt.Sprintf("folders/%v", objectId), nil
}).(pulumi.StringOutput),
RunAsRole: pulumi.String("viewer"),
Parameters: databricks.SqlQueryParameterArray{
&databricks.SqlQueryParameterArgs{
Name: pulumi.String("p1"),
Title: pulumi.String("Title for p1"),
Text: &databricks.SqlQueryParameterTextArgs{
Value: pulumi.String("default"),
},
},
&databricks.SqlQueryParameterArgs{
Name: pulumi.String("p2"),
Title: pulumi.String("Title for p2"),
Enum: &databricks.SqlQueryParameterEnumArgs{
Options: pulumi.StringArray{
pulumi.String("default"),
pulumi.String("foo"),
pulumi.String("bar"),
},
Value: pulumi.String("default"),
Multiple: &databricks.SqlQueryParameterEnumMultipleArgs{
Prefix: pulumi.String("\""),
Suffix: pulumi.String("\""),
Separator: pulumi.String(","),
},
},
},
&databricks.SqlQueryParameterArgs{
Name: pulumi.String("p3"),
Title: pulumi.String("Title for p3"),
Date: &databricks.SqlQueryParameterDateArgs{
Value: pulumi.String("2022-01-01"),
},
},
},
Tags: pulumi.StringArray{
pulumi.String("t1"),
pulumi.String("t2"),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Databricks = Pulumi.Databricks;
return await Deployment.RunAsync(() =>
{
var sharedDir = new Databricks.Directory("shared_dir", new()
{
Path = "/Shared/Queries",
});
var q1 = new Databricks.SqlQuery("q1", new()
{
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 = sharedDir.ObjectId.Apply(objectId => $"folders/{objectId}"),
RunAsRole = "viewer",
Parameters = new[]
{
new Databricks.Inputs.SqlQueryParameterArgs
{
Name = "p1",
Title = "Title for p1",
Text = new Databricks.Inputs.SqlQueryParameterTextArgs
{
Value = "default",
},
},
new Databricks.Inputs.SqlQueryParameterArgs
{
Name = "p2",
Title = "Title for p2",
Enum = new Databricks.Inputs.SqlQueryParameterEnumArgs
{
Options = new[]
{
"default",
"foo",
"bar",
},
Value = "default",
Multiple = new Databricks.Inputs.SqlQueryParameterEnumMultipleArgs
{
Prefix = "\"",
Suffix = "\"",
Separator = ",",
},
},
},
new Databricks.Inputs.SqlQueryParameterArgs
{
Name = "p3",
Title = "Title for p3",
Date = new Databricks.Inputs.SqlQueryParameterDateArgs
{
Value = "2022-01-01",
},
},
},
Tags = new[]
{
"t1",
"t2",
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.databricks.Directory;
import com.pulumi.databricks.DirectoryArgs;
import com.pulumi.databricks.SqlQuery;
import com.pulumi.databricks.SqlQueryArgs;
import com.pulumi.databricks.inputs.SqlQueryParameterArgs;
import com.pulumi.databricks.inputs.SqlQueryParameterTextArgs;
import com.pulumi.databricks.inputs.SqlQueryParameterEnumArgs;
import com.pulumi.databricks.inputs.SqlQueryParameterEnumMultipleArgs;
import com.pulumi.databricks.inputs.SqlQueryParameterDateArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var sharedDir = new Directory("sharedDir", DirectoryArgs.builder()
.path("/Shared/Queries")
.build());
var q1 = new SqlQuery("q1", SqlQueryArgs.builder()
.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(sharedDir.objectId().applyValue(objectId -> String.format("folders/%s", objectId)))
.runAsRole("viewer")
.parameters(
SqlQueryParameterArgs.builder()
.name("p1")
.title("Title for p1")
.text(SqlQueryParameterTextArgs.builder()
.value("default")
.build())
.build(),
SqlQueryParameterArgs.builder()
.name("p2")
.title("Title for p2")
.enum_(SqlQueryParameterEnumArgs.builder()
.options(
"default",
"foo",
"bar")
.value("default")
.multiple(SqlQueryParameterEnumMultipleArgs.builder()
.prefix("\"")
.suffix("\"")
.separator(",")
.build())
.build())
.build(),
SqlQueryParameterArgs.builder()
.name("p3")
.title("Title for p3")
.date(SqlQueryParameterDateArgs.builder()
.value("2022-01-01")
.build())
.build())
.tags(
"t1",
"t2")
.build());
}
}
resources:
sharedDir:
type: databricks:Directory
name: shared_dir
properties:
path: /Shared/Queries
q1:
type: databricks:SqlQuery
properties:
dataSourceId: ${example.dataSourceId}
name: My Query Name
query: |2
SELECT {{ p1 }} AS p1
WHERE 1=1
AND p2 in ({{ p2 }})
AND event_date > date '{{ p3 }}'
parent: 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:
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",
},
],
});
import pulumi
import pulumi_databricks as databricks
q1 = databricks.Permissions("q1",
sql_query_id=q1_databricks_sql_query["id"],
access_controls=[
{
"group_name": users["displayName"],
"permission_level": "CAN_RUN",
},
{
"group_name": team["displayName"],
"permission_level": "CAN_EDIT",
},
])
package main
import (
"github.com/pulumi/pulumi-databricks/sdk/go/databricks"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := databricks.NewPermissions(ctx, "q1", &databricks.PermissionsArgs{
SqlQueryId: pulumi.Any(q1DatabricksSqlQuery.Id),
AccessControls: databricks.PermissionsAccessControlArray{
&databricks.PermissionsAccessControlArgs{
GroupName: pulumi.Any(users.DisplayName),
PermissionLevel: pulumi.String("CAN_RUN"),
},
&databricks.PermissionsAccessControlArgs{
GroupName: pulumi.Any(team.DisplayName),
PermissionLevel: pulumi.String("CAN_EDIT"),
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Databricks = Pulumi.Databricks;
return await Deployment.RunAsync(() =>
{
var q1 = new Databricks.Permissions("q1", new()
{
SqlQueryId = q1DatabricksSqlQuery.Id,
AccessControls = new[]
{
new Databricks.Inputs.PermissionsAccessControlArgs
{
GroupName = users.DisplayName,
PermissionLevel = "CAN_RUN",
},
new Databricks.Inputs.PermissionsAccessControlArgs
{
GroupName = team.DisplayName,
PermissionLevel = "CAN_EDIT",
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.databricks.Permissions;
import com.pulumi.databricks.PermissionsArgs;
import com.pulumi.databricks.inputs.PermissionsAccessControlArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var q1 = new Permissions("q1", PermissionsArgs.builder()
.sqlQueryId(q1DatabricksSqlQuery.id())
.accessControls(
PermissionsAccessControlArgs.builder()
.groupName(users.displayName())
.permissionLevel("CAN_RUN")
.build(),
PermissionsAccessControlArgs.builder()
.groupName(team.displayName())
.permissionLevel("CAN_EDIT")
.build())
.build());
}
}
resources:
q1:
type: databricks:Permissions
properties:
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 data_source_id
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.
- databricks.SqlEndpoint to manage Databricks SQL Endpoints.
- databricks.SqlGlobalConfig to configure the security policy, databricks_instance_profile, and data access properties 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.
- databricks.Job to schedule Databricks SQL queries (as well as dashboards and alerts) using Databricks Jobs.
Create SqlQuery Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new SqlQuery(name: string, args: SqlQueryArgs, opts?: CustomResourceOptions);
@overload
def SqlQuery(resource_name: str,
args: SqlQueryArgs,
opts: Optional[ResourceOptions] = None)
@overload
def SqlQuery(resource_name: str,
opts: Optional[ResourceOptions] = None,
data_source_id: Optional[str] = None,
query: Optional[str] = None,
created_at: Optional[str] = None,
description: Optional[str] = None,
name: Optional[str] = None,
parameters: Optional[Sequence[SqlQueryParameterArgs]] = None,
parent: Optional[str] = None,
run_as_role: Optional[str] = None,
schedule: Optional[SqlQueryScheduleArgs] = None,
tags: Optional[Sequence[str]] = None,
updated_at: Optional[str] = None)
func NewSqlQuery(ctx *Context, name string, args SqlQueryArgs, opts ...ResourceOption) (*SqlQuery, error)
public SqlQuery(string name, SqlQueryArgs args, CustomResourceOptions? opts = null)
public SqlQuery(String name, SqlQueryArgs args)
public SqlQuery(String name, SqlQueryArgs args, CustomResourceOptions options)
type: databricks:SqlQuery
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args SqlQueryArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args SqlQueryArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args SqlQueryArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SqlQueryArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SqlQueryArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var sqlQueryResource = new Databricks.SqlQuery("sqlQueryResource", new()
{
DataSourceId = "string",
Query = "string",
CreatedAt = "string",
Description = "string",
Name = "string",
Parameters = new[]
{
new Databricks.Inputs.SqlQueryParameterArgs
{
Name = "string",
Date = new Databricks.Inputs.SqlQueryParameterDateArgs
{
Value = "string",
},
DateRange = new Databricks.Inputs.SqlQueryParameterDateRangeArgs
{
Range = new Databricks.Inputs.SqlQueryParameterDateRangeRangeArgs
{
End = "string",
Start = "string",
},
Value = "string",
},
Datetime = new Databricks.Inputs.SqlQueryParameterDatetimeArgs
{
Value = "string",
},
DatetimeRange = new Databricks.Inputs.SqlQueryParameterDatetimeRangeArgs
{
Range = new Databricks.Inputs.SqlQueryParameterDatetimeRangeRangeArgs
{
End = "string",
Start = "string",
},
Value = "string",
},
Datetimesec = new Databricks.Inputs.SqlQueryParameterDatetimesecArgs
{
Value = "string",
},
DatetimesecRange = new Databricks.Inputs.SqlQueryParameterDatetimesecRangeArgs
{
Range = new Databricks.Inputs.SqlQueryParameterDatetimesecRangeRangeArgs
{
End = "string",
Start = "string",
},
Value = "string",
},
Enum = new Databricks.Inputs.SqlQueryParameterEnumArgs
{
Options = new[]
{
"string",
},
Multiple = new Databricks.Inputs.SqlQueryParameterEnumMultipleArgs
{
Separator = "string",
Prefix = "string",
Suffix = "string",
},
Value = "string",
Values = new[]
{
"string",
},
},
Number = new Databricks.Inputs.SqlQueryParameterNumberArgs
{
Value = 0,
},
Query = new Databricks.Inputs.SqlQueryParameterQueryArgs
{
QueryId = "string",
Multiple = new Databricks.Inputs.SqlQueryParameterQueryMultipleArgs
{
Separator = "string",
Prefix = "string",
Suffix = "string",
},
Value = "string",
Values = new[]
{
"string",
},
},
Text = new Databricks.Inputs.SqlQueryParameterTextArgs
{
Value = "string",
},
Title = "string",
},
},
Parent = "string",
RunAsRole = "string",
Tags = new[]
{
"string",
},
UpdatedAt = "string",
});
example, err := databricks.NewSqlQuery(ctx, "sqlQueryResource", &databricks.SqlQueryArgs{
DataSourceId: pulumi.String("string"),
Query: pulumi.String("string"),
CreatedAt: pulumi.String("string"),
Description: pulumi.String("string"),
Name: pulumi.String("string"),
Parameters: databricks.SqlQueryParameterArray{
&databricks.SqlQueryParameterArgs{
Name: pulumi.String("string"),
Date: &databricks.SqlQueryParameterDateArgs{
Value: pulumi.String("string"),
},
DateRange: &databricks.SqlQueryParameterDateRangeArgs{
Range: &databricks.SqlQueryParameterDateRangeRangeArgs{
End: pulumi.String("string"),
Start: pulumi.String("string"),
},
Value: pulumi.String("string"),
},
Datetime: &databricks.SqlQueryParameterDatetimeArgs{
Value: pulumi.String("string"),
},
DatetimeRange: &databricks.SqlQueryParameterDatetimeRangeArgs{
Range: &databricks.SqlQueryParameterDatetimeRangeRangeArgs{
End: pulumi.String("string"),
Start: pulumi.String("string"),
},
Value: pulumi.String("string"),
},
Datetimesec: &databricks.SqlQueryParameterDatetimesecArgs{
Value: pulumi.String("string"),
},
DatetimesecRange: &databricks.SqlQueryParameterDatetimesecRangeArgs{
Range: &databricks.SqlQueryParameterDatetimesecRangeRangeArgs{
End: pulumi.String("string"),
Start: pulumi.String("string"),
},
Value: pulumi.String("string"),
},
Enum: &databricks.SqlQueryParameterEnumArgs{
Options: pulumi.StringArray{
pulumi.String("string"),
},
Multiple: &databricks.SqlQueryParameterEnumMultipleArgs{
Separator: pulumi.String("string"),
Prefix: pulumi.String("string"),
Suffix: pulumi.String("string"),
},
Value: pulumi.String("string"),
Values: pulumi.StringArray{
pulumi.String("string"),
},
},
Number: &databricks.SqlQueryParameterNumberArgs{
Value: pulumi.Float64(0),
},
Query: &databricks.SqlQueryParameterQueryArgs{
QueryId: pulumi.String("string"),
Multiple: &databricks.SqlQueryParameterQueryMultipleArgs{
Separator: pulumi.String("string"),
Prefix: pulumi.String("string"),
Suffix: pulumi.String("string"),
},
Value: pulumi.String("string"),
Values: pulumi.StringArray{
pulumi.String("string"),
},
},
Text: &databricks.SqlQueryParameterTextArgs{
Value: pulumi.String("string"),
},
Title: pulumi.String("string"),
},
},
Parent: pulumi.String("string"),
RunAsRole: pulumi.String("string"),
Tags: pulumi.StringArray{
pulumi.String("string"),
},
UpdatedAt: pulumi.String("string"),
})
var sqlQueryResource = new SqlQuery("sqlQueryResource", SqlQueryArgs.builder()
.dataSourceId("string")
.query("string")
.createdAt("string")
.description("string")
.name("string")
.parameters(SqlQueryParameterArgs.builder()
.name("string")
.date(SqlQueryParameterDateArgs.builder()
.value("string")
.build())
.dateRange(SqlQueryParameterDateRangeArgs.builder()
.range(SqlQueryParameterDateRangeRangeArgs.builder()
.end("string")
.start("string")
.build())
.value("string")
.build())
.datetime(SqlQueryParameterDatetimeArgs.builder()
.value("string")
.build())
.datetimeRange(SqlQueryParameterDatetimeRangeArgs.builder()
.range(SqlQueryParameterDatetimeRangeRangeArgs.builder()
.end("string")
.start("string")
.build())
.value("string")
.build())
.datetimesec(SqlQueryParameterDatetimesecArgs.builder()
.value("string")
.build())
.datetimesecRange(SqlQueryParameterDatetimesecRangeArgs.builder()
.range(SqlQueryParameterDatetimesecRangeRangeArgs.builder()
.end("string")
.start("string")
.build())
.value("string")
.build())
.enum_(SqlQueryParameterEnumArgs.builder()
.options("string")
.multiple(SqlQueryParameterEnumMultipleArgs.builder()
.separator("string")
.prefix("string")
.suffix("string")
.build())
.value("string")
.values("string")
.build())
.number(SqlQueryParameterNumberArgs.builder()
.value(0)
.build())
.query(SqlQueryParameterQueryArgs.builder()
.queryId("string")
.multiple(SqlQueryParameterQueryMultipleArgs.builder()
.separator("string")
.prefix("string")
.suffix("string")
.build())
.value("string")
.values("string")
.build())
.text(SqlQueryParameterTextArgs.builder()
.value("string")
.build())
.title("string")
.build())
.parent("string")
.runAsRole("string")
.tags("string")
.updatedAt("string")
.build());
sql_query_resource = databricks.SqlQuery("sqlQueryResource",
data_source_id="string",
query="string",
created_at="string",
description="string",
name="string",
parameters=[databricks.SqlQueryParameterArgs(
name="string",
date=databricks.SqlQueryParameterDateArgs(
value="string",
),
date_range=databricks.SqlQueryParameterDateRangeArgs(
range=databricks.SqlQueryParameterDateRangeRangeArgs(
end="string",
start="string",
),
value="string",
),
datetime=databricks.SqlQueryParameterDatetimeArgs(
value="string",
),
datetime_range=databricks.SqlQueryParameterDatetimeRangeArgs(
range=databricks.SqlQueryParameterDatetimeRangeRangeArgs(
end="string",
start="string",
),
value="string",
),
datetimesec=databricks.SqlQueryParameterDatetimesecArgs(
value="string",
),
datetimesec_range=databricks.SqlQueryParameterDatetimesecRangeArgs(
range=databricks.SqlQueryParameterDatetimesecRangeRangeArgs(
end="string",
start="string",
),
value="string",
),
enum=databricks.SqlQueryParameterEnumArgs(
options=["string"],
multiple=databricks.SqlQueryParameterEnumMultipleArgs(
separator="string",
prefix="string",
suffix="string",
),
value="string",
values=["string"],
),
number=databricks.SqlQueryParameterNumberArgs(
value=0,
),
query=databricks.SqlQueryParameterQueryArgs(
query_id="string",
multiple=databricks.SqlQueryParameterQueryMultipleArgs(
separator="string",
prefix="string",
suffix="string",
),
value="string",
values=["string"],
),
text=databricks.SqlQueryParameterTextArgs(
value="string",
),
title="string",
)],
parent="string",
run_as_role="string",
tags=["string"],
updated_at="string")
const sqlQueryResource = new databricks.SqlQuery("sqlQueryResource", {
dataSourceId: "string",
query: "string",
createdAt: "string",
description: "string",
name: "string",
parameters: [{
name: "string",
date: {
value: "string",
},
dateRange: {
range: {
end: "string",
start: "string",
},
value: "string",
},
datetime: {
value: "string",
},
datetimeRange: {
range: {
end: "string",
start: "string",
},
value: "string",
},
datetimesec: {
value: "string",
},
datetimesecRange: {
range: {
end: "string",
start: "string",
},
value: "string",
},
"enum": {
options: ["string"],
multiple: {
separator: "string",
prefix: "string",
suffix: "string",
},
value: "string",
values: ["string"],
},
number: {
value: 0,
},
query: {
queryId: "string",
multiple: {
separator: "string",
prefix: "string",
suffix: "string",
},
value: "string",
values: ["string"],
},
text: {
value: "string",
},
title: "string",
}],
parent: "string",
runAsRole: "string",
tags: ["string"],
updatedAt: "string",
});
type: databricks:SqlQuery
properties:
createdAt: string
dataSourceId: string
description: string
name: string
parameters:
- date:
value: string
dateRange:
range:
end: string
start: string
value: string
datetime:
value: string
datetimeRange:
range:
end: string
start: string
value: string
datetimesec:
value: string
datetimesecRange:
range:
end: string
start: string
value: string
enum:
multiple:
prefix: string
separator: string
suffix: string
options:
- string
value: string
values:
- string
name: string
number:
value: 0
query:
multiple:
prefix: string
separator: string
suffix: string
queryId: string
value: string
values:
- string
text:
value: string
title: string
parent: string
query: string
runAsRole: string
tags:
- string
updatedAt: string
SqlQuery Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The SqlQuery resource accepts the following input properties:
- Data
Source stringId - Data source ID of a SQL warehouse
- Query string
- The text of the query to be run.
- Created
At string - Description string
- General description that conveys additional information about this query such as usage notes.
- Name string
- The title of this query that appears in list views, widget headings, and on the query page.
- Parameters
List<Sql
Query Parameter> - Parent string
- The identifier of the workspace folder containing the object.
- Run
As stringRole - Run as role. Possible values are
viewer
,owner
. - Schedule
Sql
Query Schedule - List<string>
- Updated
At string
- Data
Source stringId - Data source ID of a SQL warehouse
- Query string
- The text of the query to be run.
- Created
At string - Description string
- General description that conveys additional information about this query such as usage notes.
- Name string
- The title of this query that appears in list views, widget headings, and on the query page.
- Parameters
[]Sql
Query Parameter Args - Parent string
- The identifier of the workspace folder containing the object.
- Run
As stringRole - Run as role. Possible values are
viewer
,owner
. - Schedule
Sql
Query Schedule Args - []string
- Updated
At string
- data
Source StringId - Data source ID of a SQL warehouse
- query String
- The text of the query to be run.
- created
At String - description String
- General description that conveys additional information about this query such as usage notes.
- name String
- The title of this query that appears in list views, widget headings, and on the query page.
- parameters
List<Sql
Query Parameter> - parent String
- The identifier of the workspace folder containing the object.
- run
As StringRole - Run as role. Possible values are
viewer
,owner
. - schedule
Sql
Query Schedule - List<String>
- updated
At String
- data
Source stringId - Data source ID of a SQL warehouse
- query string
- The text of the query to be run.
- created
At string - description string
- General description that conveys additional information about this query such as usage notes.
- name string
- The title of this query that appears in list views, widget headings, and on the query page.
- parameters
Sql
Query Parameter[] - parent string
- The identifier of the workspace folder containing the object.
- run
As stringRole - Run as role. Possible values are
viewer
,owner
. - schedule
Sql
Query Schedule - string[]
- updated
At string
- data_
source_ strid - Data source ID of a SQL warehouse
- query str
- The text of the query to be run.
- created_
at str - description str
- General description that conveys additional information about this query such as usage notes.
- name str
- The title of this query that appears in list views, widget headings, and on the query page.
- parameters
Sequence[Sql
Query Parameter Args] - parent str
- The identifier of the workspace folder containing the object.
- run_
as_ strrole - Run as role. Possible values are
viewer
,owner
. - schedule
Sql
Query Schedule Args - Sequence[str]
- updated_
at str
- data
Source StringId - Data source ID of a SQL warehouse
- query String
- The text of the query to be run.
- created
At String - description String
- General description that conveys additional information about this query such as usage notes.
- name String
- The title of this query that appears in list views, widget headings, and on the query page.
- parameters List<Property Map>
- parent String
- The identifier of the workspace folder containing the object.
- run
As StringRole - Run as role. Possible values are
viewer
,owner
. - schedule Property Map
- List<String>
- updated
At String
Outputs
All input properties are implicitly available as output properties. Additionally, the SqlQuery resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing SqlQuery Resource
Get an existing SqlQuery resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: SqlQueryState, opts?: CustomResourceOptions): SqlQuery
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
created_at: Optional[str] = None,
data_source_id: Optional[str] = None,
description: Optional[str] = None,
name: Optional[str] = None,
parameters: Optional[Sequence[SqlQueryParameterArgs]] = None,
parent: Optional[str] = None,
query: Optional[str] = None,
run_as_role: Optional[str] = None,
schedule: Optional[SqlQueryScheduleArgs] = None,
tags: Optional[Sequence[str]] = None,
updated_at: Optional[str] = None) -> SqlQuery
func GetSqlQuery(ctx *Context, name string, id IDInput, state *SqlQueryState, opts ...ResourceOption) (*SqlQuery, error)
public static SqlQuery Get(string name, Input<string> id, SqlQueryState? state, CustomResourceOptions? opts = null)
public static SqlQuery get(String name, Output<String> id, SqlQueryState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Created
At string - Data
Source stringId - Data source ID of a SQL warehouse
- Description string
- General description that conveys additional information about this query such as usage notes.
- Name string
- The title of this query that appears in list views, widget headings, and on the query page.
- Parameters
List<Sql
Query Parameter> - Parent string
- The identifier of the workspace folder containing the object.
- Query string
- The text of the query to be run.
- Run
As stringRole - Run as role. Possible values are
viewer
,owner
. - Schedule
Sql
Query Schedule - List<string>
- Updated
At string
- Created
At string - Data
Source stringId - Data source ID of a SQL warehouse
- Description string
- General description that conveys additional information about this query such as usage notes.
- Name string
- The title of this query that appears in list views, widget headings, and on the query page.
- Parameters
[]Sql
Query Parameter Args - Parent string
- The identifier of the workspace folder containing the object.
- Query string
- The text of the query to be run.
- Run
As stringRole - Run as role. Possible values are
viewer
,owner
. - Schedule
Sql
Query Schedule Args - []string
- Updated
At string
- created
At String - data
Source StringId - Data source ID of a SQL warehouse
- description String
- General description that conveys additional information about this query such as usage notes.
- name String
- The title of this query that appears in list views, widget headings, and on the query page.
- parameters
List<Sql
Query Parameter> - parent String
- The identifier of the workspace folder containing the object.
- query String
- The text of the query to be run.
- run
As StringRole - Run as role. Possible values are
viewer
,owner
. - schedule
Sql
Query Schedule - List<String>
- updated
At String
- created
At string - data
Source stringId - Data source ID of a SQL warehouse
- description string
- General description that conveys additional information about this query such as usage notes.
- name string
- The title of this query that appears in list views, widget headings, and on the query page.
- parameters
Sql
Query Parameter[] - parent string
- The identifier of the workspace folder containing the object.
- query string
- The text of the query to be run.
- run
As stringRole - Run as role. Possible values are
viewer
,owner
. - schedule
Sql
Query Schedule - string[]
- updated
At string
- created_
at str - data_
source_ strid - Data source ID of a SQL warehouse
- description str
- General description that conveys additional information about this query such as usage notes.
- name str
- The title of this query that appears in list views, widget headings, and on the query page.
- parameters
Sequence[Sql
Query Parameter Args] - parent str
- The identifier of the workspace folder containing the object.
- query str
- The text of the query to be run.
- run_
as_ strrole - Run as role. Possible values are
viewer
,owner
. - schedule
Sql
Query Schedule Args - Sequence[str]
- updated_
at str
- created
At String - data
Source StringId - Data source ID of a SQL warehouse
- description String
- General description that conveys additional information about this query such as usage notes.
- name String
- The title of this query that appears in list views, widget headings, and on the query page.
- parameters List<Property Map>
- parent String
- The identifier of the workspace folder containing the object.
- query String
- The text of the query to be run.
- run
As StringRole - Run as role. Possible values are
viewer
,owner
. - schedule Property Map
- List<String>
- updated
At String
Supporting Types
SqlQueryParameter, SqlQueryParameterArgs
- Name string
The literal parameter marker that appears between double curly braces in the query text. Parameters can have several different types. Type is specified using one of the following configuration blocks:
text
,number
,enum
,query
,date
,datetime
,datetimesec
,date_range
,datetime_range
,datetimesec_range
.For
text
,number
,date
,datetime
,datetimesec
block- Date
Sql
Query Parameter Date - Date
Range SqlQuery Parameter Date Range - Datetime
Sql
Query Parameter Datetime - Datetime
Range SqlQuery Parameter Datetime Range - Datetimesec
Sql
Query Parameter Datetimesec - Datetimesec
Range SqlQuery Parameter Datetimesec Range - Enum
Sql
Query Parameter Enum - Number
Sql
Query Parameter Number - Query
Sql
Query Parameter Query - The text of the query to be run.
- Text
Sql
Query Parameter Text - Title string
- The text displayed in a parameter picking widget.
- Name string
The literal parameter marker that appears between double curly braces in the query text. Parameters can have several different types. Type is specified using one of the following configuration blocks:
text
,number
,enum
,query
,date
,datetime
,datetimesec
,date_range
,datetime_range
,datetimesec_range
.For
text
,number
,date
,datetime
,datetimesec
block- Date
Sql
Query Parameter Date - Date
Range SqlQuery Parameter Date Range - Datetime
Sql
Query Parameter Datetime - Datetime
Range SqlQuery Parameter Datetime Range - Datetimesec
Sql
Query Parameter Datetimesec - Datetimesec
Range SqlQuery Parameter Datetimesec Range - Enum
Sql
Query Parameter Enum - Number
Sql
Query Parameter Number - Query
Sql
Query Parameter Query - The text of the query to be run.
- Text
Sql
Query Parameter Text - Title string
- The text displayed in a parameter picking widget.
- name String
The literal parameter marker that appears between double curly braces in the query text. Parameters can have several different types. Type is specified using one of the following configuration blocks:
text
,number
,enum
,query
,date
,datetime
,datetimesec
,date_range
,datetime_range
,datetimesec_range
.For
text
,number
,date
,datetime
,datetimesec
block- date
Sql
Query Parameter Date - date
Range SqlQuery Parameter Date Range - datetime
Sql
Query Parameter Datetime - datetime
Range SqlQuery Parameter Datetime Range - datetimesec
Sql
Query Parameter Datetimesec - datetimesec
Range SqlQuery Parameter Datetimesec Range - enum_
Sql
Query Parameter Enum - number
Sql
Query Parameter Number - query
Sql
Query Parameter Query - The text of the query to be run.
- text
Sql
Query Parameter Text - title String
- The text displayed in a parameter picking widget.
- name string
The literal parameter marker that appears between double curly braces in the query text. Parameters can have several different types. Type is specified using one of the following configuration blocks:
text
,number
,enum
,query
,date
,datetime
,datetimesec
,date_range
,datetime_range
,datetimesec_range
.For
text
,number
,date
,datetime
,datetimesec
block- date
Sql
Query Parameter Date - date
Range SqlQuery Parameter Date Range - datetime
Sql
Query Parameter Datetime - datetime
Range SqlQuery Parameter Datetime Range - datetimesec
Sql
Query Parameter Datetimesec - datetimesec
Range SqlQuery Parameter Datetimesec Range - enum
Sql
Query Parameter Enum - number
Sql
Query Parameter Number - query
Sql
Query Parameter Query - The text of the query to be run.
- text
Sql
Query Parameter Text - title string
- The text displayed in a parameter picking widget.
- name str
The literal parameter marker that appears between double curly braces in the query text. Parameters can have several different types. Type is specified using one of the following configuration blocks:
text
,number
,enum
,query
,date
,datetime
,datetimesec
,date_range
,datetime_range
,datetimesec_range
.For
text
,number
,date
,datetime
,datetimesec
block- date
Sql
Query Parameter Date - date_
range SqlQuery Parameter Date Range - datetime
Sql
Query Parameter Datetime - datetime_
range SqlQuery Parameter Datetime Range - datetimesec
Sql
Query Parameter Datetimesec - datetimesec_
range SqlQuery Parameter Datetimesec Range - enum
Sql
Query Parameter Enum - number
Sql
Query Parameter Number - query
Sql
Query Parameter Query - The text of the query to be run.
- text
Sql
Query Parameter Text - title str
- The text displayed in a parameter picking widget.
- name String
The literal parameter marker that appears between double curly braces in the query text. Parameters can have several different types. Type is specified using one of the following configuration blocks:
text
,number
,enum
,query
,date
,datetime
,datetimesec
,date_range
,datetime_range
,datetimesec_range
.For
text
,number
,date
,datetime
,datetimesec
block- date Property Map
- date
Range Property Map - datetime Property Map
- datetime
Range Property Map - datetimesec Property Map
- datetimesec
Range Property Map - enum Property Map
- number Property Map
- query Property Map
- The text of the query to be run.
- text Property Map
- title String
- The text displayed in a parameter picking widget.
SqlQueryParameterDate, SqlQueryParameterDateArgs
- Value string
- The default value for this parameter.
- Value string
- The default value for this parameter.
- value String
- The default value for this parameter.
- value string
- The default value for this parameter.
- value str
- The default value for this parameter.
- value String
- The default value for this parameter.
SqlQueryParameterDateRange, SqlQueryParameterDateRangeArgs
- Range
Sql
Query Parameter Date Range Range - Value string
- The default value for this parameter.
- Range
Sql
Query Parameter Date Range Range - Value string
- The default value for this parameter.
- range
Sql
Query Parameter Date Range Range - value String
- The default value for this parameter.
- range
Sql
Query Parameter Date Range Range - value string
- The default value for this parameter.
- range
Sql
Query Parameter Date Range Range - value str
- The default value for this parameter.
- range Property Map
- value String
- The default value for this parameter.
SqlQueryParameterDateRangeRange, SqlQueryParameterDateRangeRangeArgs
SqlQueryParameterDatetime, SqlQueryParameterDatetimeArgs
- Value string
- The default value for this parameter.
- Value string
- The default value for this parameter.
- value String
- The default value for this parameter.
- value string
- The default value for this parameter.
- value str
- The default value for this parameter.
- value String
- The default value for this parameter.
SqlQueryParameterDatetimeRange, SqlQueryParameterDatetimeRangeArgs
- Range
Sql
Query Parameter Datetime Range Range - Value string
- The default value for this parameter.
- Range
Sql
Query Parameter Datetime Range Range - Value string
- The default value for this parameter.
- range
Sql
Query Parameter Datetime Range Range - value String
- The default value for this parameter.
- range
Sql
Query Parameter Datetime Range Range - value string
- The default value for this parameter.
- range
Sql
Query Parameter Datetime Range Range - value str
- The default value for this parameter.
- range Property Map
- value String
- The default value for this parameter.
SqlQueryParameterDatetimeRangeRange, SqlQueryParameterDatetimeRangeRangeArgs
SqlQueryParameterDatetimesec, SqlQueryParameterDatetimesecArgs
- Value string
- The default value for this parameter.
- Value string
- The default value for this parameter.
- value String
- The default value for this parameter.
- value string
- The default value for this parameter.
- value str
- The default value for this parameter.
- value String
- The default value for this parameter.
SqlQueryParameterDatetimesecRange, SqlQueryParameterDatetimesecRangeArgs
- Range
Sql
Query Parameter Datetimesec Range Range - Value string
- The default value for this parameter.
- Range
Sql
Query Parameter Datetimesec Range Range - Value string
- The default value for this parameter.
- range
Sql
Query Parameter Datetimesec Range Range - value String
- The default value for this parameter.
- range
Sql
Query Parameter Datetimesec Range Range - value string
- The default value for this parameter.
- range
Sql
Query Parameter Datetimesec Range Range - value str
- The default value for this parameter.
- range Property Map
- value String
- The default value for this parameter.
SqlQueryParameterDatetimesecRangeRange, SqlQueryParameterDatetimesecRangeRangeArgs
SqlQueryParameterEnum, SqlQueryParameterEnumArgs
- Options List<string>
- Multiple
Sql
Query Parameter Enum Multiple - Value string
- The default value for this parameter.
- Values List<string>
- Options []string
- Multiple
Sql
Query Parameter Enum Multiple - Value string
- The default value for this parameter.
- Values []string
- options List<String>
- multiple
Sql
Query Parameter Enum Multiple - value String
- The default value for this parameter.
- values List<String>
- options string[]
- multiple
Sql
Query Parameter Enum Multiple - value string
- The default value for this parameter.
- values string[]
- options Sequence[str]
- multiple
Sql
Query Parameter Enum Multiple - value str
- The default value for this parameter.
- values Sequence[str]
- options List<String>
- multiple Property Map
- value String
- The default value for this parameter.
- values List<String>
SqlQueryParameterEnumMultiple, SqlQueryParameterEnumMultipleArgs
SqlQueryParameterNumber, SqlQueryParameterNumberArgs
- Value double
- The default value for this parameter.
- Value float64
- The default value for this parameter.
- value Double
- The default value for this parameter.
- value number
- The default value for this parameter.
- value float
- The default value for this parameter.
- value Number
- The default value for this parameter.
SqlQueryParameterQuery, SqlQueryParameterQueryArgs
- Query
Id string - Multiple
Sql
Query Parameter Query Multiple - Value string
- The default value for this parameter.
- Values List<string>
- Query
Id string - Multiple
Sql
Query Parameter Query Multiple - Value string
- The default value for this parameter.
- Values []string
- query
Id String - multiple
Sql
Query Parameter Query Multiple - value String
- The default value for this parameter.
- values List<String>
- query
Id string - multiple
Sql
Query Parameter Query Multiple - value string
- The default value for this parameter.
- values string[]
- query_
id str - multiple
Sql
Query Parameter Query Multiple - value str
- The default value for this parameter.
- values Sequence[str]
- query
Id String - multiple Property Map
- value String
- The default value for this parameter.
- values List<String>
SqlQueryParameterQueryMultiple, SqlQueryParameterQueryMultipleArgs
SqlQueryParameterText, SqlQueryParameterTextArgs
- Value string
- The default value for this parameter.
- Value string
- The default value for this parameter.
- value String
- The default value for this parameter.
- value string
- The default value for this parameter.
- value str
- The default value for this parameter.
- value String
- The default value for this parameter.
SqlQuerySchedule, SqlQueryScheduleArgs
SqlQueryScheduleContinuous, SqlQueryScheduleContinuousArgs
- Interval
Seconds int - Until
Date string
- Interval
Seconds int - Until
Date string
- interval
Seconds Integer - until
Date String
- interval
Seconds number - until
Date string
- interval_
seconds int - until_
date str
- interval
Seconds Number - until
Date String
SqlQueryScheduleDaily, SqlQueryScheduleDailyArgs
- Interval
Days int - Time
Of stringDay - Until
Date string
- Interval
Days int - Time
Of stringDay - Until
Date string
- interval
Days Integer - time
Of StringDay - until
Date String
- interval
Days number - time
Of stringDay - until
Date string
- interval_
days int - time_
of_ strday - until_
date str
- interval
Days Number - time
Of StringDay - until
Date String
SqlQueryScheduleWeekly, SqlQueryScheduleWeeklyArgs
- Day
Of stringWeek - Interval
Weeks int - Time
Of stringDay - Until
Date string
- Day
Of stringWeek - Interval
Weeks int - Time
Of stringDay - Until
Date string
- day
Of StringWeek - interval
Weeks Integer - time
Of StringDay - until
Date String
- day
Of stringWeek - interval
Weeks number - time
Of stringDay - until
Date string
- day_
of_ strweek - interval_
weeks int - time_
of_ strday - until_
date str
- day
Of StringWeek - interval
Weeks Number - time
Of StringDay - until
Date String
Import
You can import a databricks_sql_query
resource with ID like the following:
bash
$ pulumi import databricks:index/sqlQuery:SqlQuery this <query-id>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- databricks pulumi/pulumi-databricks
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
databricks
Terraform Provider.