MongoVUE Bulk Insert - bulkinsert

I'm trying to insert multiple documents using MongoVUE by passing an array of documents in the Insert Document window. For example:
[ {"name": "Kiran", age: 20}, {"name": "John", "age": 31} ]
However, I kept getting the following error:
ReadStartDocument can only be called when CurrentBsonType is Document, not when CurrentBsonType is Array
Does anyone know how to do bulk insert in MongoVUE?
Thanks!

In case anyone else stumbles on this question, the answer is that the "Import Multiple Documents" functionality in MongoVue doesn't accept an array of objects like you would expect it to. Instead, it expects the document to be formatted as a simple series of documents.
For the above example, you could create a simple file called "import.json" and format the data like this and it will import fine:
{"name": "Kiran", age: 20}
{"name": "John", "age": 31}

Related

Altering or updating of nested data in DataFrame Spark

I have a very weird requirement in spark wherein I have to transform the data present in a dataframe.
So I read data from s3 bucket and transform them into a dataframe. This is being done fine, the next step is where the challenge lies.
Once the data is being read the data which is Json data needs to be transformed so that all data are consistent.
Sample data which I have
{"name": "John", "age": 24, "object_data": {"tax_details":""}}
{"name": "nash", "age": 26, "object_data": {"tax_details": {"Tax": "None"} } }
The issue is that tax_details field is string in first document and second document is having an object. I want to ascertain that everytime I put it as object, if that can be done by dataframe operation then it will be great. Else any pointer to do it will be great.
Looking for any help

Is it possible to prevent ORDS from escaping my GeoJSON?

I have a problem with Oracle ORDS escaping my GeoJSON with "
{
"id": 1,
"city": "New York",
"state_abrv": "NY",
"location": "{\"type\":\"Point\",\"coordinates\":[-73.943849, 40.6698]}"
}
In Oracle DB it is stated correctly:
{"type":"Point","coordinates":[-73.943849, 40.6698]}
Need help to figure out why the " are added and how to prevent this from happening
add this column alias to your restful service handler query for the JSON column
SELECT id,
jsons "{}jsons" --this one
FROM table_with_json
Then when ords sees the data for the column, it won't format it as JSON because it already IS json
You can use whatever you want, in your case it should probably be
"{}location"

How to extract this json into a table?

I've a sql column filled with json document, one for row:
[{
"ID":"TOT",
"type":"ABS",
"value":"32.0"
},
{
"ID":"T1",
"type":"ABS",
"value":"9.0"
},
{
"ID":"T2",
"type":"ABS",
"value":"8.0"
},
{
"ID":"T3",
"type":"ABS",
"value":"15.0"
}]
How is it possible to trasform it into tabular form? I tried with redshift json_extract_path_text and JSON_EXTRACT_ARRAY_ELEMENT_TEXT function, also I tried with json_each and json_each_text (on postgres) but didn't get what expected... any suggestions?
desired results should appear like this:
T1 T2 T3 TOT
9.0 8.0 15.0 32.0
I assume you printed 4 rows. In postgresql
SELECT this_column->'ID'
FROM that_table;
will return column with JSON strings. Use ->> if you want text column. More info here: https://www.postgresql.org/docs/current/static/functions-json.html
In case you were using some old Postgresql (before 9.3), this gets harder : )
Your best option is to use COPY from JSON Format. This will load the JSON directly into a normal table format. You then query it as normal data.
However, I suspect that you will need to slightly modify the format of the file by removing the outer [...] square brackets and also the commas between records, eg:
{
"ID": "TOT",
"type": "ABS",
"value": "32.0"
}
{
"ID": "T1",
"type": "ABS",
"value": "9.0"
}
If, however, your data is already loaded and you cannot re-load the data, you could either extract the data into a new table, or add additional columns to the existing table and use an UPDATE command to extract each field into a new column.
Or, very worst case, you can use one of the JSON Functions to access the information in a JSON field, but this is very inefficient for large requests (eg in a WHERE clause).

Bulk Update RavenDB

Good Morning, We are trying to find a way to do a Bulk update of a couple thousand documents in RavenDB. This is the first time we have done this as the DB is provided by a third party and they are not sure either on how to do this.
Essentially we have 1000's of records that look like this one below:
{
"VPOId": 8,
"Description": "VPO 8",
"AreaId": "93",
"AreaDisplay": "Area",
"Address": "Address",
"JobId": "109201005111",
"JobDisplay": "Address",
"TradeId": "19",
"TradeDisplay": "Finishing",
"VarianceId": "V70",
"VarianceDisplay": "V70 - Trade Change",
"SupplierId": "104095",
"SupplierDisplay": "Vendor Name",
"SupplierBackChargeId": null,
"SupplierBackChargeDisplay": null,
"IssuedDate": "2017-08-14T00:00:00.0000000",
"SearchTerms": " 109201005111 ",
"AccountId": "d740eb47-137d-e711-80d4-00505681128f",
"Active": true,
"DivisionDisplay": "010"
we need to mass update the Search Terms and the JobID Perferable from an our EXCEL spreadsheet mapping document. I have tried the export and import csv but that just seems to create new records vs updating the old ones or do we have a way that we can do that.
......
If your input is CSV, you'll need to write a script that does this.
You can do that in Python or C#.

PostgreSQL: Create Index in JSON Array

I am pretty new to postregSQL and not too familiar with SQL yet. But im trying to learn.
In my database i want to store huge JSON files (~2mio lines, 40mb) and later query them as fast as possible. Right now it is to slow, so i figured indexing should do the trick.
The Problem is i do not know how to index the file since it is a bit tricky. I am woking on it the whole day now and starting to get desperate..
My DB is calles "replays" the json column "replay_files"
So my files look like this:
"replay": [
{
"data": {
"posX": 182,
"posY": 176,
"hero_name": "CDOTA_Unit_Hero_EarthSpirit"
},
"tick": 2252,
"type": "entity"
},
{
"data": {
"posX": 123,
"posY": 186,
"hero_name": "CDOTA_Unit_Hero_Puck"
},
"tick": 2252,
"type": "entity"
}, ...alot more lines... ]}
I tried to get all the entries with say heron_name: Puck
So i tried this:
SELECT * FROM replays r, json_array_elements(r.replay_file#>'{replay}') obj WHERE obj->'data'->>'hero_name' = 'CDOTA_Unit_Hero_Puck';
Which is working but for smaller files.
So i want to index like that:
CREATE INDEX hero_name_index ON
replays ((json_array_elements(r.replay_file#>'{replay}')->'data'->'hero_name);
BUt it doesn work. I have no idea how to reach that deep into the file and get to index this stuff.
I hope you understand my problem since my english isnt the best and can help me out here. I just dont know what else to try out.
Kind regards and thanks alot in advance
Peter