From b27cd5ada876913440a770450b91bd30425ee156 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 3 Apr 2019 06:01:23 -0700 Subject: [PATCH] Make csv-input optional for default cases (#2741) Fixes #2740 --- cmd/client-s3.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 4dd04ccc..d0cfe2af 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -473,6 +473,10 @@ func selectObjectOutputOpts(selOpts SelectObjectOpts, i minio.SelectObjectInputS return o } +func trimCompressionFileExts(name string) string { + return strings.TrimSuffix(strings.TrimSuffix(strings.TrimSuffix(name, ".gz"), ".bz"), ".bz2") +} + // set the SelectObjectInputSerialization struct using options passed in by client. If unspecified, // default S3 API specified defaults func selectObjectInputOpts(selOpts SelectObjectOpts, object string) minio.SelectObjectInputSerialization { @@ -514,8 +518,8 @@ func selectObjectInputOpts(selOpts SelectObjectOpts, object string) minio.Select // i.CSV.QuotedRecordDelimiter = qrd // } } - ext := filepath.Ext(object) if i.CSV == nil && i.JSON == nil && i.Parquet == nil { + ext := filepath.Ext(trimCompressionFileExts(object)) if strings.Contains(ext, "csv") { i.CSV = &minio.CSVInputOptions{ RecordDelimiter: defaultRecordDelimiter,