-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CTK: Invoke MongoDB Table Loader with Zyp Transformation
On a specific collection loaded from a MongoDB Extended JSON file, mask (exclude/ignore/omit) certain elements, in order to import all records without further errors. Both elements will be dropped: - .image.available_sizes - .screenshots[].available_sizes The procedure can be improved on a later iteration.
- Loading branch information
Showing
3 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
cratedb-toolkit[influxdb,mongodb]==0.0.23 | ||
cratedb-toolkit[influxdb,mongodb]==0.0.24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# A Zyp Transformation [1] file to support importing datasets | ||
# from mongodb-json-files [2] into CrateDB [3]. | ||
# | ||
# [1] https://commons-codec.readthedocs.io/zyp/ | ||
# [2] https://github.com/ozlerhakan/mongodb-json-files | ||
# [3] https://cratedb.com/docs/guide/feature/ | ||
|
||
# Because CrateDB can not store nested arrays into OBJECT(DYNAMIC) columns, | ||
# this file defines a corresponding transformation to work around the problem. | ||
# | ||
# The workaround applied here is to just exclude/omit relevant `available_sizes` | ||
# elements completely. Converting them right can be implemented on behalf of a | ||
# later iteration. | ||
# | ||
# "image": { | ||
# "available_sizes": [ | ||
# [ | ||
# [ | ||
# 150, | ||
# 99 | ||
# ], | ||
# "assets/images/resized/0001/3896/13896v3-max-150x150.jpg" | ||
# ], | ||
# ] | ||
# | ||
# A possible representation could be: | ||
# | ||
# "image": { | ||
# "available_sizes": [ | ||
# { | ||
# "path": "assets/images/resized/0001/3896/13896v3-max-150x150.jpg", | ||
# "size": {"width": 150, "height": 99}, | ||
# } | ||
# ] | ||
# } | ||
--- | ||
|
||
meta: | ||
type: zyp-project | ||
version: 1 | ||
collections: | ||
- address: | ||
container: datasets | ||
name: companies | ||
pre: | ||
rules: | ||
- expression: .[] |= del(.image.available_sizes, .screenshots[].available_sizes) | ||
type: jq |