Repository navigation
Conversation
|
Thanks for opening this pull request! Please check out our contributing guidelines. (https://flink.apache.org/contributing/how-to-contribute.html) |
da4bff2 to
656a4b5
Compare
MartijnVisser
left a comment
There was a problem hiding this comment.
The next release targets Flink 2.3 and 2.4 only, where the SinkFunction sinks don't compile. I would prefer to switch main to 2.3 and drop those sinks first (FLINK-41536), then land this without the sink ports. Can you rebase once that's in?
| <!-- For dependency convergence --> | ||
| <dependency> | ||
| <groupId>io.dropwizard.metrics</groupId> | ||
| <artifactId>metrics-core</artifactId> |
There was a problem hiding this comment.
CI fails on dependency convergence. Pinning metrics-core 4.1.18 and jsr305 1.3.9 here fixes it, I checked with -Pcheck-convergence on 1.20.5.
| this.cluster = clusterBuilder.getCluster(); | ||
| this.maxSplitMemorySize = maxSplitMemorySize; | ||
| this.session = cluster.newSession(); | ||
| this.session = sessionBuilder.getSession(); |
There was a problem hiding this comment.
getSession() connects, where cluster.newSession() didn't, and this runs on the coordinator thread. Can you open the session in prepareSplits instead?
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.flink.streaming.connectors.cassandra; |
There was a problem hiding this comment.
I think this and CassandraMapperOptions should move to org.apache.flink.connector.cassandra while we're breaking anyway, next to the source and the Sink V2 sink.
| * @param <T> the type of the mapped POJO | ||
| * @return the mapper | ||
| */ | ||
| public static <T> PojoMapper<T> create(Class<T> pojoClass) { |
There was a problem hiding this comment.
Naming and transients match the driver's generated code for the entities I tried, but @HierarchyScanStrategy is silently ignored and @PropertyStrategy fails with a misleading error. Please reject unsupported mapper annotations by name.
| * Returns the partition key columns formatted to be used in a CQL query, in the order of the | ||
| * partition key. The names of the case-sensitive columns are double-quoted. | ||
| */ | ||
| public static String getPartitionKeyString( |
There was a problem hiding this comment.
Both cases fail on main with InvalidQueryException, so I've filed FLINK-41537 for a v3.3 backport. Can you move this fix to a separate commit for that ticket? Through SQL a quoted key still fails on a 2.3 cluster, the select list in CassandraTableFactory isn't quoted.
…y columns and keep their order in the split queries
…m 3.11.2 to 4.19.4 The connector now uses the Java Driver for Apache Cassandra 4.19.4 (org.apache.cassandra:java-driver-*), whose API is not compatible with the version 3 of the driver. Breaking changes: - ClusterBuilder#buildCluster(Cluster.Builder) is replaced by CassandraSessionBuilder#buildSession(CqlSessionBuilder) and setClusterBuilder by setSessionBuilder. The SQL option 'cluster-builder-class' is renamed to 'session-builder-class'. - MapperOptions and SimpleMapperOptions are replaced by CassandraMapperOptions. - POJOs are annotated with the annotations of the driver mapper (@entity, @CqlName). As the mapper of the driver only works with an annotation processor, the connector maps the POJOs at runtime. - CassandraSinkBase#send returns a CompletionStage, Guava is not exposed by the driver anymore and is not bundled. - CQL date, time and timestamp are mapped to the java.time types. java.util.Date is still supported for timestamp columns. New options: - 'local-datacenter' SQL option and CassandraSinkBuilder#setLocalDatacenter. When it is not set, the local datacenter is inferred from the hosts. - 'driver.*' SQL options are passed to the driver configuration. - 'secure-connect-bundle' SQL option to connect to a cloud database, the hosts and the local datacenter are then ignored. The partition key columns used to build the token range queries of the source now keep the order of the partition key and are quoted when they are case-sensitive. This only changes the queries of the tables with a composite or a case-sensitive partition key. Generated-by: Claude Code (Claude Fable 5.2)
656a4b5 to
812d088
Compare
MartijnVisser
left a comment
There was a problem hiding this comment.
All five points from the last round are in, thanks. Can you rebase onto #56 and #54 once they're in and drop a39fca7? #54 covers FLINK-41537 including the SQL select list, on driver 4 that quoting is CqlIdentifier.fromInternal(name).asCql(true).
| : new HashSet<>(Arrays.asList(transientProperties.value())); | ||
|
|
||
| final List<Property> properties = new ArrayList<>(); | ||
| for (PropertyDescriptor descriptor : getPropertyDescriptors(pojoClass)) { |
There was a problem hiding this comment.
The driver's annotation processor maps 7 of 19 test entities differently: Boolean isX() and protected getters are dropped, and @CqlName, @Transient, @NamingStrategy and @TransientProperties on a superclass or interface are ignored. On reads that leaves fields unset without an error. Can the scan follow the processor, with it as the oracle in PojoMapperTest?
| } | ||
| final String name = descriptor.getName(); | ||
| final Field field = findField(pojoClass, name); | ||
| checkNoUnsupportedAnnotation(pojoClass, getter.getAnnotations()); |
There was a problem hiding this comment.
Only the class-level check is tested, PojoMapperTest stays green with the getter, setter and field checks removed.
| continue; | ||
| } | ||
| final Computed computed = getAnnotation(Computed.class, getter, field); | ||
| if (setter == null) { |
There was a problem hiding this comment.
The driver skips a getter without a setter, a derived getFullName() fails only here.
| return doubleQuote( | ||
| Character.toUpperCase(javaName.charAt(0)) + javaName.substring(1)); | ||
| case SNAKE_CASE_INSENSITIVE: | ||
| return toSnakeCase(javaName).toLowerCase(); |
There was a problem hiding this comment.
This needs Locale.ROOT, with a Turkish default locale userId becomes user_ıd and the mapper throws.
| } | ||
|
|
||
| /** @deprecated Use {@link #builder()} instead. */ | ||
| @Deprecated |
There was a problem hiding this comment.
These signatures change anyway, so I'd drop the deprecated constructors in 4.0 instead of porting them.
| * CQL `date`, `time` and `timestamp` are mapped to `java.time.LocalDate`, `java.time.LocalTime` and `java.time.Instant`, | ||
| see [temporal types](https://apache.github.io/cassandra-java-driver/4.19.0/core/temporal_types/). `java.util.Date` is still supported for `timestamp` columns. | ||
| Tuples read with `CassandraInputFormat` contain the `java.time` types. | ||
| * The request timeout of the driver, set by the SQL option `read-timeout`, now covers a request including its retries. |
There was a problem hiding this comment.
setHost and custom builders go from driver 3's 12 s read timeout to a 2 s request timeout, I think that belongs here too.
| - com.datastax.oss:native-protocol:1.5.2 | ||
| - com.typesafe:config:1.4.1 | ||
| - io.dropwizard.metrics:metrics-core:4.1.18 | ||
| - org.apache.cassandra:java-driver-core-shaded:4.19.4 |
There was a problem hiding this comment.
The shaded driver bundles relocated netty 4.1.138 and jackson 2.20.1, those need listing, and its BSD Protocol Buffers code needs licenses/LICENSE.protobuf.
Purpose of the change
Upgrade Cassandra Java Driver to
4.19.4, see FLINK-41444.Brief change log
ClusterBuilderis replaced byCassandraSessionBuilder (buildSession(CqlSessionBuilder)), andsetClusterBuilderbysetSessionBuilder. The SQL optioncluster-builder-classis nowsession-builder-class.@Entity/@CqlNameclasses itself at runtime, since the 4.x driver mapper only works through an annotation processor.MapperOptionsandSimpleMapperOptionsare replaced byCassandraMapperOptions.local-datacenterSQL option andCassandraSinkBuilder.setLocalDatacenter. When unset, the datacenter is inferred from the hosts, so existingsetHostjobs and SQL tables keep working.secure-connect-bundleSQL option; when set, hosts, port and local datacenter are ignored.java.util.Date: still works for timestamp columns through a codec the connector registers.content.zhpages are updated, with new sections on connecting, driver configuration, POJO mapping, cloud databases and migrating from driver 3.Things to know
CassandraInputFormatnow returnsInstant,java.time.LocalDateandLocalTimefor temporal columns, because the 3.x types no longer exist. This is in the migration section of the docs.@Entityproperty maps to a UDT, but collections of entities are rejected at startup with a clear error.Verifying this change
Ran the CI build locally;
mvn clean verifypasses on both JDK 11 and JDK 17: 135 unit tests and 41 integration tests against a 2-node Cassandra 4.1.12, plus checkstyle, spotless, RAT, enforcer, japicmp and ArchUnit.Impact and documentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Claude Fable 5.2)