Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_stream_analytics_reference_input_mssql: add support for table property #18211

Merged
merged 1 commit into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ func resourceStreamAnalyticsReferenceMsSql() *pluginsdk.Resource {
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
},

"table": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
},
},
}
}
Expand Down Expand Up @@ -158,6 +164,10 @@ func resourceStreamAnalyticsReferenceInputMsSqlCreateUpdate(d *pluginsdk.Resourc
properties.DeltaSnapshotQuery = utils.String(v.(string))
}

if v, ok := d.GetOk("table"); ok {
properties.Table = utils.String(v.(string))
}

props := streamanalytics.Input{
Name: utils.String(id.InputName),
Properties: &streamanalytics.ReferenceInputProperties{
Expand Down Expand Up @@ -221,6 +231,7 @@ func resourceStreamAnalyticsReferenceInputMsSqlRead(d *pluginsdk.ResourceData, m
d.Set("refresh_interval_duration", inputDataSource.AzureSQLReferenceInputDataSourceProperties.RefreshRate)
d.Set("full_snapshot_query", inputDataSource.AzureSQLReferenceInputDataSourceProperties.FullSnapshotQuery)
d.Set("delta_snapshot_query", inputDataSource.AzureSQLReferenceInputDataSourceProperties.DeltaSnapshotQuery)
d.Set("table", inputDataSource.AzureSQLReferenceInputDataSourceProperties.Table)
}
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ func TestAccStreamAnalyticsReferenceInputMsSql_update(t *testing.T) {
})
}

func TestAccStreamAnalyticsReferenceInputMsSql_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_stream_analytics_reference_input_mssql", "test")
r := StreamAnalyticsReferenceInputMsSqlResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("password"),
})
}

func TestAccStreamAnalyticsReferenceInputMsSql_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_stream_analytics_reference_input_mssql", "test")
r := StreamAnalyticsReferenceInputMsSqlResource{}
Expand Down Expand Up @@ -137,6 +152,32 @@ QUERY
`, template, data.RandomInteger)
}

func (r StreamAnalyticsReferenceInputMsSqlResource) complete(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%s

resource "azurerm_analytics_reference_input_mssql" "test" {
name = "acctestinput-%d"
stream_analytics_job_name = azurerm_stream_analytics_job.test.name
resource_group_name = azurerm_stream_analytics_job.test.resource_group_name
server = azurerm_mssql_server.test.fully_qualified_domain_name
database = azurerm_mssql_database.test.name
username = "maurice"
password = "ludicrousdisplay"
refresh_type = "RefreshPeriodicallyWithFull"
refresh_interval_duration = "00:10:00"
table = "exampletable"
full_snapshot_query = <<QUERY
SELECT *
INTO [YourOutputAlias]
FROM [YourInputAlias]
QUERY

}
`, template, data.RandomInteger)
}

func (r StreamAnalyticsReferenceInputMsSqlResource) requiresImport(data acceptance.TestData) string {
template := r.basic(data)
return fmt.Sprintf(`
Expand Down Expand Up @@ -197,8 +238,9 @@ resource "azurerm_mssql_server" "test" {
}

resource "azurerm_mssql_database" "test" {
name = "acctest-db-%[1]d"
server_id = azurerm_mssql_server.test.id
name = "acctest-db-%[1]d"
server_id = azurerm_mssql_server.test.id
license_type = "LicenseIncluded"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ The following arguments are supported:

* `delta_snapshot_query` - (Optional) The query used to retrieve incremental changes in the reference data from the MS SQL database. Cannot be set when `refresh_type` is `Static`.

* `table` - (Optional) The name of the table in the Azure SQL database.

## Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:
Expand Down