Gintaras Matulas
03/25/2024, 9:11 AMBrian Koehler
03/25/2024, 4:27 PMraw data format. From there, we convert it to a datastream. Then we use a UDF to use the confluent kafka (python) library to deserialize each message. Then convert it back to the Table API if neededGintaras Matulas
03/26/2024, 8:12 AMGintaras Matulas
03/26/2024, 9:20 AMJosé Fonte
04/04/2024, 10:40 AMGintaras Matulas
04/04/2024, 12:04 PMVARCHAR or CHAR instead of defaulting for Avro string type I get it from the schema that I fetched earlierJosé Fonte
04/04/2024, 1:45 PMGintaras Matulas
04/04/2024, 2:18 PMJosé Fonte
04/04/2024, 2:53 PMJosé Fonte
04/04/2024, 8:44 PMGintaras Matulas
04/05/2024, 6:21 AMJosé Fonte
04/05/2024, 12:38 PMGintaras Matulas
04/05/2024, 1:28 PM./mvnw clean package -pl :flink-avro-confluent-registry This should be the only avro project. Then in flink-avro-confluent-registry/target you should have jars. And then depending on your deployments replace the jar in flin /lib folder or add this as dependency to your flink jobJosé Fonte
04/05/2024, 8:14 PMflink-avro-confluent-registry and then include its dependency in build.gradle. Is this a right assumption?
implementation files('libs/flink-avro-confluent-registry-1.18-SNAPSHOT.jar')Gintaras Matulas
04/08/2024, 6:17 AMJosé Fonte
04/08/2024, 8:36 AMGintaras Matulas
04/08/2024, 8:40 AMJosé Fonte
04/08/2024, 8:46 AMio.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException . Have you removed this dependencies from your fork? Doesn't look it's coming from your changes.Gintaras Matulas
04/08/2024, 8:52 AMJosé Fonte
04/08/2024, 10:00 AMCaused by: java.io.IOException: Failed to deserialize consumer record ConsumerRecord(topic = us1.service.accounting.transactions, partition = 0, leaderEpoch = 2, offset = 0, CreateTime = 1705063363304, serialized key size = 13, serialized value size = 109, headers = RecordHeaders(headers = [RecordHeader(key = x-datadog-trace-id, value = [54, 54, 51, 57, 54, 49, 54, 48, 54, 50, 56, 56, 57, 54, 55, 50, 52, 56, 49]), RecordHeader(key = x-datadog-parent-id, value = [52, 48, 50, 50, 49, 50, 51, 49, 52, 52, 52, 55, 55, 55, 55, 57, 52, 57, 50]), RecordHeader(key = x-datadog-sampling-priority, value = [49]), RecordHeader(key = x-datadog-tags, value = [95, 100, 100, 46, 112, 46, 100, 109, 61, 45, 49, 44, 95, 100, 100, 46, 112, 46, 116, 105, 100, 61, 54, 53, 97, 49, 51, 51, 99, 50, 48, 48, 48, 48, 48, 48, 48, 48]), RecordHeader(key = traceparent, value = [48, 48, 45, 54, 53, 97, 49, 51, 51, 99, 50, 48, 48, 48, 48, 48, 48, 48, 48, 53, 99, 50, 52, 97, 55, 97, 49, 56, 57, 56, 52, 51, 102, 50, 49, 45, 51, 55, 100, 49, 55, 51, 98, 48, 57, 53, 55, 57, 97, 54, 50, 52, 45, 48, 49]), RecordHeader(key = tracestate, value = [100, 100, 61, 115, 58, 49, 59, 116, 46, 100, 109, 58, 45, 49, 59, 116, 46, 116, 105, 100, 58, 54, 53, 97, 49, 51, 51, 99, 50, 48, 48, 48, 48, 48, 48, 48, 48])], isReadOnly = false), key = [B@79b10d8, value = [B@2e776055).
at org.apache.flink.connector.kafka.source.reader.deserializer.KafkaDeserializationSchemaWrapper.deserialize(KafkaDeserializationSchemaWrapper.java:57)
at org.apache.flink.connector.kafka.source.reader.KafkaRecordEmitter.emitRecord(KafkaRecordEmitter.java:53)
... 14 more
Caused by: java.io.IOException: Failed to deserialize Avro record.
at org.apache.flink.formats.avro.AvroRowDataDeserializationSchema.deserialize(AvroRowDataDeserializationSchema.java:106)
at org.apache.flink.formats.avro.AvroRowDataDeserializationSchema.deserialize(AvroRowDataDeserializationSchema.java:46)
at org.apache.flink.api.common.serialization.DeserializationSchema.deserialize(DeserializationSchema.java:82)
at org.apache.flink.streaming.connectors.kafka.table.DynamicKafkaDeserializationSchema.deserialize(DynamicKafkaDeserializationSchema.java:130)
at org.apache.flink.connector.kafka.source.reader.deserializer.KafkaDeserializationSchemaWrapper.deserialize(KafkaDeserializationSchemaWrapper.java:54)
... 15 more
Caused by: org.apache.avro.AvroTypeException: Found com.cloudbeds.AccountingService.SourceKindEnum, expecting string
at org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:308)
at org.apache.avro.io.parsing.Parser.advance(Parser.java:86)
at org.apache.avro.io.ResolvingDecoder.readString(ResolvingDecoder.java:203)
at org.apache.avro.generic.GenericDatumReader.readString(GenericDatumReader.java:470)
at org.apache.avro.generic.GenericDatumReader.readString(GenericDatumReader.java:460)
at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:192)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:161)
at org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:260)
at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:248)
at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:180)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:161)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:154)
at org.apache.flink.formats.avro.RegistryAvroDeserializationSchema.deserialize(RegistryAvroDeserializationSchema.java:81)
at org.apache.flink.formats.avro.AvroRowDataDeserializationSchema.deserialize(AvroRowDataDeserializationSchema.java:103)Gintaras Matulas
04/08/2024, 10:10 AMvalue.avro-confluent.fallback-schema = '<schema-subject>' ? When it is set when resolving string types it will use latest version of that schemaJosé Fonte
04/08/2024, 10:21 AMSchemaRegistryTableCatalog to:
public class SchemaRegistryTableCatalog extends ReadOnlyTableCatalog {
...
private Map<String, String> generateTableProperties(ObjectPath tablePath, Schema tableSchema) {
// TODO: Validate config
var schemaRegistryUrl = catalogConfig.get("schema.registry.url");
var schemaRegistryBasicAuthCredentialsSource = catalogConfig.get("schema.registry.basic.auth.credentials.source");
var schemaRegistryBasicAuthUserInfo = catalogConfig.get("schema.registry.basic.auth.user.info");
var tableProperties = catalogConfig
.entrySet()
.stream()
.filter(entry -> entry.getKey().startsWith("table."))
.map(entry -> {
var key = entry.getKey().replace("table.", "");
var value = entry.getValue();
return Map.entry(key, value);
})
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));
var schemaRegistryProperties = new HashMap<>(Map.ofEntries(
Map.entry("topic", getTableTopicName(tablePath)),
// SR Key
Map.entry("key.format", "avro-confluent"),
Map.entry("key.avro-confluent.url", schemaRegistryUrl),
Map.entry("key.avro-confluent.basic-auth.credentials-source", schemaRegistryBasicAuthCredentialsSource),
Map.entry("key.avro-confluent.basic-auth.user-info", schemaRegistryBasicAuthUserInfo),
Map.entry("value.fields-include", "EXCEPT_KEY"),
// SR Value
Map.entry("value.format", "avro-confluent"),
Map.entry("value.avro-confluent.url", schemaRegistryUrl),
Map.entry("value.avro-confluent.basic-auth.credentials-source", schemaRegistryBasicAuthCredentialsSource),
Map.entry("value.avro-confluent.basic-auth.user-info", schemaRegistryBasicAuthUserInfo)
));
...
}Gintaras Matulas
04/08/2024, 10:26 AMCREATE TABLE some_table (
the_kafka_key STRING,
some_enum STRING,
) WITH (
'connector' = 'kafka',
'topic' = 'kafka-topic',
'scan.startup.mode' = 'earliest-offset',
'scan.bounded.mode' = 'latest-offset',
'properties.bootstrap.servers' = 'bootstrap-server:9092',
'key.format' = 'raw',
'key.fields' = 'the_kafka_key',
'value.format' = 'avro-confluent',
'value.avro-confluent.url' = 'https://schema-registry.com'
'value.avro-confluent.fallback-schema' = 'schema-subject'
);José Fonte
04/08/2024, 10:45 AMvalue.avro-confluent.fallback-schema in my SQL Java migrations app that inherits that config and sets it up. I'm still not understanding what should be the value of schema-subject? Is this a generic schema?Gintaras Matulas
04/08/2024, 10:49 AMJosé Fonte
04/08/2024, 10:57 AMJosé Fonte
04/08/2024, 11:20 AMCREATE CATALOG pg WITH (
'type' = 'jdbc',
'default-database' = '${POSTGRES_NAME}',
'username' = '${POSTGRES_USER}',
'password' = '${POSTGRES_PASSWORD}',
'base-url' = 'jdbc:postgresql://postgres:${POSTGRES_PORT}'
);José Fonte
04/08/2024, 11:23 AMCREATE CATALOG sr WITH (
'type' = 'schema-registry',
'island' = '${ISLAND}',
'schema.registry.url' = '${SCHEMA_REGISTRY_URL}',
'schema.registry.basic.auth.credentials.source' = 'USER_INFO',
'schema.registry.basic.auth.user.info' = '${SCHEMA_REGISTRY_USER}:${SCHEMA_REGISTRY_PASSWORD}',
'table.connector' = 'upsert-kafka',
'table.properties.bootstrap.servers' = '${KAFKA_BROKER}',
'table.properties.security.protocol' = 'SASL_SSL',
'table.properties.sasl.mechanism' = 'PLAIN',
'table.properties.sasl.jaas.config' = 'org.apache.kafka.common.security.plain.PlainLoginModule required username="${KAFKA_SASL_USER}" password="${KAFKA_SASL_PASSWORD}";'
);José Fonte
04/08/2024, 2:53 PMGintaras Matulas
04/08/2024, 5:48 PM<topic name>-value
• Don’t forget to add this config value.avro-confluent.fallback-schema' = 'schema-subjectJosé Fonte
04/24/2024, 2:57 PM2024-04-24 15:55:26 at org.apache.flink.formats.avro.registry.confluent.RegistryAvroFormatFactory.lambda$getFallbackSchema$0(RegistryAvroFormatFactory.java:184)
2024-04-24 15:55:26 at java.base/java.util.Optional.map(Unknown Source)
2024-04-24 15:55:26 at org.apache.flink.formats.avro.registry.confluent.RegistryAvroFormatFactory.getFallbackSchema(RegistryAvroFormatFactory.java:179)
2024-04-24 15:55:26 at org.apache.flink.formats.avro.registry.confluent.RegistryAvroFormatFactory.access$000(RegistryAvroFormatFactory.java:83)
2024-04-24 15:55:26 at org.apache.flink.formats.avro.registry.confluent.RegistryAvroFormatFactory$1.createRuntimeDecoder(RegistryAvroFormatFactory.java:106)
2024-04-24 15:55:26 at org.apache.flink.formats.avro.registry.confluent.RegistryAvroFormatFactory$1.createRuntimeDecoder(RegistryAvroFormatFactory.java:97)
2024-04-24 15:55:26 at org.apache.flink.table.connector.format.ProjectableDecodingFormat.createRuntimeDecoder(ProjectableDecodingFormat.java:66)
2024-04-24 15:55:26 at org.apache.flink.streaming.connectors.kafka.table.UpsertKafkaDynamicTableFactory$DecodingFormatWrapper.createRuntimeDecoder(UpsertKafkaDynamicTableFactory.java:349)
2024-04-24 15:55:26 at org.apache.flink.streaming.connectors.kafka.table.UpsertKafkaDynamicTableFactory$DecodingFormatWrapper.createRuntimeDecoder(UpsertKafkaDynamicTableFactory.java:331)
2024-04-24 15:55:26 at org.apache.flink.streaming.connectors.kafka.table.KafkaDynamicSource.createDeserialization(KafkaDynamicSource.java:568)
2024-04-24 15:55:26 at org.apache.flink.streaming.connectors.kafka.table.KafkaDynamicSource.getScanRuntimeProvider(KafkaDynamicSource.java:244)
2024-04-24 15:55:26 at org.apache.flink.table.planner.connectors.DynamicSourceUtils.validateScanSource(DynamicSourceUtils.java:478)
2024-04-24 15:55:26 at org.apache.flink.table.planner.connectors.DynamicSourceUtils.prepareDynamicSource(DynamicSourceUtils.java:161)
2024-04-24 15:55:26 at org.apache.flink.table.planner.connectors.DynamicSourceUtils.convertSourceToRel(DynamicSourceUtils.java:125)
2024-04-24 15:55:26 at org.apache.flink.table.planner.plan.schema.CatalogSourceTable.toRel(CatalogSourceTable.java:118)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.toRel(SqlToRelConverter.java:4002)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.convertIdentifier(SqlToRelConverter.java:2872)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2432)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2346)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2291)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.convertJoin(SqlToRelConverter.java:3271)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2451)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2291)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:728)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:714)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3848)
2024-04-24 15:55:26 at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:618)José Fonte
04/29/2024, 1:45 PMJosé Fonte
05/03/2024, 8:45 AMGintaras Matulas
05/03/2024, 8:51 AMJosé Fonte
05/03/2024, 9:25 AMGintaras Matulas
05/03/2024, 9:33 AMJosé Fonte
05/03/2024, 11:10 AM[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.410 s
[INFO] Finished at: 2024-05-03T12:09:41+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:2.27.1:check (spotless-check) on project flink-avro-confluent-registry: The following files had format violations:
[ERROR] src/main/java/org/apache/flink/formats/avro/registry/confluent/RegistryAvroFormatFactory.java
[ERROR] @@ -104,7 +104,9 @@
[ERROR] ················final·RowType·rowType·=·(RowType)·producedDataType.getLogicalType();
[ERROR] ················String·fallbackSchema·=
[ERROR] ························getFallbackSchema(
[ERROR] -································schemaRegistryURL,·optionalPropertiesMap,·formatOptions.getOptional(FALLBACK_SCHEMA));
[ERROR] +································schemaRegistryURL,
[ERROR] +································optionalPropertiesMap,
[ERROR] +································formatOptions.getOptional(FALLBACK_SCHEMA));
[ERROR] ················final·Schema·schema·=
[ERROR] ························schemaString
[ERROR] ································.map(s·->·getAvroSchema(s,·rowType))
[ERROR] @@ -138,7 +140,10 @@
[ERROR] ········Map<String,·?>·optionalPropertiesMap·=·buildOptionalPropertiesMap(formatOptions);
[ERROR]
[ERROR] ········String·fallbackSchema·=
[ERROR] -················getFallbackSchema(schemaRegistryURL,·optionalPropertiesMap,·formatOptions.getOptional(FALLBACK_SCHEMA));
[ERROR] +················getFallbackSchema(
[ERROR] +························schemaRegistryURL,
[ERROR] +························optionalPropertiesMap,
[ERROR] +························formatOptions.getOptional(FALLBACK_SCHEMA));
[ERROR]
[ERROR] ········if·(!subject.isPresent())·{
[ERROR] ············throw·new·ValidationException(
[ERROR] @@ -172,7 +177,10 @@
[ERROR] ········};
[ERROR] ····}
[ERROR]
[ERROR] -····private·String·getFallbackSchema(String·schemaRegistryURL,·@Nullable·Map<String,·?>·registryConfigs,·Optional<String>·fallbackSchema)·{
[ERROR] +····private·String·getFallbackSchema(
[ERROR] +············String·schemaRegistryURL,
[ERROR] +············@Nullable·Map<String,·?>·registryConfigs,
[ERROR] +············Optional<String>·fallbackSchema)·{
[ERROR] ········CachedSchemaRegistryClient·client·=
[ERROR] ················new·CachedSchemaRegistryClient(schemaRegistryURL,·10,·registryConfigs);
[ERROR] ········return·fallbackSchema
[ERROR] Run 'mvn spotless:apply' to fix these violations.Gintaras Matulas
05/03/2024, 11:42 AMJosé Fonte
05/03/2024, 1:09 PMCaused by: org.apache.avro.AvroTypeException: Found com.cloudbeds.AccountingService.SourceKindEnum, expecting union .José Fonte
05/03/2024, 4:58 PMJosé Fonte
05/07/2024, 9:58 AM