Skip to content

Commit

Permalink
feat: Add file format resource (#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
wookasz committed Jun 21, 2021
1 parent ad90692 commit 6b95dcb
Show file tree
Hide file tree
Showing 10 changed files with 2,568 additions and 1 deletion.
77 changes: 77 additions & 0 deletions docs/resources/file_format.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "snowflake_file_format Resource - terraform-provider-snowflake"
subcategory: ""
description: |-
---

# snowflake_file_format (Resource)



## Example Usage

```terraform
resource "snowflake_file_format" "example_file_format" {
name = "EXAMPLE_FILE_FORMAT"
database = "EXAMPLE_DB"
schema = "EXAMPLE_SCHEMA"
format_type = "CSV"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- **database** (String) The database in which to create the file format.
- **format_type** (String) Specifies the format of the input files (for data loading) or output files (for data unloading).
- **name** (String) Specifies the identifier for the file format; must be unique for the database and schema in which the file format is created.
- **schema** (String) The schema in which to create the file format.

### Optional

- **allow_duplicate** (Boolean) Boolean that specifies to allow duplicate object field names (only the last one will be preserved).
- **binary_as_text** (Boolean) Boolean that specifies whether to interpret columns with no defined logical data type as UTF-8 text.
- **binary_format** (String) Defines the encoding format for binary input or output.
- **comment** (String) Specifies a comment for the file format.
- **compression** (String) Specifies the current compression algorithm for the data file.
- **date_format** (String) Defines the format of date values in the data files (data loading) or table (data unloading).
- **disable_auto_convert** (Boolean) Boolean that specifies whether the XML parser disables automatic conversion of numeric and Boolean values from text to native representation.
- **disable_snowflake_data** (Boolean) Boolean that specifies whether the XML parser disables recognition of Snowflake semi-structured data tags.
- **empty_field_as_null** (Boolean) Specifies whether to insert SQL NULL for empty fields in an input file, which are represented by two successive delimiters.
- **enable_octal** (Boolean) Boolean that enables parsing of octal numbers.
- **encoding** (String) String (constant) that specifies the character set of the source data when loading data into a table.
- **error_on_column_count_mismatch** (Boolean) Boolean that specifies whether to generate a parsing error if the number of delimited columns (i.e. fields) in an input file does not match the number of columns in the corresponding table.
- **escape** (String) Single character string used as the escape character for field values.
- **escape_unenclosed_field** (String) Single character string used as the escape character for unenclosed field values only.
- **field_delimiter** (String) Specifies one or more singlebyte or multibyte characters that separate fields in an input file (data loading) or unloaded file (data unloading).
- **field_optionally_enclosed_by** (String) Character used to enclose strings.
- **file_extension** (String) Specifies the extension for files unloaded to a stage.
- **id** (String) The ID of this resource.
- **ignore_utf8_errors** (Boolean) Boolean that specifies whether UTF-8 encoding errors produce error conditions.
- **null_if** (List of String) String used to convert to and from SQL NULL.
- **preserve_space** (Boolean) Boolean that specifies whether the XML parser preserves leading and trailing spaces in element content.
- **record_delimiter** (String) Specifies one or more singlebyte or multibyte characters that separate records in an input file (data loading) or unloaded file (data unloading).
- **replace_invalid_characters** (Boolean) Boolean that specifies whether to replace invalid UTF-8 characters with the Unicode replacement character (�).
- **skip_blank_lines** (Boolean) Boolean that specifies to skip any blank lines encountered in the data files.
- **skip_byte_order_mark** (Boolean) Boolean that specifies whether to skip the BOM (byte order mark), if present in a data file.
- **skip_header** (Number) Number of lines at the start of the file to skip.
- **strip_null_values** (Boolean) Boolean that instructs the JSON parser to remove object fields or array elements containing null values.
- **strip_outer_array** (Boolean) Boolean that instructs the JSON parser to remove outer brackets.
- **strip_outer_element** (Boolean) Boolean that specifies whether the XML parser strips out the outer XML element, exposing 2nd level elements as separate documents.
- **time_format** (String) Defines the format of time values in the data files (data loading) or table (data unloading).
- **timestamp_format** (String) Defines the format of timestamp values in the data files (data loading) or table (data unloading).
- **trim_space** (Boolean) Boolean that specifies whether to remove white space from fields.
- **validate_utf8** (Boolean) Boolean that specifies whether to validate UTF-8 character encoding in string column data.

## Import

Import is supported using the following syntax:

```shell
# format is database name | schema name | file format name
terraform import snowflake_file_format.example 'dbName|schemaName|fileFormatName'
```
2 changes: 2 additions & 0 deletions examples/resources/snowflake_file_format/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# format is database name | schema name | file format name
terraform import snowflake_file_format.example 'dbName|schemaName|fileFormatName'
6 changes: 6 additions & 0 deletions examples/resources/snowflake_file_format/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "snowflake_file_format" "example_file_format" {
name = "EXAMPLE_FILE_FORMAT"
database = "EXAMPLE_DB"
schema = "EXAMPLE_SCHEMA"
format_type = "CSV"
}
1 change: 1 addition & 0 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func getResources() map[string]*schema.Resource {
"snowflake_api_integration": resources.APIIntegration(),
"snowflake_database": resources.Database(),
"snowflake_external_function": resources.ExternalFunction(),
"snowflake_file_format": resources.FileFormat(),
"snowflake_managed_account": resources.ManagedAccount(),
"snowflake_masking_policy": resources.MaskingPolicy(),
"snowflake_materialized_view": resources.MaterializedView(),
Expand Down

0 comments on commit 6b95dcb

Please sign in to comment.