From dcd6dd857234301e454757a7948dc07209b8b3d8 Mon Sep 17 00:00:00 2001 From: Rachel Mackintosh Date: Wed, 15 Jan 2025 09:15:44 -0500 Subject: [PATCH 1/6] java filters --- source/batch-mode/batch-read.txt | 5 +++++ source/java/filters.rst | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 source/java/filters.rst diff --git a/source/batch-mode/batch-read.txt b/source/batch-mode/batch-read.txt index 0d777de..0e0dae9 100644 --- a/source/batch-mode/batch-read.txt +++ b/source/batch-mode/batch-read.txt @@ -135,6 +135,11 @@ Filters tabs: + - id: java-sync + content: | + + .. include:: /java/filters.rst + - id: python content: | diff --git a/source/java/filters.rst b/source/java/filters.rst new file mode 100644 index 0000000..3f1894f --- /dev/null +++ b/source/java/filters.rst @@ -0,0 +1,32 @@ +.. include:: /includes/pushed-filters.rst + +You can use `Java Aggregation Expressions `__ to filter your data. + +.. include:: /includes/example-load-dataframe.rst + +First, set up a ``DataFrame`` object to connect with your default MongoDB data source: + +.. code-block:: java + + Dataset dataFrame = spark.read() + .format("mongodb") + .option("database", "food") + .option("collection", "fruit") + .load(); + +The following example includes only records in which the ``qty`` field is greater than or equal to ``10``: + +.. code-block:: java + + dataFrame.getInteger("qty").gte(of(10)) + +The operation outputs the following: + +.. code-block:: none + + +---+----+------+ + |_id| qty| type| + +---+----+------+ + |2.0|10.0|orange| + |3.0|15.0|banana| + +---+----+------+ From 6cf6f39a0d8498a7f50fd3164fa7187479eabf78 Mon Sep 17 00:00:00 2001 From: Rachel Mackintosh Date: Wed, 15 Jan 2025 09:45:49 -0500 Subject: [PATCH 2/6] typo --- source/java/filters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/java/filters.rst b/source/java/filters.rst index 3f1894f..ad36e2f 100644 --- a/source/java/filters.rst +++ b/source/java/filters.rst @@ -4,7 +4,7 @@ You can use `Java Aggregation Expressions Date: Thu, 16 Jan 2025 09:41:05 -0500 Subject: [PATCH 3/6] RL feedback --- source/java/filters.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/java/filters.rst b/source/java/filters.rst index ad36e2f..a9d9362 100644 --- a/source/java/filters.rst +++ b/source/java/filters.rst @@ -8,17 +8,17 @@ First, create a DataFrame to connect with your default MongoDB data source: .. code-block:: java - Dataset dataFrame = spark.read() - .format("mongodb") - .option("database", "food") - .option("collection", "fruit") - .load(); + Dataset df = spark.read() + .format("mongodb") + .option("database", "food") + .option("collection", "fruit") + .load(); The following example includes only records in which the ``qty`` field is greater than or equal to ``10``: .. code-block:: java - dataFrame.getInteger("qty").gte(of(10)) + df.filter(df.col("qty").gte(10)) The operation outputs the following: From bf0c9a993cdd70809335a4313f678eec33f42da8 Mon Sep 17 00:00:00 2001 From: Rachel Mackintosh Date: Fri, 17 Jan 2025 10:52:58 -0500 Subject: [PATCH 4/6] RR feedback --- source/java/filters.rst | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/java/filters.rst b/source/java/filters.rst index a9d9362..6181142 100644 --- a/source/java/filters.rst +++ b/source/java/filters.rst @@ -1,20 +1,23 @@ .. include:: /includes/pushed-filters.rst -You can use `Java Aggregation Expressions `__ to filter your data. +You can use :driver:`Java Aggregation Expressions +`__ +to filter your data. .. include:: /includes/example-load-dataframe.rst -First, create a DataFrame to connect with your default MongoDB data source: +First, create a DataFrame to connect to your default MongoDB data source: .. code-block:: java Dataset df = spark.read() - .format("mongodb") - .option("database", "food") - .option("collection", "fruit") - .load(); + .format("mongodb") + .option("database", "food") + .option("collection", "fruit") + .load(); -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 ``qty`` field +is greater than or equal to ``10``: .. code-block:: java From e5cea2294bd3d0f80d2da31a64397e4a7a6519e6 Mon Sep 17 00:00:00 2001 From: Rachel Mackintosh Date: Fri, 17 Jan 2025 11:00:08 -0500 Subject: [PATCH 5/6] link format --- source/java/filters.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/java/filters.rst b/source/java/filters.rst index 6181142..cbb8dc2 100644 --- a/source/java/filters.rst +++ b/source/java/filters.rst @@ -1,8 +1,8 @@ .. include:: /includes/pushed-filters.rst You can use :driver:`Java Aggregation Expressions -`__ -to filter your data. +` to filter +your data. .. include:: /includes/example-load-dataframe.rst From 86cd0bae571ec0145d0c39d0187e8031c57079f6 Mon Sep 17 00:00:00 2001 From: Rachel Mackintosh Date: Fri, 17 Jan 2025 11:10:17 -0500 Subject: [PATCH 6/6] link format --- source/java/filters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/java/filters.rst b/source/java/filters.rst index cbb8dc2..d0a203d 100644 --- a/source/java/filters.rst +++ b/source/java/filters.rst @@ -1,7 +1,7 @@ .. include:: /includes/pushed-filters.rst You can use :driver:`Java Aggregation Expressions -` to filter +` to filter your data. .. include:: /includes/example-load-dataframe.rst