Skip to content

Commit

Permalink
fix: Escape String for AS in external table (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
alldoami committed Jun 17, 2021
1 parent a6d7f6f commit 3954741
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/resources/external_table_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ resource "snowflake_external_table" "test_table" {
comment = "Terraform acceptance test"
column {
name = "column1"
type = "TIMESTAMP_NTZ(9)"
as = "($1:\"CreatedDate\"::timestamp)"
type = "STRING"
as = "TO_VARCHAR(TO_TIMESTAMP_NTZ(value:unix_timestamp_property::NUMBER, 3), 'yyyy-mm-dd-hh')"
}
column {
name = "column2"
type = "TIMESTAMP_NTZ(9)"
as = "($1:\"CreatedDate\"::timestamp)"
as = "($1:'CreatedDate'::timestamp)"
}
file_format = "TYPE = CSV"
location = "@${snowflake_database.test.name}.${snowflake_schema.test.name}.${snowflake_stage.test.name}"
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/external_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (tb *ExternalTableBuilder) Create() string {
q.WriteString(fmt.Sprintf(` (`))
columnDefinitions := []string{}
for _, columnDefinition := range tb.columns {
columnDefinitions = append(columnDefinitions, fmt.Sprintf(`"%v" %v AS %v`, EscapeString(columnDefinition["name"]), EscapeString(columnDefinition["type"]), EscapeString(columnDefinition["as"])))
columnDefinitions = append(columnDefinitions, fmt.Sprintf(`"%v" %v AS %v`, EscapeString(columnDefinition["name"]), EscapeString(columnDefinition["type"]), columnDefinition["as"]))
}
q.WriteString(strings.Join(columnDefinitions, ", "))
q.WriteString(fmt.Sprintf(`)`))
Expand Down

0 comments on commit 3954741

Please sign in to comment.