terraform-provider-databricks icon indicating copy to clipboard operation
terraform-provider-databricks copied to clipboard

Add a `databricks_table` data source

Open jdavidheiser opened this issue 1 year ago • 12 comments

Changes

This adds a new data source to describe a Databricks table, to address the request in https://github.com/databricks/terraform-provider-databricks/issues/3148. I am not particularly familiar with the Databricks Terraform Provider repo, and not sure which styles are best to mimic. I opted to re-use the struct from the Databricks SDK, rather than implementing a new one. I don't see this pattern a lot in the repo, but it seems like recent changes to the SQL data source may have taken this approach.

Tests

I wanted to see if this approach of using the SDK structs is acceptable before writing tests. Go is not a language I normally work in, so it might take a bit of doing for me to figure out that part.

I did manually test it against a real Databricks workspace and confirm the return data shows up in my terraform.tfstate

  • [ ] make test run locally
  • [ ] relevant change in docs/ folder
  • [ ] covered with integration tests in internal/acceptance
  • [ ] relevant acceptance tests are passing
  • [ ] using Go SDK

jdavidheiser avatar Jan 26 '24 21:01 jdavidheiser

I fixed a formatting error and added some basic unit testing. I am not really set up for running integration tests yet. Setting that up seems like a lot of overhead to commit a change that just passes an SDK result through unmodified, so if someone already set up for integration tests could help me out that would be appreciated.

jdavidheiser avatar Jan 31 '24 15:01 jdavidheiser

Please add at least a unit test...

alexott avatar Jan 31 '24 19:01 alexott

Sorry, I did and forgot to commit it.. Should be there now.

jdavidheiser avatar Jan 31 '24 19:01 jdavidheiser

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 83.47%. Comparing base (edbda2a) to head (c9055a1). Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3170      +/-   ##
==========================================
+ Coverage   83.43%   83.47%   +0.04%     
==========================================
  Files         176      177       +1     
  Lines       16223    16258      +35     
==========================================
+ Hits        13536    13572      +36     
+ Misses       1865     1864       -1     
  Partials      822      822              
Files Coverage Δ
catalog/data_table.go 100.00% <100.00%> (ø)
provider/provider.go 94.68% <100.00%> (+0.02%) :arrow_up:

... and 5 files with indirect coverage changes

codecov-commenter avatar Jan 31 '24 19:01 codecov-commenter

Please rebase to the latest main branch to fix the conflict. The changes should be like this: https://github.com/databricks/terraform-provider-databricks/pull/3191/commits/e221fe7a142a2806bf702ff8a211d3caf325ec59

alexott avatar Feb 01 '24 12:02 alexott

conflict should be fixed and switched to common.resource

jdavidheiser avatar Feb 01 '24 13:02 jdavidheiser

you can always run make fmt && make lint before committing...

alexott avatar Feb 01 '24 14:02 alexott

Oh, I missed that documentation isn't a part of PR - please add the documentation as doc/data-sources/table.md file.

alexott avatar Feb 01 '24 14:02 alexott

I added a doc file - mostly copy/pasted from the Databricks SDK for Go docs.

jdavidheiser avatar Feb 05 '24 20:02 jdavidheiser

@jdavidheiser can you please resolve conflicts in the provider?

alexott avatar Feb 21 '24 06:02 alexott

fixed

jdavidheiser avatar Feb 22 '24 21:02 jdavidheiser

Hi - just circling back on this, hoping it could get merged soon to prevent more conflicts.

jdavidheiser avatar Mar 12 '24 13:03 jdavidheiser

Supersed by #3571

alexott avatar May 14 '24 13:05 alexott