diff --git a/pkg/s3select/csv/args.go b/pkg/s3select/csv/args.go index f935b998c..33df09b28 100644 --- a/pkg/s3select/csv/args.go +++ b/pkg/s3select/csv/args.go @@ -65,6 +65,8 @@ func (args *ReaderArgs) UnmarshalXML(d *xml.Decoder, start xml.StartElement) err parsedArgs.FileHeaderInfo = strings.ToLower(parsedArgs.FileHeaderInfo) switch parsedArgs.FileHeaderInfo { + case "": + parsedArgs.FileHeaderInfo = none case none, use, ignore: default: return errInvalidFileHeaderInfo(fmt.Errorf("invalid FileHeaderInfo '%v'", parsedArgs.FileHeaderInfo)) diff --git a/pkg/s3select/select.go b/pkg/s3select/select.go index 8f6b46c04..88ad400cb 100644 --- a/pkg/s3select/select.go +++ b/pkg/s3select/select.go @@ -99,6 +99,11 @@ func (input *InputSerialization) UnmarshalXML(d *xml.Decoder, start xml.StartEle return errMalformedXML(err) } + // If no compression is specified, set to noneType + if parsedInput.CompressionType == CompressionType("") { + parsedInput.CompressionType = noneType + } + found := 0 if !parsedInput.CSVArgs.IsEmpty() { parsedInput.format = csvFormat @@ -172,10 +177,10 @@ type RequestProgress struct { } // S3Select - filters the contents on a simple structured query language (SQL) statement. It -// represents elements inside in request XML specified in detail at +// represents elements inside in request XML specified in detail at // https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectSELECTContent.html. type S3Select struct { - XMLName xml.Name `xml:"SelectObjectContentRequest"` + XMLName xml.Name `xml:"SelectRequest"` Expression string `xml:"Expression"` ExpressionType string `xml:"ExpressionType"` Input InputSerialization `xml:"InputSerialization"` @@ -187,8 +192,20 @@ type S3Select struct { recordReader recordReader } +var ( + legacyXMLName = "SelectObjectContentRequest" +) + // UnmarshalXML - decodes XML data. func (s3Select *S3Select) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + // S3 also supports the older SelectObjectContentRequest tag, + // though it is no longer found in documentation. This is + // checked and renamed below to allow older clients to also + // work. + if start.Name.Local == legacyXMLName { + start.Name = xml.Name{Space: "", Local: "SelectRequest"} + } + // Make subtype to avoid recursive UnmarshalXML(). type subS3Select S3Select parsedS3Select := subS3Select{}