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 @@ -239,6 +239,9 @@ public static void validateDefaultValue(Type type, String defaultValue) throws A
break;
case BITMAP:
break;
case BOOLEAN:
BoolLiteral boolLiteral = new BoolLiteral(defaultValue);
break;
default:
throw new AnalysisException("Unsupported type: " + type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public static Set<String> analyzeBloomFilterColumns(Map<String, String> properti
// tinyint/float/double columns don't support
// key columns and none/replace aggregate non-key columns support
if (type == PrimitiveType.TINYINT || type == PrimitiveType.FLOAT
|| type == PrimitiveType.DOUBLE) {
|| type == PrimitiveType.DOUBLE || type == PrimitiveType.BOOLEAN) {
throw new AnalysisException(type + " is not supported in bloom filter index. "
+ "invalid column: " + bfColumn);
} else if (column.isKey()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ public class ColumnDefTest {
private TypeDef intCol;
private TypeDef stringCol;
private TypeDef floatCol;
private TypeDef booleanCol;

@Before
public void setUp() {
intCol = new TypeDef(ScalarType.createType(PrimitiveType.INT));
stringCol = new TypeDef(ScalarType.createChar(10));
floatCol = new TypeDef(ScalarType.createType(PrimitiveType.FLOAT));
booleanCol = new TypeDef(ScalarType.createType(PrimitiveType.BOOLEAN));

}

@Test
Expand Down Expand Up @@ -96,4 +99,23 @@ public void testStrSum() throws AnalysisException {
column.analyze(true);
}

@Test
public void testBooleanDefaultValue() throws AnalysisException{
ColumnDef column1 = new ColumnDef("col", booleanCol, true, null, true, new DefaultValue(true, "1"), "");
column1.analyze(true);
Assert.assertEquals("1", column1.getDefaultValue());

ColumnDef column2 = new ColumnDef("col", booleanCol, true, null, true, new DefaultValue(true, "true"), "");
column2.analyze(true);
Assert.assertEquals("true", column2.getDefaultValue());

ColumnDef column3 = new ColumnDef("col", booleanCol, true, null, true, new DefaultValue(true, "10"), "");
try {
column3.analyze(true);
} catch (AnalysisException e) {
Assert.assertEquals("errCode = 2, detailMessage = Invalid BOOLEAN literal: 10", e.getMessage());
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testBfColumns() throws AnalysisException {
List<Column> columns = Lists.newArrayList();
columns.add(new Column("k1", PrimitiveType.INT));
columns.add(new Column("k2", PrimitiveType.TINYINT));
columns.add(new Column("v1",
columns.add(new Column("v1",
ScalarType.createType(PrimitiveType.VARCHAR), false, AggregateType.REPLACE, "", ""));
columns.add(new Column("v2",
ScalarType.createType(PrimitiveType.BIGINT), false, AggregateType.SUM, "0", ""));
Expand All @@ -66,7 +66,8 @@ public void testBfColumnsError() {
List<Column> columns = Lists.newArrayList();
columns.add(new Column("k1", PrimitiveType.INT));
columns.add(new Column("k2", PrimitiveType.TINYINT));
columns.add(new Column("v1",
columns.add(new Column("k3", PrimitiveType.BOOLEAN));
columns.add(new Column("v1",
ScalarType.createType(PrimitiveType.VARCHAR), false, AggregateType.REPLACE, "", ""));
columns.add(new Column("v2", ScalarType.createType(PrimitiveType.BIGINT), false, AggregateType.SUM, "0", ""));
columns.get(0).setIsKey(true);
Expand All @@ -82,8 +83,8 @@ public void testBfColumnsError() {
Assert.fail();
}

// k3 not exist
properties.put(PropertyAnalyzer.PROPERTIES_BF_COLUMNS, "k3");
// k4 not exist
properties.put(PropertyAnalyzer.PROPERTIES_BF_COLUMNS, "k4");
try {
PropertyAnalyzer.analyzeBloomFilterColumns(properties, columns);
} catch (AnalysisException e) {
Expand All @@ -98,6 +99,14 @@ public void testBfColumnsError() {
Assert.assertTrue(e.getMessage().contains("TINYINT is not supported"));
}

// bool not supported
properties.put(PropertyAnalyzer.PROPERTIES_BF_COLUMNS, "k3");
try {
PropertyAnalyzer.analyzeBloomFilterColumns(properties, columns);
} catch (AnalysisException e) {
Assert.assertTrue(e.getMessage().contains("BOOLEAN is not supported"));
}

// not replace value
properties.put(PropertyAnalyzer.PROPERTIES_BF_COLUMNS, "v2");
try {
Expand Down