Skip to content

Improve the ergonomics of creating field and list array accesses #7193

@alamb

Description

@alamb

Is your feature request related to a problem or challenge?

#6936 from @izveigor added a really nice set of array functionality 🏆 to access individual array elements as well as ranges!

However when I was testing the a bit of a mismatch in the GetFieldAccess struct which is now overloaded to return a named field in a struct, an element in a list or a range of a list.

More commentary here #6936 (comment)

You can see for example, the code to manipulate it here is pretty tricky: https://github.com/influxdata/influxdb_iox/pull/8419/files#diff-2ea572c49a95b9cbfa0647dbb38795bff1aa4dc788518bc8e83f80814f061b1f

Describe the solution you'd like

I think it would be a clearer API to separate out the FieldAccess for struct fields and ListAccess for list element acess

Perhaps something like

enum GetFieldAccess {
  /// returns the field `struct[field]`. For example `struct["name"]`
  NamedStructField { 
    name: ScalarValue,
  },
  /// single list index
  // list[i]
  ListIndex: {
    key: Expr
  },
  /// list range `list[i:j]`
  ListRange: {
    start: Expr
    stop: Expr
  },
}

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions