Set correct compressionType for compression select request (#2730)
This commit is contained in:
committed by
kannappanr
parent
ba92305de0
commit
c34dec5495
@@ -537,8 +537,6 @@ func selectObjectInputOpts(selOpts SelectObjectOpts, object string) minio.Select
|
||||
// get client specified compression type or default compression type from file extension
|
||||
func selectCompressionType(selOpts SelectObjectOpts, object string) minio.SelectCompressionType {
|
||||
ext := filepath.Ext(object)
|
||||
origContentType := mimedb.TypeByExtension(filepath.Ext(strings.TrimSuffix(strings.TrimSuffix(object, ".gz"), ".bz2")))
|
||||
|
||||
contentType := mimedb.TypeByExtension(ext)
|
||||
|
||||
if selOpts.CompressionType != "" {
|
||||
@@ -547,12 +545,6 @@ func selectCompressionType(selOpts SelectObjectOpts, object string) minio.Select
|
||||
if strings.Contains(ext, "parquet") || strings.Contains(object, ".parquet") {
|
||||
return minio.SelectCompressionNONE
|
||||
}
|
||||
if origContentType != "" {
|
||||
if strings.Contains(origContentType, "csv") ||
|
||||
strings.Contains(origContentType, "json") {
|
||||
return minio.SelectCompressionNONE
|
||||
}
|
||||
}
|
||||
if contentType != "" {
|
||||
if strings.Contains(contentType, "gzip") {
|
||||
return minio.SelectCompressionGZIP
|
||||
|
||||
@@ -245,8 +245,8 @@ var testSelectCompressionTypeCases = []struct {
|
||||
{SelectObjectOpts{CompressionType: minio.SelectCompressionNONE}, "a.gzip", minio.SelectCompressionNONE},
|
||||
{SelectObjectOpts{CompressionType: minio.SelectCompressionBZIP}, "a.gz", minio.SelectCompressionBZIP},
|
||||
{SelectObjectOpts{}, "t.parquet", minio.SelectCompressionNONE},
|
||||
{SelectObjectOpts{}, "x.csv.gz", minio.SelectCompressionNONE},
|
||||
{SelectObjectOpts{}, "x.json.bz2", minio.SelectCompressionNONE},
|
||||
{SelectObjectOpts{}, "x.csv.gz", minio.SelectCompressionGZIP},
|
||||
{SelectObjectOpts{}, "x.json.bz2", minio.SelectCompressionBZIP},
|
||||
{SelectObjectOpts{}, "b.gz", minio.SelectCompressionGZIP},
|
||||
{SelectObjectOpts{}, "k.bz2", minio.SelectCompressionBZIP},
|
||||
{SelectObjectOpts{}, "a.csv", minio.SelectCompressionNONE},
|
||||
|
||||
+6
-6
@@ -103,17 +103,17 @@ EXAMPLES:
|
||||
3. Run a query on an encrypted object with customer provided keys.
|
||||
$ {{.HelpName}} --encrypt-key "myminio/iot-devices=32byteslongsecretkeymustbegiven1" \
|
||||
--query "select count(s.power) from S3Object s" myminio/iot-devices/power-ratio-encrypted.csv
|
||||
|
||||
|
||||
4. Run a query on an object on Minio in gzip format using ; as field delimiter,
|
||||
newline as record delimiter and file header to be used
|
||||
newline as record delimiter and file header to be used
|
||||
$ {{.HelpName}} --compression GZIP --csv-input "rd=\n,fh=USE,fd=;" \
|
||||
--query "select count(s.power) from S3Object" myminio/iot-devices/power-ratio.csv.gz
|
||||
|
||||
|
||||
5. Run a query on an object on Minio in gzip format using ; as field delimiter,
|
||||
newline as record delimiter and file header to be used
|
||||
$ {{.HelpName}} --compression GZIP --csv-input "rd=\n,fh=USE,fd=;" \
|
||||
newline as record delimiter and file header to be used
|
||||
$ {{.HelpName}} --compression GZIP --csv-input "rd=\n,fh=USE,fd=;" \
|
||||
--json-output "rd=\n\n" --query "select * from S3Object" myminio/iot-devices/data.csv
|
||||
|
||||
|
||||
6. Run same query as in 5., but specify csv output headers. If --csv-output-headers is
|
||||
specified as "", first row of csv is interpreted as header
|
||||
$ {{.HelpName}} --compression GZIP --csv-input "rd=\n,fh=USE,fd=;" \
|
||||
|
||||
Reference in New Issue
Block a user