featurebase/sql3/planner/inbuiltfunctionstable.go
pokeeffe-molecula 7c936471cc
sql3 changes (#2211)
* first cut of working (slowly) bulk insert; table valued functions and a tuple data type to support time quantums

* oversight

* filter pushdown implementation; bulk insert

* addressed some linter issues
2022-09-06 11:16:11 -05:00

66 lines
1.9 KiB
Go

package planner
import (
"github.com/molecula/featurebase/v3/sql3"
"github.com/molecula/featurebase/v3/sql3/parser"
)
// TODO (pok) this needs to go somewhere
/*func (p *ExecutionPlanner) analyzeFunctionRecord(call *parser.Call, scope parser.Statement) (parser.Expr, error) {
if len(call.Args) != 2 {
return nil, sql3.NewErrCallParameterCountMismatch(call.Rparen.Line, call.Rparen.Column, call.Name.Name, 2, len(call.Args))
}
// timestamp
timestampType := parser.NewDataTypeTimestamp()
if !typesAreAssignmentCompatible(timestampType, call.Args[0].DataType()) {
return nil, sql3.NewErrParameterTypeMistmatch(call.Args[0].Pos().Line, call.Args[0].Pos().Column, call.Args[0].DataType().TypeName(), timestampType.TypeName())
}
// set
ok, _ := typeIsSet(call.Args[1].DataType())
if !ok {
return nil, sql3.NewErrSetExpressionExpected(call.Args[1].Pos().Line, call.Args[1].Pos().Column)
}
//return record
call.ResultDataType = parser.NewDataTypeSubtable([]*parser.SubtableColumn{
{
Name: "",
DataType: timestampType,
},
{
Name: "",
DataType: call.Args[1].DataType(),
},
})
return call, nil
}
*/
func (p *ExecutionPlanner) analyzeFunctionSubtable(call *parser.Call, scope parser.Statement) (parser.Expr, error) {
if len(call.Args) != 1 {
return nil, sql3.NewErrCallParameterCountMismatch(call.Rparen.Line, call.Rparen.Column, call.Name.Name, 2, len(call.Args))
}
// set
ok, _ := typeIsTimeQuantum(call.Args[0].DataType())
if !ok {
// TODO (pok) send back the right error
return nil, sql3.NewErrSetExpressionExpected(call.Args[1].Pos().Line, call.Args[1].Pos().Column)
}
call.ResultDataType = parser.NewDataTypeSubtable([]*parser.SubtableColumn{
{
Name: "_id",
DataType: parser.NewDataTypeID(),
},
{
Name: "timestamp",
DataType: parser.NewDataTypeTimestamp(),
},
{
Name: "value",
DataType: call.Args[0].DataType(),
},
})
return call, nil
}