Skip to content

Commit

Permalink
Ensure that boolean partition columns are boxed (#4547)
Browse files Browse the repository at this point in the history
Fixes #4545
  • Loading branch information
niloc132 authored Sep 27, 2023
1 parent bd60e3e commit 2b1ff94
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,15 @@ public static Table readPartitionedTableInferSchema(
throw new IllegalArgumentException("First location key " + firstKey
+ " has null partition value at partition key " + partitionKey);
}
allColumns.add(ColumnDefinition.fromGenericType(partitionKey,
getUnboxedTypeIfBoxed(partitionValue.getClass()), null, ColumnDefinition.ColumnType.Partitioning));

// Primitives should be unboxed, except booleans
Class<?> dataType = partitionValue.getClass();
if (dataType != Boolean.class) {
dataType = getUnboxedTypeIfBoxed(partitionValue.getClass());
}

allColumns.add(ColumnDefinition.fromGenericType(partitionKey, dataType, null,
ColumnDefinition.ColumnType.Partitioning));
}
allColumns.addAll(schemaInfo.getFirst());
return readPartitionedTable(readInstructions.isRefreshing() ? locationKeyFinder : initialKeys,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.deephaven.engine.table.TableDefinition;
import io.deephaven.engine.table.impl.DataAccessHelpers;
import io.deephaven.engine.table.impl.InMemoryTable;
import io.deephaven.engine.table.impl.UncoalescedTable;
import io.deephaven.engine.table.impl.locations.TableDataException;
import io.deephaven.engine.testutil.junit4.EngineCleanup;
import io.deephaven.engine.util.TableTools;
Expand Down Expand Up @@ -355,6 +356,19 @@ public void testPartitionedRead() {
assertTableEquals(expected, result);
}

@Test
public void testBooleanPartition() {
ParquetTools.writeTable(table1, new File(testRootFile, "Active=true" + File.separator + "file1.parquet"));
ParquetTools.writeTable(table1, new File(testRootFile, "Active=false" + File.separator + "file2.parquet"));
Table table = ParquetTools.readTable(testRootFile);
Assert.assertTrue(table instanceof UncoalescedTable);
final Table expected = TableTools.merge(
table1.updateView("Active=false"),
table1.updateView("Active=true")).moveColumnsUp("Active");

assertTableEquals(expected, table);
}

@Test
public void testBigArrays() {
ExecutionContext.getContext().getQueryLibrary().importClass(LongVectorDirect.class);
Expand Down

0 comments on commit 2b1ff94

Please sign in to comment.