use of org.apache.lucene.util.BytesRef in project crate by crate.
the class RefreshAnalyzerTest method testRefreshPartition.
@Test
public void testRefreshPartition() throws Exception {
PartitionName partition = new PartitionName("parted", Arrays.asList(new BytesRef("1395874800000")));
RefreshTableAnalyzedStatement analysis = e.analyze("refresh table parted PARTITION (date=1395874800000)");
assertThat(analysis.indexNames(), contains(".partitioned.parted.04732cpp6ks3ed1o60o30c1g"));
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class SnapshotRestoreAnalyzerTest method testRestoreSinglePartition.
@Test
public void testRestoreSinglePartition() throws Exception {
RestoreSnapshotAnalyzedStatement statement = analyze("RESTORE SNAPSHOT my_repo.my_snapshot TABLE parted PARTITION (date=123)");
PartitionName partition = new PartitionName("parted", ImmutableList.of(new BytesRef("123")));
assertThat(statement.restoreTables().size(), is(1));
assertThat(statement.restoreTables().get(0).partitionName(), is(partition));
assertThat(statement.restoreTables().get(0).tableIdent(), is(new TableIdent(null, "parted")));
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class SnapshotRestoreAnalyzerTest method testRestoreSinglePartitionToUnknownTable.
@Test
public void testRestoreSinglePartitionToUnknownTable() throws Exception {
RestoreSnapshotAnalyzedStatement statement = analyze("RESTORE SNAPSHOT my_repo.my_snapshot TABLE unknown_parted PARTITION (date=123)");
PartitionName partitionName = new PartitionName("unknown_parted", ImmutableList.of(new BytesRef("123")));
assertThat(statement.restoreTables().size(), is(1));
assertThat(statement.restoreTables().get(0).partitionName(), is(partitionName));
assertThat(statement.restoreTables().get(0).tableIdent(), is(new TableIdent(null, "unknown_parted")));
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class CompoundLiteralTest method testObjectConstruction.
@SuppressWarnings("ConstantConditions")
@Test
public void testObjectConstruction() throws Exception {
Symbol s = expressions.asSymbol("{}");
assertThat(s, instanceOf(Literal.class));
Literal l = (Literal) s;
assertThat(l.value(), is((Object) new HashMap<String, Object>()));
Literal objectLiteral = (Literal) expressions.normalize(expressions.asSymbol("{ident='value'}"));
assertThat(objectLiteral.symbolType(), is(SymbolType.LITERAL));
assertThat(objectLiteral.valueType(), is((DataType) ObjectType.INSTANCE));
assertThat(objectLiteral.value(), is((Object) new MapBuilder<String, Object>().put("ident", new BytesRef("value")).map()));
Literal multipleObjectLiteral = (Literal) expressions.normalize(expressions.asSymbol("{\"Ident\"=123.4, a={}, ident='string'}"));
Map<String, Object> values = (Map<String, Object>) multipleObjectLiteral.value();
assertThat(values, is(new MapBuilder<String, Object>().put("Ident", 123.4d).put("a", new HashMap<String, Object>()).put("ident", new BytesRef("string")).map()));
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class CompoundLiteralTest method testObjectConstructionWithExpressionsAsValues.
@Test
public void testObjectConstructionWithExpressionsAsValues() throws Exception {
Literal objectLiteral = (Literal) expressions.normalize(expressions.asSymbol("{name = 1 + 2}"));
assertThat(objectLiteral.symbolType(), is(SymbolType.LITERAL));
assertThat(objectLiteral.value(), is(new MapBuilder<String, Object>().put("name", 3L).map()));
Literal nestedObjectLiteral = (Literal) expressions.normalize(expressions.asSymbol("{a = {name = concat('foo', 'bar')}}"));
@SuppressWarnings("unchecked") Map<String, Object> values = (Map<String, Object>) nestedObjectLiteral.value();
assertThat(values, is(new MapBuilder<String, Object>().put("a", new HashMap<String, Object>() {
{
put("name", new BytesRef("foobar"));
}
}).map()));
}
Aggregations