echauchot commented on code in PR #3:
URL:
https://github.com/apache/flink-connector-cassandra/pull/3#discussion_r1105851298
##########
flink-connector-cassandra/src/test/java/org/apache/flink/connector/cassandra/source/reader/CassandraQueryTest.java:
##########
@@ -31,84 +32,35 @@
/** tests for query generation and query sanity checks. */
class CassandraQueryTest {
+ private static final Pattern PATTERN =
Pattern.compile(CassandraSplitReader.SELECT_REGEXP);
+
@Test
public void testKeySpaceTableExtractionRegexp() {
- final Pattern pattern =
Pattern.compile(CassandraSplitReader.SELECT_REGEXP);
- Matcher matcher;
- matcher = pattern.matcher("SELECT field FROM keyspace.table where
field = value;");
- assertThat(matcher.matches()).isTrue();
- assertThat(matcher.group(1)).isEqualTo("keyspace");
- assertThat(matcher.group(2)).isEqualTo("table");
-
- matcher = pattern.matcher("SELECT * FROM keyspace.table;");
- assertThat(matcher.matches()).isTrue();
- assertThat(matcher.group(1)).isEqualTo("keyspace");
- assertThat(matcher.group(2)).isEqualTo("table");
- matcher = pattern.matcher("select field1, field2 from
keyspace.table;");
- assertThat(matcher.matches()).isTrue();
- assertThat(matcher.group(1)).isEqualTo("keyspace");
- assertThat(matcher.group(2)).isEqualTo("table");
+ assertQueryFormatCorrect("SELECT field FROM keyspace.table where field
= value;");
+ assertQueryFormatCorrect("SELECT * FROM keyspace.table;");
+ assertQueryFormatCorrect("select field1, field2 from keyspace.table;");
+ assertQueryFormatCorrect("select field1, field2 from keyspace.table
LIMIT(1000);");
+ assertQueryFormatCorrect("select field1 from keyspace.table ;");
+ assertQueryFormatCorrect("select field1 from keyspace.table where
field1=1;");
- matcher = pattern.matcher("select field1, field2 from keyspace.table
LIMIT(1000);");
- assertThat(matcher.matches()).isTrue();
- assertThat(matcher.group(1)).isEqualTo("keyspace");
- assertThat(matcher.group(2)).isEqualTo("table");
-
- matcher = pattern.matcher("select field1 from keyspace.table ;");
- assertThat(matcher.matches()).isTrue();
- assertThat(matcher.group(1)).isEqualTo("keyspace");
- assertThat(matcher.group(2)).isEqualTo("table");
-
- matcher = pattern.matcher("select field1 from keyspace.table where
field1=1;");
- assertThat(matcher.matches()).isTrue();
- assertThat(matcher.group(1)).isEqualTo("keyspace");
- assertThat(matcher.group(2)).isEqualTo("table");
-
- matcher = pattern.matcher("select field1 from table;"); // missing
keyspace
- assertThat(matcher.matches()).isFalse();
-
- matcher = pattern.matcher("select field1 from keyspace.table"); //
missing ";"
- assertThat(matcher.matches()).isFalse();
+ assertQueryFormatIncorrect("select field1 from table;"); // missing
keyspace
+ assertQueryFormatIncorrect("select field1 from keyspace.table"); //
missing ";"
}
@Test
public void testProhibitedClauses() {
- assertThatThrownBy(
- () ->
- CassandraSource.checkQueryValidity(
- "SELECT COUNT(*) from flink.table;"))
- .isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("Aggregations/OrderBy are not
supported");
- assertThatThrownBy(
- () -> CassandraSource.checkQueryValidity("SELECT
AVG(*) from flink.table;"))
- .isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("Aggregations/OrderBy are not
supported");
-
- assertThatThrownBy(
- () -> CassandraSource.checkQueryValidity("SELECT
MIN(*) from flink.table;"))
- .isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("Aggregations/OrderBy are not
supported");
- assertThatThrownBy(
- () -> CassandraSource.checkQueryValidity("SELECT
MAX(*) from flink.table;"))
- .isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("Aggregations/OrderBy are not
supported");
- assertThatThrownBy(
- () -> CassandraSource.checkQueryValidity("SELECT
SUM(*) from flink.table;"))
- .isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("Aggregations/OrderBy are not
supported");
- assertThatThrownBy(
- () ->
- CassandraSource.checkQueryValidity(
- "SELECT field1, field2 from
flink.table ORDER BY field1;"))
- .isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("Aggregations/OrderBy are not
supported");
- assertThatThrownBy(
- () ->
- CassandraSource.checkQueryValidity(
- "SELECT field1, field2 from
flink.table GROUP BY field1;"))
- .isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("Aggregations/OrderBy are not
supported");
+ Arrays.stream(
+ new String[] {
Review Comment:
Sketchy thing, not ready for review
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]