planCreateList generates a list construction Interpretable.
(expr ast.Expr)
| 503 | |
| 504 | // planCreateList generates a list construction Interpretable. |
| 505 | func (p *planBuilder) planCreateList(expr ast.Expr) (InterpretableV2, error) { |
| 506 | list := expr.AsList() |
| 507 | optionalIndices := list.OptionalIndices() |
| 508 | elements := list.Elements() |
| 509 | optionals := make([]bool, len(elements)) |
| 510 | for _, index := range optionalIndices { |
| 511 | if index < 0 || index >= int32(len(elements)) { |
| 512 | return nil, fmt.Errorf("optional index %d out of element bounds [0, %d]", index, len(elements)) |
| 513 | } |
| 514 | optionals[index] = true |
| 515 | } |
| 516 | elems := make([]InterpretableV2, len(elements)) |
| 517 | for i, elem := range elements { |
| 518 | elemVal, err := p.plan(elem) |
| 519 | if err != nil { |
| 520 | return nil, err |
| 521 | } |
| 522 | elems[i] = elemVal |
| 523 | } |
| 524 | return &evalList{ |
| 525 | id: expr.ID(), |
| 526 | elems: elems, |
| 527 | optionals: optionals, |
| 528 | hasOptionals: len(optionalIndices) != 0, |
| 529 | adapter: p.adapter, |
| 530 | }, nil |
| 531 | } |
| 532 | |
| 533 | // planCreateStruct generates a map or object construction Interpretable. |
| 534 | func (p *planBuilder) planCreateMap(expr ast.Expr) (InterpretableV2, error) { |