This is an automated email from the ASF dual-hosted git repository.

FrankChen021 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 308c9499965 fix: correct JSON serialization of CloneQueryMode (#20557)
308c9499965 is described below

commit 308c9499965dbc3460acd71ec3f734f8c1502d33
Author: Frank Chen <[email protected]>
AuthorDate: Tue Oct 13 13:57:55 2026 +0800

    fix: correct JSON serialization of CloneQueryMode (#20557)
---
 .../org/apache/druid/query/CloneQueryMode.java     |  2 +
 .../org/apache/druid/query/CloneQueryModeTest.java | 49 ++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git 
a/processing/src/main/java/org/apache/druid/query/CloneQueryMode.java 
b/processing/src/main/java/org/apache/druid/query/CloneQueryMode.java
index 643c1dcb403..65b66f1d90c 100644
--- a/processing/src/main/java/org/apache/druid/query/CloneQueryMode.java
+++ b/processing/src/main/java/org/apache/druid/query/CloneQueryMode.java
@@ -20,6 +20,7 @@
 package org.apache.druid.query;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
 import org.apache.druid.error.InvalidInput;
 
 /**
@@ -60,6 +61,7 @@ public enum CloneQueryMode
     throw InvalidInput.exception("No such clone query mode[%s]", value);
   }
 
+  @JsonValue
   @Override
   public String toString()
   {
diff --git 
a/processing/src/test/java/org/apache/druid/query/CloneQueryModeTest.java 
b/processing/src/test/java/org/apache/druid/query/CloneQueryModeTest.java
new file mode 100644
index 00000000000..d5660a2f7f3
--- /dev/null
+++ b/processing/src/test/java/org/apache/druid/query/CloneQueryModeTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.druid.query;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.druid.error.DruidException;
+import org.apache.druid.jackson.DefaultObjectMapper;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class CloneQueryModeTest
+{
+  private static final ObjectMapper JSON_MAPPER = new DefaultObjectMapper();
+
+  @Test
+  public void testSerde() throws Exception
+  {
+    for (final CloneQueryMode mode : CloneQueryMode.values()) {
+      final String json = JSON_MAPPER.writeValueAsString(mode);
+      Assertions.assertEquals("\"" + mode + "\"", json);
+      Assertions.assertEquals(mode, JSON_MAPPER.readValue(json, 
CloneQueryMode.class));
+    }
+    Assertions.assertEquals("\"preferClones\"", 
JSON_MAPPER.writeValueAsString(CloneQueryMode.PREFERCLONES));
+  }
+
+  @Test
+  public void testFromStringRejectsUnknownValue()
+  {
+    Assertions.assertThrows(DruidException.class, () -> 
CloneQueryMode.fromString("unknown"));
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to