Transform multiple rows into an array in one object through canonical transform

#1

I have a type defined as

@db(compactType=true,
datastore=‘cassandra’,
partitionKeyField=‘parent’,
persistenceOrder=‘timestamp’)
entity type TypeA schema name ‘ABCDE’ {
quantities: [double]
other fields…
}

The data I want to load to the quantities array is in the following csv format

quantity, index
1, 1
2, 2
4, 5

Can I just fetch the object for TypeA, add the quantity to the array, and then upsert it in the transform function?
Is it possible for two threads/workers to run the transform function at the same time and the array upserted by one thread/worker to be overwritten by another thread/worker?

#2

transform function has to be https://en.wikipedia.org/wiki/Pure_function so, no, you can’t fetch+append+and update

I assume there are more fields then quantity and index - e.g. typeA - in which case you need to map this source to a type that will eventually be an fkey child in TypeB (vs. embedded array as you have it here).

i.e.

@db(compactType=true, datastore=‘cassandra’, partitionKeyField=‘typeA’, persistenceOrder=‘index’)
type Quantity  {
  typeA: TypeA
  index: int
  quantity: double
}

type TypeA {
  quantities: [Quantity] (typeA)
}