From 0b0648266c6c3741e787e17d0c390a19ff4dc4cc Mon Sep 17 00:00:00 2001 From: Yuval Oren Date: Thu, 6 Mar 2014 15:28:20 -0800 Subject: [PATCH] Fix DataSource serialization --- .../main/java/io/druid/query/DataSource.java | 2 +- .../java/io/druid/query/LegacyDataSource.java | 33 +++++++++++++++++++ .../java/io/druid/query/TableDataSource.java | 4 +-- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 processing/src/main/java/io/druid/query/LegacyDataSource.java diff --git a/processing/src/main/java/io/druid/query/DataSource.java b/processing/src/main/java/io/druid/query/DataSource.java index 6fa7bff24c5..2560f2b418c 100644 --- a/processing/src/main/java/io/druid/query/DataSource.java +++ b/processing/src/main/java/io/druid/query/DataSource.java @@ -27,7 +27,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", - defaultImpl = TableDataSource.class) + defaultImpl = LegacyDataSource.class) @JsonSubTypes({ @JsonSubTypes.Type(value = TableDataSource.class, name = "table"), @JsonSubTypes.Type(value = QueryDataSource.class, name = "query") diff --git a/processing/src/main/java/io/druid/query/LegacyDataSource.java b/processing/src/main/java/io/druid/query/LegacyDataSource.java new file mode 100644 index 00000000000..93636238d87 --- /dev/null +++ b/processing/src/main/java/io/druid/query/LegacyDataSource.java @@ -0,0 +1,33 @@ +/* + * Druid - a distributed column store. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * This file Copyright (C) 2014 N3TWORK, Inc. and contributed to the Druid project + * under the Druid Corporate Contributor License Agreement. + */ +package io.druid.query; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class LegacyDataSource extends TableDataSource +{ + @JsonCreator + public LegacyDataSource(String name) + { + super(name); + } +} diff --git a/processing/src/main/java/io/druid/query/TableDataSource.java b/processing/src/main/java/io/druid/query/TableDataSource.java index af8400b3836..79fed0e0721 100644 --- a/processing/src/main/java/io/druid/query/TableDataSource.java +++ b/processing/src/main/java/io/druid/query/TableDataSource.java @@ -31,7 +31,7 @@ public class TableDataSource implements DataSource @JsonCreator public TableDataSource(@JsonProperty("name") String name) { - this.name = name.toLowerCase(); + this.name = (name == null ? null : name.toLowerCase()); } public String getName() @@ -45,7 +45,7 @@ public class TableDataSource implements DataSource public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (!(o instanceof TableDataSource)) return false; TableDataSource that = (TableDataSource) o;