Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site2/docs/schema-evolution-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ In some data formats, for example, Avro, you can define fields with default valu

> **Tip**
>
> You can set schema compatibility check strategy at namespace or broker level. For how to set the strategy, see [here](schema-manage.md/#set-schema-compatibility-check-strategy).
> You can set schema compatibility check strategy at the topic, namespace or broker level. For how to set the strategy, see [here](schema-manage.md/#set-schema-compatibility-check-strategy).

## Schema verification

Expand Down
119 changes: 110 additions & 9 deletions site2/docs/schema-manage.md
Original file line number Diff line number Diff line change
Expand Up @@ -809,23 +809,124 @@ To use your custom schema storage implementation, perform the following steps.

## Set schema compatibility check strategy

You can set [schema compatibility check strategy](schema-evolution-compatibility.md#schema-compatibility-check-strategy) at namespace or broker level.
You can set [schema compatibility check strategy](schema-evolution-compatibility.md#schema-compatibility-check-strategy) at the topic, namespace or broker level.

- If you set schema compatibility check strategy at both namespace or broker level, it uses the strategy set for the namespace level.
The schema compatibility check strategy set at different levels has priority: topic level > namespace level > broker level.

- If you do not set schema compatibility check strategy at both namespace or broker level, it uses the `FULL` strategy.
- If you set the strategy at both topic and namespace level, it uses the topic-level strategy.

- If you set schema compatibility check strategy at broker level rather than namespace level, it uses the strategy set for the broker level.
- If you set the strategy at both namespace and broker level, it uses the namespace-level strategy.

- If you set schema compatibility check strategy at namespace level rather than broker level, it uses the strategy set for the namespace level.
- If you do not set the strategy at any level, it uses the `FULL` strategy. For all available values, see [here](schema-evolution-compatibility.md#schema-compatibility-check-strategy).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a description that available values for schema compatibility strategy?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I will add a link as the reference for available values. Thank you.

### Namespace

### Topic level

To set a schema compatibility check strategy at the topic level, use one of the following methods.

<!--DOCUSAURUS_CODE_TABS-->

<!--Admin CLI-->

Use the [`pulsar-admin topics set-schema-compatibility-strategy`](https://pulsar.apache.org/tools/pulsar-admin/) command.

```shell
pulsar-admin topics set-schema-compatibility-strategy <strategy> <topicName>
```
<!--REST API-->

Send a `PUT` request to this endpoint: {@inject: endpoint|PUT|/admin/v2/topics/:tenant/:namespace/:topic|operation/schemaCompatibilityStrategy?version=[[pulsar:version_number]]}

<!--Java Admin API-->

```java
void setSchemaCompatibilityStrategy(String topic, SchemaCompatibilityStrategy strategy)
```

Here is an example of setting a schema compatibility check strategy at the topic level.

```java
PulsarAdmin admin = …;

admin.topicPolicies().setSchemaCompatibilityStrategy("my-tenant/my-ns/my-topic", SchemaCompatibilityStrategy.ALWAYS_INCOMPATIBLE);
```

<!--END_DOCUSAURUS_CODE_TABS-->
<br />
To get the topic-level schema compatibility check strategy, use one of the following methods.

<!--DOCUSAURUS_CODE_TABS-->

<!--Admin CLI-->

Use the [`pulsar-admin topics get-schema-compatibility-strategy`](https://pulsar.apache.org/tools/pulsar-admin/) command.

```shell
pulsar-admin topics get-schema-compatibility-strategy <topicName>
```
<!--REST API-->

Send a `GET` request to this endpoint: {@inject: endpoint|GET|/admin/v2/topics/:tenant/:namespace/:topic|operation/schemaCompatibilityStrategy?version=[[pulsar:version_number]]}

<!--Java Admin API-->

```java
SchemaCompatibilityStrategy getSchemaCompatibilityStrategy(String topic, boolean applied)
```

Here is an example of getting the topic-level schema compatibility check strategy.

```java
PulsarAdmin admin = …;

// get the current applied schema compatibility strategy
admin.topicPolicies().getSchemaCompatibilityStrategy("my-tenant/my-ns/my-topic", true);

// only get the schema compatibility strategy from topic policies
admin.topicPolicies().getSchemaCompatibilityStrategy("my-tenant/my-ns/my-topic", false);
```

<!--END_DOCUSAURUS_CODE_TABS-->
<br />
To remove the topic-level schema compatibility check strategy, use one of the following methods.

<!--DOCUSAURUS_CODE_TABS-->

<!--Admin CLI-->

Use the [`pulsar-admin topics remove-schema-compatibility-strategy`](https://pulsar.apache.org/tools/pulsar-admin/) command.

```shell
pulsar-admin topics remove-schema-compatibility-strategy <topicName>
```
<!--REST API-->

Send a `DELETE` request to this endpoint: {@inject: endpoint|DELETE|/admin/v2/topics/:tenant/:namespace/:topic|operation/schemaCompatibilityStrategy?version=[[pulsar:version_number]]}

<!--Java Admin API-->

```java
void removeSchemaCompatibilityStrategy(String topic)
```

Here is an example of removing the topic-level schema compatibility check strategy.

```java
PulsarAdmin admin = …;

admin.removeSchemaCompatibilityStrategy("my-tenant/my-ns/my-topic");
```

<!--END_DOCUSAURUS_CODE_TABS-->


### Namespace level

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep the DOCUSAURUS_CODE_TABS tab has same style between Topice level and Namespace level.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep the DOCUSAURUS_CODE_TABS tab has same style between Topice level and Namespace level.

Do you mean by using the same tab name, like Admin CLI?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected. PTAL. Thanks.


You can set schema compatibility check strategy at namespace level using one of the following methods.

<!--DOCUSAURUS_CODE_TABS-->

<!--pulsar-admin-->
<!--Admin CLI-->

Use the [`pulsar-admin namespaces set-schema-compatibility-strategy`](https://pulsar.apache.org/tools/pulsar-admin/) command.

Expand All @@ -836,7 +937,7 @@ pulsar-admin namespaces set-schema-compatibility-strategy options

Send a `PUT` request to this endpoint: {@inject: endpoint|PUT|/admin/v2/namespaces/:tenant/:namespace|operation/schemaCompatibilityStrategy?version=[[pulsar:version_number]]}

<!--Java-->
<!--Java Admin CLI-->

Use the [`setSchemaCompatibilityStrategy`](https://pulsar.apache.org/api/admin/)method.

Expand All @@ -846,7 +947,7 @@ admin.namespaces().setSchemaCompatibilityStrategy("test", SchemaCompatibilityStr

<!--END_DOCUSAURUS_CODE_TABS-->

### Broker
### Broker level

You can set schema compatibility check strategy at broker level by setting `schemaCompatibilityStrategy` in [`broker.conf`](https://github.com/apache/pulsar/blob/f24b4890c278f72a67fe30e7bf22dc36d71aac6a/conf/broker.conf#L1240) or [`standalone.conf`](https://github.com/apache/pulsar/blob/master/conf/standalone.conf) file.

Expand Down