Skip to content

Commit

Permalink
ch data fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakaushik committed Feb 12, 2024
1 parent 26a1de8 commit 425f877
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions flow/model/qvalue/avro_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func GetAvroSchemaFromQValueKind(kind QValueKind, targetDWH QDWHType, precision
}, nil
case QValueKindTime, QValueKindTimeTZ, QValueKindDate, QValueKindTimestamp, QValueKindTimestampTZ:
if targetDWH == QDWHTypeClickhouse {
if kind == QValueKindTime || kind == QValueKindDate {
if kind == QValueKindTime {
return "string", nil
}
return "long", nil
Expand Down Expand Up @@ -259,15 +259,15 @@ func (c *QValueAvroConverter) ToAvroValue() (interface{}, error) {
return t, err
}

if c.TargetDWH == QDWHTypeSnowflake || c.TargetDWH == QDWHTypeClickhouse {
if c.TargetDWH == QDWHTypeSnowflake {
if c.Nullable {
return c.processNullableUnion("string", t.(string))
} else {
return t.(string), nil
}
}

if c.Nullable {
if c.Nullable && c.TargetDWH == QDWHTypeBigQuery {
return goavro.Union("int.date", t), nil
}
return t, nil
Expand Down Expand Up @@ -431,7 +431,7 @@ func (c *QValueAvroConverter) processGoDate() (interface{}, error) {

// Snowflake has issues with avro timestamp types, returning as string form
// See: https://stackoverflow.com/questions/66104762/snowflake-date-column-have-incorrect-date-from-avro-file
if c.TargetDWH == QDWHTypeSnowflake || c.TargetDWH == QDWHTypeClickhouse {
if c.TargetDWH == QDWHTypeSnowflake {
return t.Format("2006-01-02"), nil
}
return t, nil
Expand Down

0 comments on commit 425f877

Please sign in to comment.