From 822d4860d3f44938b7f1712df6be84a21036a53a Mon Sep 17 00:00:00 2001 From: Yongming Ding Date: Mon, 24 Oct 2022 12:11:12 -0700 Subject: [PATCH] Enclose Pod labels with single quote for Snowflake usecases In this commit, we updated the s3 uploader inside Flow Aggregator to enclose Pod label fields with single quote for snowflake usecases. Because commas are used to separate different columns in CSV and Pod labels json string contains commas, we enclose it with single quote to avoid them being separated into multiple columns in Snowflake. Signed-off-by: Yongming Ding --- pkg/flowaggregator/s3uploader/s3uploader.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/flowaggregator/s3uploader/s3uploader.go b/pkg/flowaggregator/s3uploader/s3uploader.go index 2f6d98417ea..a5bdb616239 100644 --- a/pkg/flowaggregator/s3uploader/s3uploader.go +++ b/pkg/flowaggregator/s3uploader/s3uploader.go @@ -459,9 +459,10 @@ func writeRecord(w io.Writer, r *flowrecord.FlowRecord, clusterUUID string) { io.WriteString(w, ",") io.WriteString(w, fmt.Sprintf("%d", r.FlowType)) io.WriteString(w, ",") - io.WriteString(w, r.SourcePodLabels) + // Enclose Pod labels with single quote for Snowflake usecases + io.WriteString(w, fmt.Sprintf("'%s'", r.SourcePodLabels)) io.WriteString(w, ",") - io.WriteString(w, r.DestinationPodLabels) + io.WriteString(w, fmt.Sprintf("'%s'", r.DestinationPodLabels)) io.WriteString(w, ",") io.WriteString(w, fmt.Sprintf("%d", r.Throughput)) io.WriteString(w, ",")