Skip to content

Commit

Permalink
log.warn on invalid nested column format version instead of failure
Browse files Browse the repository at this point in the history
  • Loading branch information
clintropolis committed Jan 23, 2025
1 parent f87324d commit 0a1bab4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.druid.data.input.impl.DimensionSchema;
import org.apache.druid.error.DruidException;
import org.apache.druid.java.util.common.logger.Logger;

import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Objects;

public class DefaultColumnFormatConfig
{
private static final Logger LOG = new Logger(DefaultColumnFormatConfig.class);

public static void validateNestedFormatVersion(@Nullable Integer formatVersion)
{
if (formatVersion != null) {
if (formatVersion != 5) {
throw DruidException.forPersona(DruidException.Persona.USER)
.ofCategory(DruidException.Category.INVALID_INPUT)
.build("Unsupported nested column format version[%s]", formatVersion);
LOG.warn("Unsupported nested column format version[%s], using default version instead", formatVersion);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.error.DruidException;
import org.apache.druid.jackson.DefaultObjectMapper;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -56,25 +55,4 @@ public void testSerdeDefault() throws JsonProcessingException
NestedDataColumnSchema andBack = MAPPER.readValue(there, NestedDataColumnSchema.class);
Assert.assertEquals(new NestedDataColumnSchema("test", 5), andBack);
}

@Test
public void testSerdeOverride() throws JsonProcessingException
{
Throwable t = Assert.assertThrows(DruidException.class, () -> new NestedDataColumnSchema("test", 4));
Assert.assertEquals("Unsupported nested column format version[4]", t.getMessage());
}

@Test
public void testVersionTooSmall()
{
Throwable t = Assert.assertThrows(DruidException.class, () -> new NestedDataColumnSchema("test", 3));
Assert.assertEquals("Unsupported nested column format version[3]", t.getMessage());
}

@Test
public void testVersionTooBig()
{
Throwable t = Assert.assertThrows(DruidException.class, () -> new NestedDataColumnSchema("test", 6));
Assert.assertEquals("Unsupported nested column format version[6]", t.getMessage());
}
}

0 comments on commit 0a1bab4

Please sign in to comment.