diff --git a/CHANGELOG.md b/CHANGELOG.md index 07ccf7555..8b057cdd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Quote by Default ([#241](https://github.com/databricks/dbt-databricks/pull/241)) - Avoid show table extended command. ([#231](https://github.com/databricks/dbt-databricks/pull/231)) - Use show table extended with table name list for get_catalog. ([#237](https://github.com/databricks/dbt-databricks/pull/237)) +- Add support for a glob pattern in the databricks_copy_into macro ([#259](https://github.com/databricks/dbt-databricks/pull/259)) ## dbt-databricks 1.3.2 (November 9, 2022) diff --git a/dbt/include/databricks/macros/copy_into.sql b/dbt/include/databricks/macros/copy_into.sql index fd483311f..f2c444cb8 100644 --- a/dbt/include/databricks/macros/copy_into.sql +++ b/dbt/include/databricks/macros/copy_into.sql @@ -7,6 +7,7 @@ source_encryption=none, validate=none, files=none, + pattern=none, format_options=none, copy_options=none) -%} @@ -47,6 +48,9 @@ from {{ source_clause }} fileformat = {{ file_format }} {% if validate -%} validate {{ validate }} {%- endif %} + {% if files and pattern %} + {{ exceptions.raise_compiler_error("You can only specify one of 'files' or 'pattern'") }} + {% endif %} {% if files -%} files = ( {%- for file in files -%} @@ -54,6 +58,9 @@ {%- endfor -%} ) {%- endif %} + {% if pattern -%} + pattern = '{{ pattern }}' + {%- endif %} {% if format_options -%} format_options ( {%- for key in format_options -%}