planCreateList generates a list construction Interpretable.
(expr ast.Expr)
| 525 | |
| 526 | // planCreateList generates a list construction Interpretable. |
| 527 | func (p *planBuilder) planCreateList(expr ast.Expr) (InterpretableV2, error) { |
| 528 | list := expr.AsList() |
| 529 | optionalIndices := list.OptionalIndices() |
| 530 | elements := list.Elements() |
| 531 | optionals := make([]bool, len(elements)) |
| 532 | for _, index := range optionalIndices { |
| 533 | if index < 0 || index >= int32(len(elements)) { |
| 534 | return nil, fmt.Errorf("optional index %d out of element bounds [0, %d]", index, len(elements)) |
| 535 | } |
| 536 | optionals[index] = true |
| 537 | } |
| 538 | elems := make([]InterpretableV2, len(elements)) |
| 539 | for i, elem := range elements { |
| 540 | elemVal, err := p.plan(elem) |
| 541 | if err != nil { |
| 542 | return nil, err |
| 543 | } |
| 544 | elems[i] = elemVal |
| 545 | } |
| 546 | return &evalList{ |
| 547 | id: expr.ID(), |
| 548 | elems: elems, |
| 549 | optionals: optionals, |
| 550 | hasOptionals: len(optionalIndices) != 0, |
| 551 | adapter: p.adapter, |
| 552 | }, nil |
| 553 | } |
| 554 | |
| 555 | // planCreateStruct generates a map or object construction Interpretable. |
| 556 | func (p *planBuilder) planCreateMap(expr ast.Expr) (InterpretableV2, error) { |