How to create an array of objects in data factory? - azure-data-factory

I need to have an array of objects and save it to JSON in Data Factory.
[
{"abc":123},
{"bca":123}
]
I can save it to JSON but it omits the comma (,).
This is my flow
My aggregate function
collect(#(abc=abc, ...))
This gives my an array for each object which is not what I want. I would like to wrap all the lines in one array.
Update
The image below shows the flattening of the incomming stream.
Thanks

You need to create the structure first in a Derived Column, then collect() that structure in an Aggregate.

Related

Query a Map containing a string saved in Cloud Firestore with Dart/Flutter

I've a problem with a query condition. I would like to query a string inside an array that's also inside a map. I manage to receive the information complet without the where condition but when I do this condition I've an error.
My function to retrieve all information
My array with a map inside
If category is the only value inside the produits array items, you can check for its existence with array-contains:
collectionRef.where('produits', arrayContains({ 'categorie': 'Alimentation' }))
If there are more properties for the array item, you will need to specify all of them in the call to arrayContains. There is no way to query for a subset of the array item.
In such cases, a common workaround is to add a extra array field to the document with just the property values you want to query for. For example:
produitsCategories: ['Alimentation', '...']
With that field in place you can then query it with:
collectionRef.where('produitsCategories', arrayContains('Alimentation'))

Is there any possible do upsert functionality in "array of an object" using firestore query?

Example :[{
inst:"EVA",
std:"12th"
},
{
inst:"KSF",
std:"12th"
}]
As per the above example, In my case if "inst: "EVA" is already there in the "qualification" array so we need to update the object from the existing one.
Then "inst: "KSF" does not already exist in the "qualification" array so we need to add that one.
Help me if there is any way to upsert using firestore query.
There is no "upsert" operation for objects in arrays. If you need to make changes to that array, you will have to read the document, modify the contents of the array in memory, then update the document with the new contents of the array.
Arrays of objects usually do not work the way that people want, given their limitations on querying and updating. It's usually better to store data as documents in a nested subcollection, so they can be more easily queried and updated by the contents of their fields.

Dgraph: Is it possible to store arrays natively?

When I tried to store an array like test: []string{"hello", "bye"} using dgo and queried for test, I only get back "hello". Seems like the closest way to store an array in Dgraph is to create multiple objects and point them towards a single node. If that is the case, how would you store a list of fixed length? or ensure the number of list nodes does not exceed the intended list size (e.g. having a todo list with only 10 slots)?
You can create and get an array of string as follows
**Query to create array of strings**
{"set":[{
"StringArray" : ["Hi", "hello"]
}]}
**Query to fetch array of strings**
{q(func:has(StringArray)){
uid
StringArray
}}
In dgraph it is called as List Type
Ref: https://docs.dgraph.io/query-language/#list-type

PostgreSQL: array in text to array

I have JSON array in text type field in DB, and I want to check whether there are some elements in the array, and in that case, add some elements to this array and save it back to DB. The main issue I am having is that this text field looks like this:
["elem1","elem2","elem3"]
and I cannot figure out how to work with those double-quotes.
When I tried to_json it resulted in:
"[\"elem1\",\"elem2\",\"elem3\"]"
When I tried string_to_array:
{"[\"elem1\"","\"elem2\"","\"elem3\"]"}
I just need something like that:
['elem1', 'elem2', 'elem3']
To get a JSON array, simply cast it into json directly:
demo:db<>fiddle
SELECT '["elem1","elem2","elem3"]'::json
If you need a simple array (without JSON), you need to expand the elements of the JSON array (json_array_elements_text()) and aggregate them afterwards (array_agg()):
SELECT
array_agg(elems)
FROM mytable,
json_array_elements_text(mydata::json) AS elems

Arrange NSDictionary unique value in iphone

Hi i am getting response form Json like this
{"items":[{"f":"djay","m":"hi ajay","d":"2012-9-22","id":"16"},{"f":"djay","m":"hi","d":"2012-9-22","id":"25"},{"f":"Chithri","m":"hi","d":"2012-9-23","id":"26"},{"f":"ChithriAtchibabu","m":"gig","d":"2012-9-23","id":"27"}]}
i want arrange my array like this
[{"time":"2012-9-22","data":[{"m":"hiajay"},{"m":hi}]},{"time":"2012-9-23","data":[{"m":"hi"},{"m":gig}]}]
can any one please guide me how could i arrange my array like this
An NSDictionary is an unsorted collection.
To sort the data in it makes no sense.
What you are doing in your post is completely rebuilding an array of dictionaries from another dictionary.
Also, a dictionary can't have duplicate keys.
To do this you'd have to go through the array "items" in your first dictionary and then create a new dictionary for each new date and then inside there put an array with the items in it. Or something...