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
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void testInsertImplicitCast() throws Exception
{
String queryFile = "/catalog/implicitCast_select.sql";
String tableName = "testImplicitCast" + operationName;
TableMetadata table = TableBuilder.datasource(tableName, "P1D")
TableMetadata table = TableBuilder.datasource(tableName, "DAY")
.column(Columns.TIME_COLUMN, Columns.LONG)
.column("double_col1", "DOUBLE")
.build();
Expand Down Expand Up @@ -179,7 +179,7 @@ public void testInsertWithClusteringFromCatalog() throws Exception
{
String queryFile = "/catalog/clustering_select.sql";
String tableName = "testWithClusteringFromCatalog" + operationName;
TableMetadata table = TableBuilder.datasource(tableName, "P1D")
TableMetadata table = TableBuilder.datasource(tableName, "ALL")
.column(Columns.TIME_COLUMN, Columns.LONG)
.column("bigint_col1", "BIGINT")
.property(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.druid.java.util.common.granularity.PeriodGranularity;
import org.joda.time.Period;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import java.net.URI;
Expand Down Expand Up @@ -63,17 +64,25 @@ public static List<String> columnNames(List<ColumnSpec> columns)
* For the odd interval, the interval name is also accepted (for the other
* intervals, the interval name is the descriptive string).
*/
public static Granularity asDruidGranularity(String value)
public static Granularity asDruidGranularity(@Nonnull String value)
{
if (Strings.isNullOrEmpty(value) || value.equalsIgnoreCase(DatasourceDefn.ALL_GRANULARITY)) {
if (value.equalsIgnoreCase(DatasourceDefn.ALL_GRANULARITY)) {
return Granularities.ALL;
Comment thread
zachjsh marked this conversation as resolved.
}
Granularity granularity;
try {
return new PeriodGranularity(new Period(value), null, null);
granularity = Granularity.fromString(value);
}
catch (IllegalArgumentException e) {
throw new IAE(StringUtils.format("'%s' is an invalid period string", value));
try {
granularity = new PeriodGranularity(new Period(value), null, null);
}
catch (IllegalArgumentException e2) {
throw new IAE("[%s] is an invalid granularity string.", value);
}
}

return granularity;
}

/**
Expand Down Expand Up @@ -275,18 +284,12 @@ public static Map<String, Object> mergeProperties(
return merged;
}

public static void validateGranularity(String value)
public static void validateGranularity(final String value)
{
if (value == null) {
return;
}
Granularity granularity;
try {
granularity = new PeriodGranularity(new Period(value), null, null);
}
catch (IllegalArgumentException e) {
throw new IAE(StringUtils.format("[%s] is an invalid granularity string", value));
}
final Granularity granularity = asDruidGranularity(value);
if (!GranularityType.isStandard(granularity)) {
throw new IAE(
"Unsupported segment graularity. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.segment.column.ColumnType;

import javax.annotation.Nullable;

import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -122,6 +124,7 @@ public String segmentGranularityString()
return stringProperty(DatasourceDefn.SEGMENT_GRANULARITY_PROPERTY);
}

@Nullable
public Granularity segmentGranularity()
{
String definedGranularity = segmentGranularityString();
Expand Down