Skip to content

Conversation

@allisonwang-db
Copy link
Collaborator

resolves #41

Description

This PR adds a macro databricks_copy_into to support the COPY INTO command. You can use it with dbt run-operation:

dbt run-operation databricks_copy_into --args ...

Checklist

  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt-databricks next" section.

Copy link
Contributor

@ueshin ueshin left a comment

Choose a reason for hiding this comment

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

@allisonwang-db Thanks for working on this!

Could you fix the linter issue by running tox -e black?
Could you also add an item in CHANGELOG.txt for this?

Otherwise, LGTM.

Comment on lines +37 to +52
@use_profile("databricks_cluster")
def test_databricks_cluster(self):
self.test_copy_into()

@use_profile("databricks_sql_endpoint")
def test_databricks_sql_endpoint(self):
self.test_copy_into()
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this feature not support UC?

Copy link
Collaborator Author

@allisonwang-db allisonwang-db Sep 26, 2022

Choose a reason for hiding this comment

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

I tested against a UC cluster and I don't think UC can support this test case:

  1. UC does not allow the creation of parquet tables (only Delta is supported)
  2. UC does not allow access to the underlying path of a managed Delta table (so we can't get the source in the test)

But UC should support COPY INTO: https://docs.databricks.com/ingestion/copy-into/unity-catalog.html

@ueshin
Copy link
Contributor

ueshin commented Sep 27, 2022

Thanks! merging.

@ueshin ueshin merged commit 698daa7 into databricks:main Sep 27, 2022
@bilalaslamseattle
Copy link
Collaborator

@ueshin does this support the inline credentials that newer DBRs support for COPY INTO?

@ueshin
Copy link
Contributor

ueshin commented Sep 29, 2022

@bilalaslamseattle Yes, seems so, if you mean this:

{% if source_credential -%}
credential (
{%- for name in source_credential -%}
'{{ name }}' = '{{ source_credential[name] }}' {%- if not loop.last %}, {% endif -%}
{%- endfor -%}
)
{%- endif %}

cc @allisonwang-db

@allisonwang-db
Copy link
Collaborator Author

@bilalaslamseattle Yes, it should support the inline credentials (for the source table).

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.

Support for COPY INTO

3 participants