Skip to content

Commit

Permalink
Revert "improve date and time for bq"
Browse files Browse the repository at this point in the history
This reverts commit 3d5dbd9.
  • Loading branch information
Amogh-Bharadwaj committed Jan 17, 2024
1 parent 3d5dbd9 commit 1b1887c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions flow/model/qvalue/avro_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ func (c *QValueAvroConverter) ToAvroValue() (interface{}, error) {
}
}
if c.Nullable {
return goavro.Union("long.timestamp-micros", t), nil
return goavro.Union("long.timestamp-micros", t.(int64)), nil
} else {
return t.(int64), nil
}
return t, nil
case QValueKindDate:
t, err := c.processGoDate()
if err != nil || t == nil {
Expand Down Expand Up @@ -238,12 +239,13 @@ func (c *QValueAvroConverter) processGoTime() (interface{}, error) {
return nil, fmt.Errorf("invalid Time value")
}

// Snowflake has issues with avro timestamp types, returning as string
ret := t.UnixMicro()
// Snowflake has issues with avro timestamp types, returning as string form of the int64
// See: https://stackoverflow.com/questions/66104762/snowflake-date-column-have-incorrect-date-from-avro-file
if c.TargetDWH == QDWHTypeSnowflake {
return fmt.Sprint(t.String()), nil
return fmt.Sprint(ret), nil
}
return t, nil
return ret, nil
}

func (c *QValueAvroConverter) processGoDate() (interface{}, error) {
Expand All @@ -256,10 +258,11 @@ func (c *QValueAvroConverter) processGoDate() (interface{}, error) {
return nil, fmt.Errorf("invalid Time value")
}

// Snowflake has issues with avro timestamp types, returning as string
// Snowflake has issues with avro timestamp types, returning as string form of the int64
// See: https://stackoverflow.com/questions/66104762/snowflake-date-column-have-incorrect-date-from-avro-file
if c.TargetDWH == QDWHTypeSnowflake {
return fmt.Sprint(t.Format("2006-03-03")), nil
ret := t.UnixMicro()
return fmt.Sprint(ret), nil
}
return t, nil
}
Expand Down

0 comments on commit 1b1887c

Please sign in to comment.