-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schema questions for pymongoarrow when converting from pymongo #239
Comments
Thank you for the question! Tracking here: https://jira.mongodb.org/browse/ARROW-253 |
@covatic-john Can you please explain in more detail how you are doing the transformation with PyMongo described above? Thank you |
morning, my original pymongo query is
the before writing to parquet file I just converted the dataframe columns to the correct types I wanted in the parquet before writing out.
The parquet is then uploaded to s3 and then crawled by glue. This was legacy code not written by myself but nothing complicated. The only issue I see with my original statement is the schema I was trying which was this should have been
but I played around lots and final have
using a schema of I could not seem to get any data from
without using the js functions |
we have 3 mongo collections which hold a permission object all 3 slightly different in structure.
in pymongo I could just project the object and then convert the pandas column into string
df[c] = df[c].astype(pd.StringDtype())
then using Fastparquet as the engine write to parquet with the output like this
[{'location': 'notRequested'}, {'activity': 'never'}, {'pushNotifications': 'never'}, {'backgroundAuthStatus': 'permitted'}, {'att': 'denied'}, {'isPrecise': 'notRequested'}, {'adPersonalisation': 'true'}]
I am having issues when converting to use pymongoarrow. if I set the schema object as
"permissions": pa.list_(pa.string()),
then I get null/None, I have tried using ps.struct but then get empty values for the items that are missing in the structure.
currently my project in my query is
with a schema element of
"permissions": pa.list_(pa.string()),
but then need to convert the column with
df['permissions'] = df['permissions'].apply(list).astype(str).str.replace("'", "").str.replace('"', "'")
there must be an easier way to deal with these json objects as string. ultimately these are ending up in Redshift so can be parsed in queries. Any help or suggestions for something I thought would be quite simple.
3 days messing with mongo data and converting a migration to pymongoarrow. the other collections have been a breeze and the memory consumption has come down and have a speed improvement.
John
The text was updated successfully, but these errors were encountered: