Treat columns with spaces inbetween [s3Select] (#6597)

replace the double/single quotes with backticks for the xwb1989/sqlparser
to recognise such queries.

Fixes #6589
This commit is contained in:
Praveen raj Mani
2018-10-17 23:31:26 +05:30
committed by Dee Koder
parent c998d1ac8c
commit cef044178c
4 changed files with 19 additions and 11 deletions

View File

@@ -207,12 +207,6 @@ func (reader *Input) ReadRecord() []string {
return row
}
// convertMySQL Replaces double quote escape for column names with backtick for
// the MySQL parser
func convertMySQL(random string) string {
return strings.Replace(random, "\"", "`", len(random))
}
// readHeader reads the header into the header variable if the header is present
// as the first row of the csv
func (reader *Input) readHeader() error {
@@ -222,7 +216,7 @@ func (reader *Input) readHeader() error {
if readErr != nil {
return ErrCSVParsingError
}
reader.header = reader.firstRow
reader.header = cleanHeader(reader.firstRow)
reader.firstRow = nil
reader.minOutputLength = len(reader.header)
} else {
@@ -236,6 +230,14 @@ func (reader *Input) readHeader() error {
return nil
}
// Replace the spaces in columnnames with underscores
func cleanHeader(columns []string) []string {
for i := 0; i < len(columns); i++ {
columns[i] = strings.Replace(columns[i], " ", "_", -1)
}
return columns
}
// createStatXML is the function which does the marshaling from the stat
// structs into XML so that the progress and stat message can be sent
func (reader *Input) createStatXML() (string, error) {
@@ -296,7 +298,7 @@ func (reader *Input) Execute(writer io.Writer) error {
continuationTimer := time.NewTimer(continuationTime)
defer progressTicker.Stop()
defer continuationTimer.Stop()
go reader.runSelectParser(convertMySQL(reader.options.Expression), myRow)
go reader.runSelectParser(reader.options.Expression, myRow)
for {
select {
case row, ok := <-myRow: