albert597 commented on code in PR #25410: URL: https://github.com/apache/flink/pull/25410#discussion_r2157728818
########## flink-formats/flink-avro-confluent-registry/src/main/java/org/apache/flink/formats/avro/registry/confluent/ConfluentSchemaRegistryCoder.java: ########## @@ -81,13 +100,29 @@ public Schema readSchema(InputStream in) throws IOException { @Override public void writeSchema(Schema schema, OutputStream out) throws IOException { - try { - int registeredId = schemaRegistryClient.register(subject, schema); - out.write(CONFLUENT_MAGIC_BYTE); - byte[] schemaIdBytes = ByteBuffer.allocate(4).putInt(registeredId).array(); - out.write(schemaIdBytes); - } catch (RestClientException e) { - throw new IOException("Could not register schema in registry", e); + int registeredId; + if (registerSchema()) { + try { + registeredId = schemaRegistryClient.register(subject, schema); + } catch (RestClientException e) { + throw new IOException("Could not register schema in registry", e); + } + } else { + try { + registeredId = schemaRegistryClient.getId(subject, schema); Review Comment: We're using flink sql, and the generated avro namespace doesnt match the one we've pre-registered. This `getId(subject, schema)` would still fail because it has the wrong namespace. Could we do something like this to fix it? ``` registeredId = schemaRegistryClient.getLatestSchemaMetadata(subject).getId(); ``` -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org