-
Notifications
You must be signed in to change notification settings - Fork 60
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
[Spark] Add Filters section for Java #226
Conversation
✅ Deploy Preview for docs-spark-connector ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
09ec43b
to
6cf6f39
Compare
source/java/filters.rst
Outdated
|
||
.. code-block:: java | ||
|
||
dataFrame.getInteger("qty").gte(of(10)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend keeping the example similar to python / scala so something like:
df.filter(df.col("gte").gte(30))
See example here: https://spark.apache.org/docs/latest/api/java/index.html?org/apache/spark/sql/Dataset.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is the same example that's used on the python tab of this section.
I've updated the syntax to use col()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few small things!
source/java/filters.rst
Outdated
@@ -0,0 +1,32 @@ | |||
.. include:: /includes/pushed-filters.rst | |||
|
|||
You can use `Java Aggregation Expressions <https://www.mongodb.com/docs/drivers/java/sync/upcoming/fundamentals/aggregation-expression-operations/>`__ to filter your data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: implement line breaks for readability
source/java/filters.rst
Outdated
@@ -0,0 +1,32 @@ | |||
.. include:: /includes/pushed-filters.rst | |||
|
|||
You can use `Java Aggregation Expressions <https://www.mongodb.com/docs/drivers/java/sync/upcoming/fundamentals/aggregation-expression-operations/>`__ to filter your data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: use an rst target such as the driver one
source/java/filters.rst
Outdated
|
||
.. include:: /includes/example-load-dataframe.rst | ||
|
||
First, create a DataFrame to connect with your default MongoDB data source: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, create a DataFrame to connect with your default MongoDB data source: | |
First, create a DataFrame to connect to your default MongoDB data source: |
source/java/filters.rst
Outdated
.format("mongodb") | ||
.option("database", "food") | ||
.option("collection", "fruit") | ||
.load(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: not sure about indentation here but should these be pushed in?
source/java/filters.rst
Outdated
.option("collection", "fruit") | ||
.load(); | ||
|
||
The following example includes only records in which the ``qty`` field is greater than or equal to ``10``: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following example includes only records in which the ``qty`` field is greater than or equal to ``10``: | |
The following example retrieves only records in which the value of the ``qty`` field is greater than or equal to ``10``: |
.. code-block:: java | ||
|
||
df.filter(df.col("qty").gte(10)) | ||
|
||
The operation outputs the following: | ||
|
||
.. code-block:: none | ||
|
||
+---+----+------+ | ||
|_id| qty| type| | ||
+---+----+------+ | ||
|2.0|10.0|orange| | ||
|3.0|15.0|banana| | ||
+---+----+------+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: convert into IO code block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, this formatting was odd to me too, but I'm matching the formatting of the other tabs and other example on this page. I think I'll open a separate PR to fix them all at one after this is merged. (There's like 10+ on this page and I don't want to clutter up this PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-33990
Staging - https://deploy-preview-226--docs-spark-connector.netlify.app/batch-mode/batch-read/#filters
Self-Review Checklist