use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class RowShardResolverTest method testMultiPrimaryKeyNullException.
@Test
public void testMultiPrimaryKeyNullException() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("A primary key value must not be NULL");
List<Symbol> primaryKeySymbols = List.of(new InputColumn(1), new InputColumn(0));
RowShardResolver rowShardResolver = new RowShardResolver(txnCtx, nodeCtx, List.of(ci("id"), ci("foo")), primaryKeySymbols, null, new InputColumn(1));
rowShardResolver.setNextRow(row(1, null));
}
use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class RowShardResolverTest method testMultipleRows.
@Test
public void testMultipleRows() {
List<Symbol> primaryKeySymbols = List.of(new InputColumn(0), new InputColumn(1));
RowShardResolver rowShardResolver = new RowShardResolver(txnCtx, nodeCtx, List.of(ci("id"), ci("foo")), primaryKeySymbols, ci("foo"), new InputColumn(1));
rowShardResolver.setNextRow(row(1, "hoschi"));
assertThat(rowShardResolver.id(), is("AgZob3NjaGkBMQ=="));
assertThat(rowShardResolver.routing(), is("hoschi"));
rowShardResolver.setNextRow(row(2, "galoschi"));
assertThat(rowShardResolver.id(), is("AghnYWxvc2NoaQEy"));
assertThat(rowShardResolver.routing(), is("galoschi"));
}
use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class RowShardResolverTest method testPrimaryKeyNullException.
@Test
public void testPrimaryKeyNullException() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("A primary key value must not be NULL");
List<Symbol> primaryKeySymbols = List.of(new InputColumn(0));
RowShardResolver rowShardResolver = new RowShardResolver(txnCtx, nodeCtx, List.of(ci("id")), primaryKeySymbols, null, null);
rowShardResolver.setNextRow(row(new Object[] { null }));
}
use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class RowShardResolverTest method testPrimaryKeyNoRouting.
@Test
public void testPrimaryKeyNoRouting() {
List<Symbol> primaryKeySymbols = List.of(new InputColumn(0), new InputColumn(1));
RowShardResolver rowShardResolver = new RowShardResolver(txnCtx, nodeCtx, List.of(ci("id"), ci("foo")), primaryKeySymbols, null, null);
rowShardResolver.setNextRow(row(1, "hoschi"));
// compound encoded id, no special routing
assertThat(rowShardResolver.id(), is("AgExBmhvc2NoaQ=="));
assertNull(rowShardResolver.routing());
}
use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class ColumnIndexWriterProjectionTest method testTargetColumnRefsAndSymbolsAreCorrectAfterExclusionOfPartitionColumns.
@Test
public void testTargetColumnRefsAndSymbolsAreCorrectAfterExclusionOfPartitionColumns() {
/*
* pk: [ymd, domain, area, isp]
* partitioned by: [ymd, isp]
* insert into t (ymd, domain, area, isp, h) select ...
*
* We don't write PartitionedBy columns, so they're excluded from the allTargetColumns:
*
* expected targetRefs: [ domain, area, h ]
* expected column symbols: [ ic1, ic2, ic4 ]
*/
ColumnIdent ymd = new ColumnIdent("ymd");
ColumnIdent domain = new ColumnIdent("domain");
ColumnIdent area = new ColumnIdent("area");
ColumnIdent isp = new ColumnIdent("isp");
ColumnIdent h = new ColumnIdent("h");
Reference ymdRef = partitionRef(ymd, DataTypes.STRING);
Reference domainRef = ref(domain, DataTypes.STRING);
Reference areaRef = ref(area, DataTypes.STRING);
Reference ispRef = partitionRef(isp, DataTypes.STRING);
Reference hRef = ref(h, DataTypes.INTEGER);
List<ColumnIdent> primaryKeys = Arrays.asList(ymd, domain, area, isp);
List<Reference> targetColumns = Arrays.asList(ymdRef, domainRef, areaRef, ispRef, hRef);
List<Reference> targetColumnsExclPartitionColumns = Arrays.asList(domainRef, areaRef, hRef);
InputColumns.SourceSymbols targetColsCtx = new InputColumns.SourceSymbols(targetColumns);
List<Symbol> primaryKeySymbols = InputColumns.create(Arrays.asList(ymdRef, domainRef, areaRef, ispRef), targetColsCtx);
List<Symbol> partitionedBySymbols = InputColumns.create(Arrays.asList(ymdRef, ispRef), targetColsCtx);
List<Symbol> columnSymbols = InputColumns.create(targetColumnsExclPartitionColumns, targetColsCtx);
ColumnIndexWriterProjection projection = new ColumnIndexWriterProjection(relationName, null, primaryKeys, targetColumns, targetColumnsExclPartitionColumns, columnSymbols, false, null, primaryKeySymbols, partitionedBySymbols, null, null, Settings.EMPTY, true, List.of(), null);
assertThat(projection.columnReferencesExclPartition(), is(Arrays.asList(domainRef, areaRef, hRef)));
assertThat(projection.columnSymbolsExclPartition(), is(Arrays.asList(new InputColumn(1, DataTypes.STRING), new InputColumn(2, DataTypes.STRING), new InputColumn(4, DataTypes.INTEGER))));
}
Aggregations