mirror of
https://github.com/minio/minio.git
synced 2025-11-20 18:06:10 -05:00
Add support for Timestamp data type in SQL Select (#7185)
This change adds support for casting strings to Timestamp via CAST:
`CAST('2010T' AS TIMESTAMP)`
It also implements the following date-time functions:
- UTCNOW()
- DATE_ADD()
- DATE_DIFF()
- EXTRACT()
For values passed to these functions, date-types are automatically
inferred.
This commit is contained in:
committed by
kannappanr
parent
ea6d61ab1f
commit
f04f8bbc78
@@ -201,6 +201,16 @@ func (e *FuncExpr) analyze(s *Select) (result qProp) {
|
||||
case sqlFnExtract:
|
||||
return e.Extract.From.analyze(s)
|
||||
|
||||
case sqlFnDateAdd:
|
||||
result.combine(e.DateAdd.Quantity.analyze(s))
|
||||
result.combine(e.DateAdd.Timestamp.analyze(s))
|
||||
return result
|
||||
|
||||
case sqlFnDateDiff:
|
||||
result.combine(e.DateDiff.Timestamp1.analyze(s))
|
||||
result.combine(e.DateDiff.Timestamp2.analyze(s))
|
||||
return result
|
||||
|
||||
// Handle aggregation function calls
|
||||
case aggFnAvg, aggFnMax, aggFnMin, aggFnSum, aggFnCount:
|
||||
// Initialize accumulator
|
||||
@@ -283,6 +293,11 @@ func (e *FuncExpr) analyze(s *Select) (result qProp) {
|
||||
}
|
||||
return result
|
||||
|
||||
case sqlFnUTCNow:
|
||||
if len(e.SFunc.ArgsList) != 0 {
|
||||
result.err = fmt.Errorf("%s() takes no arguments", string(funcName))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// TODO: implement other functions
|
||||
|
||||
Reference in New Issue
Block a user