mirror of
https://github.com/minio/minio.git
synced 2025-11-20 18:06:10 -05:00
Fix S3Select SQL column reference handling (#11957)
This change fixes handling of these types of queries:
- Double quoted column names with special characters:
SELECT "column.name" FROM s3object
- Double quoted column names with reserved keywords:
SELECT "CAST" FROM s3object
- Table name as prefix for column names:
SELECT S3Object."CAST" FROM s3object
This commit is contained in:
committed by
GitHub
parent
d5d2fc9850
commit
b2936243f9
@@ -36,6 +36,27 @@ func (e *JSONPath) String() string {
|
||||
return e.pathString
|
||||
}
|
||||
|
||||
// StripTableAlias removes a table alias from the path. The result is also
|
||||
// cached for repeated lookups during SQL query evaluation.
|
||||
func (e *JSONPath) StripTableAlias(tableAlias string) []*JSONPathElement {
|
||||
if e.strippedTableAlias == tableAlias {
|
||||
return e.strippedPathExpr
|
||||
}
|
||||
|
||||
hasTableAlias := e.BaseKey.String() == tableAlias || strings.ToLower(e.BaseKey.String()) == baseTableName
|
||||
var pathExpr []*JSONPathElement
|
||||
if hasTableAlias {
|
||||
pathExpr = e.PathExpr
|
||||
} else {
|
||||
pathExpr = make([]*JSONPathElement, len(e.PathExpr)+1)
|
||||
pathExpr[0] = &JSONPathElement{Key: &ObjectKey{ID: e.BaseKey}}
|
||||
copy(pathExpr[1:], e.PathExpr)
|
||||
}
|
||||
e.strippedTableAlias = tableAlias
|
||||
e.strippedPathExpr = pathExpr
|
||||
return e.strippedPathExpr
|
||||
}
|
||||
|
||||
func (e *JSONPathElement) String() string {
|
||||
switch {
|
||||
case e.Key != nil:
|
||||
|
||||
Reference in New Issue
Block a user