You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/12/29 23:16:10 UTC

[GitHub] [beam] lpmarques opened a new pull request, #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

lpmarques opened a new pull request, #24830:
URL: https://github.com/apache/beam/pull/24830

   It would be very useful to be able to pass a user-defined query to CassandraIO for purposes of column selection only.
   
   However, the current method for query parsing assumes such query necessarily comes with a 'where' clause, which leads to an invalid resulting statement when this is not the case.
   
   The proposed change fixes this by checking if the user given query contains a where clause, appending a "WHERE" to it when it doesn't, instead of a "AND".
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/get-started-contributing/#make-the-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Go tests](https://github.com/apache/beam/workflows/Go%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on pull request #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

Posted by GitBox <gi...@apache.org>.
Abacn commented on PR #24830:
URL: https://github.com/apache/beam/pull/24830#issuecomment-1367688014

   Thanks for the catch, would you mind adding a unit test for this (query has no where clause)?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on a diff in pull request #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

Posted by GitBox <gi...@apache.org>.
Abacn commented on code in PR #24830:
URL: https://github.com/apache/beam/pull/24830#discussion_r1059434802


##########
sdks/java/io/cassandra/src/test/java/org/apache/beam/sdk/io/cassandra/CassandraIOTest.java:
##########
@@ -485,6 +489,39 @@ public void testReadWithQuery() throws Exception {
     pipeline.run();
   }
 
+  @Test
+  public void testReadWithUnfilteredQuery() throws Exception {
+    String query =
+        String.format(
+            "select person_id, writetime(person_name) from %s.%s",
+            CASSANDRA_KEYSPACE, CASSANDRA_TABLE);
+
+    PCollection<Scientist> output =
+        pipeline.apply(
+            CassandraIO.<Scientist>read()
+                .withHosts(Collections.singletonList(CASSANDRA_HOST))
+                .withPort(cassandraPort)
+                .withKeyspace(CASSANDRA_KEYSPACE)
+                .withTable(CASSANDRA_TABLE)
+                .withMinNumberOfSplits(20)
+                .withQuery(query)
+                .withCoder(SerializableCoder.of(Scientist.class))
+                .withEntity(Scientist.class));
+
+    PAssert.thatSingleton(output.apply("Count", Count.globally())).isEqualTo(22L);

Review Comment:
   ```suggestion
       PAssert.thatSingleton(output.apply("Count", Count.globally())).isEqualTo(NUM_ROWS);
   ```



##########
CHANGES.md:
##########
@@ -80,7 +80,7 @@
 
 ## Bugfixes
 
-* Fixed X (Java/Python) ([#X](https://github.com/apache/beam/issues/X)).
+* Avoids Cassandra syntax error when user-defined query has no where clause in it (Java/Python) ([#24829](https://github.com/apache/beam/issues/24829)).

Review Comment:
   ```suggestion
   * Avoids Cassandra syntax error when user-defined query has no where clause in it (Java) ([#24829](https://github.com/apache/beam/issues/24829)).
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lpmarques commented on pull request #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

Posted by GitBox <gi...@apache.org>.
lpmarques commented on PR #24830:
URL: https://github.com/apache/beam/pull/24830#issuecomment-1367979702

   > LGTM, thanks!
   
   Thanks for the fix up suggestions!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lpmarques commented on pull request #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

Posted by GitBox <gi...@apache.org>.
lpmarques commented on PR #24830:
URL: https://github.com/apache/beam/pull/24830#issuecomment-1373903297

   Hey, @Abacn. How you doing?
   
   Do we have any forecast for when 2.45.0 (or at least 2.44.0) is going to be realeased?
   
   Thanks in advance


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn merged pull request #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

Posted by GitBox <gi...@apache.org>.
Abacn merged PR #24830:
URL: https://github.com/apache/beam/pull/24830


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lpmarques commented on pull request #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

Posted by GitBox <gi...@apache.org>.
lpmarques commented on PR #24830:
URL: https://github.com/apache/beam/pull/24830#issuecomment-1367977701

   I've just noticed there are currently two unreleased versions on the changelog: 2.44.0 and 2.45.0. Should I disconsider the latter and move my change to the former one?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on pull request #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

Posted by GitBox <gi...@apache.org>.
Abacn commented on PR #24830:
URL: https://github.com/apache/beam/pull/24830#issuecomment-1367978245

   > I've just noticed there are currently two unreleased versions on the changelog: 2.44.0 and 2.45.0. Should I disconsider the latter and move my change to the former one?
   
   It will be 2.45.0. 2.44.0 branch is already cut: https://github.com/apache/beam/tree/release-2.44.0


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lpmarques commented on pull request #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

Posted by GitBox <gi...@apache.org>.
lpmarques commented on PR #24830:
URL: https://github.com/apache/beam/pull/24830#issuecomment-1367973741

   @Abacn thank you for the quick feedback. A unit test has been added now.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] github-actions[bot] commented on pull request #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #24830:
URL: https://github.com/apache/beam/pull/24830#issuecomment-1367651377

   Assigning reviewers. If you would like to opt out of this review, comment `assign to next reviewer`:
   
   R: @robertwb for label java.
   R: @chamikaramj for label io.
   
   Available commands:
   - `stop reviewer notifications` - opt out of the automated review tooling
   - `remind me after tests pass` - tag the comment author after tests pass
   - `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
   
   The PR bot will only process comments in the main thread (not review comments).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lpmarques commented on pull request #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

Posted by GitBox <gi...@apache.org>.
lpmarques commented on PR #24830:
URL: https://github.com/apache/beam/pull/24830#issuecomment-1367632350

   fixes #24829


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on pull request #24830: Fix Cassandra read bug when user query has no where clause (fixes #24829)

Posted by GitBox <gi...@apache.org>.
Abacn commented on PR #24830:
URL: https://github.com/apache/beam/pull/24830#issuecomment-1373912150

   Hi @lpmarques should be in mid Feb. Beam releases every 6 weeks. 2.45.0 branch will be cut next week and usually it takes 4-6 weeks to release.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org