2022-05-06 17:43:51 +08:00
|
|
|
package planparserv2
|
|
|
|
|
|
|
|
import (
|
2023-06-09 01:28:37 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
2022-05-06 17:43:51 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/planpb"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ExprWithType struct {
|
|
|
|
expr *planpb.Expr
|
|
|
|
dataType schemapb.DataType
|
2023-08-21 19:36:20 +08:00
|
|
|
// ExprWithType can be a node only when nodeDependent is set to false.
|
|
|
|
// For example, a column expression or a value expression itself cannot be an expression node independently.
|
|
|
|
// Unless our execution backend can support them.
|
|
|
|
nodeDependent bool
|
2022-05-06 17:43:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func getError(obj interface{}) error {
|
|
|
|
err, ok := obj.(error)
|
|
|
|
if !ok {
|
|
|
|
// obj is not an error.
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func getExpr(obj interface{}) *ExprWithType {
|
|
|
|
n, ok := obj.(*ExprWithType)
|
|
|
|
if !ok {
|
|
|
|
// obj is not of *ExprWithType
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
|
|
|
func getGenericValue(obj interface{}) *planpb.GenericValue {
|
|
|
|
expr := getExpr(obj)
|
|
|
|
if expr == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return expr.expr.GetValueExpr().GetValue()
|
|
|
|
}
|
2024-10-31 14:20:22 +08:00
|
|
|
|
|
|
|
func getValueExpr(obj interface{}) *planpb.ValueExpr {
|
|
|
|
expr := getExpr(obj)
|
|
|
|
if expr == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return expr.expr.GetValueExpr()
|
|
|
|
}
|
|
|
|
|
|
|
|
func isTemplateExpr(expr *planpb.ValueExpr) bool {
|
|
|
|
return expr != nil && expr.GetTemplateVariableName() != ""
|
|
|
|
}
|