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

Resources for SQL Analytics queries and dashboards #553

Merged
merged 39 commits into from
Apr 22, 2021
Merged

Resources for SQL Analytics queries and dashboards #553

merged 39 commits into from
Apr 22, 2021

Conversation

pietern
Copy link
Contributor

@pietern pietern commented Mar 9, 2021

New resources are:

  • databricks_sql_query
  • databricks_sql_visualization
  • databricks_sql_dashboard
  • databricks_sql_widget

@pietern pietern requested a review from nfx March 9, 2021 12:18
@pietern pietern marked this pull request as draft March 9, 2021 12:23
@codecov
Copy link

codecov bot commented Mar 9, 2021

Codecov Report

Merging #553 (acfeb2c) into master (fc595ac) will increase coverage by 0.08%.
The diff coverage is 83.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #553      +/-   ##
==========================================
+ Coverage   82.55%   82.64%   +0.08%     
==========================================
  Files          79       85       +6     
  Lines        7032     7765     +733     
==========================================
+ Hits         5805     6417     +612     
- Misses        812      878      +66     
- Partials      415      470      +55     
Impacted Files Coverage Δ
sqlanalytics/api/widget.go 63.63% <63.63%> (ø)
sqlanalytics/resource_visualization.go 71.27% <71.27%> (ø)
sqlanalytics/api/query.go 73.25% <73.25%> (ø)
sqlanalytics/resource_widget.go 83.45% <83.45%> (ø)
sqlanalytics/resource_dashboard.go 84.61% <84.61%> (ø)
sqlanalytics/resource_query.go 94.75% <94.75%> (ø)
provider/provider.go 95.65% <100.00%> (+0.05%) ⬆️
... and 3 more

Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First batch of changes requested :)

sqlanalytics/api/query.go Show resolved Hide resolved
sqlanalytics/resource_visualization.go Outdated Show resolved Hide resolved
sqlanalytics/resource_visualization.go Outdated Show resolved Hide resolved
sqlanalytics/resource_visualization.go Outdated Show resolved Hide resolved
sqlanalytics/resource_visualization.go Outdated Show resolved Hide resolved
sqlanalytics/resource_visualization.go Show resolved Hide resolved
sqlanalytics/resource_visualization.go Outdated Show resolved Hide resolved
sqlanalytics/resource_visualization.go Outdated Show resolved Hide resolved
sqlanalytics/resource_query_test.go Show resolved Hide resolved
sqlanalytics/resource_query.go Outdated Show resolved Hide resolved
@pietern pietern changed the title Resources for SQL Analytics queries and visualizations Resources for SQL Analytics queries and dashboards Mar 18, 2021
@pietern pietern marked this pull request as ready for review March 18, 2021 13:30
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR drops coverage by 19% - https://app.codecov.io/gh/databrickslabs/terraform-provider-databricks/compare/553/tree/sqlanalytics, please bring code coverage to the level of resource_sql_endpoint.go.

The other 3 things:

}

// NewWrapper creates and returns an API wrapper.
func NewWrapper(ctx context.Context, m interface{}) Wrapper {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split Wrapper into VisualizationAPI, QueryAPI, WidgetAPI structs and move entities and API wrappers to respective resource files, e.g. resource_widget.go will have NewWidgetsAPI factory, WidgetsAPI struct, WidgetEntity terraform entity for reflection, Widget api entity, and ResourceWidget. The main reason for this is that we have 82%+ code coverage requirement for all code that is written and gotestsum calculates coverage on the package level. I've figured it, when i was confident that reflect_resource is pretty well tested by other packages, but the coverage report didn't show any good results for it. api package coverage is missing from the report, meaning that there are long-term risks of changes going untested to production. This may not be ideal, but it is consistent with the rest of the codebase. Even the special package, dedicated to Accounts API only, follows the same conventions as packages that create resources within the workspace. We may reconsider package layout conventions if we want to have databricks-go-sdk and refactor all 7 packages in a separate pull request, adjusting resource.RetryContext along the way.

@nfx
Copy link
Contributor

nfx commented Mar 27, 2021

acceptance tests should have TestPreviewAcc prefix, so that we can test those separately.

@nfx nfx added this to the v0.3.3 milestone Mar 27, 2021
sqlanalytics/resource_query.go Outdated Show resolved Hide resolved
sqlanalytics/resource_query.go Show resolved Hide resolved
sqlanalytics/resource_query.go Outdated Show resolved Hide resolved
sqlanalytics/resource_query.go Outdated Show resolved Hide resolved
sqlanalytics/resource_query.go Outdated Show resolved Hide resolved
sqlanalytics/resource_query.go Outdated Show resolved Hide resolved
sqlanalytics/resource_query.go Show resolved Hide resolved
sqlanalytics/resource_query.go Outdated Show resolved Hide resolved
@pietern
Copy link
Contributor Author

pietern commented Apr 22, 2021

Output of make test-preview:

preview
---
 * [ ] TestPreviewAccDashboard (593.86s)
 * [ ] TestPreviewAccPipelineResource_CreatePipeline (2.15s)
 * [ ] TestPreviewAccQuery (865.81s)
 * [ ] TestPreviewAccSQLEndpoint (519.09s)
 * [x] sqlanalytics.TestPreviewAccSQLEndpoints (443.40s)

The pipeline failure is a known problem (erroneous template).

The SQLA failures are all caused by a non-empty plan for the SQL endpoint:

    acceptance.go:160: Step 1/1 error: After applying this test step, the plan was not empty.
        stdout:


        An execution plan has been generated and is shown below.
        Resource actions are indicated with the following symbols:
          ~ update in-place

        Terraform will perform the following actions:

          # databricks_sql_endpoint.this will be updated in-place
          ~ resource "databricks_sql_endpoint" "this" {
              - auto_stop_mins   = 120 -> null
                id               = "024de5b61abeb9c3"
              - min_num_clusters = 1 -> null
                name             = "tf-thcbecidgbdii"
              - num_clusters     = 1 -> null
                # (6 unchanged attributes hidden)


              - tags {
                }
                # (1 unchanged block hidden)
            }

        Plan: 0 to add, 1 to change, 0 to destroy.

This commit makes it match the style of the visualization and widget resources,
after they were converted to use composite IDs.
This commit makes it match the style of the visualization and widget resources,
after they were converted to use composite IDs.
@nfx nfx merged commit d4a20e2 into master Apr 22, 2021
@nfx nfx deleted the sqla-queries branch April 22, 2021 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants