use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class SourceIndexWriterProjectionSerializationTest method testSerializationFailFast.
@Test
public void testSerializationFailFast() throws IOException {
RelationName relationName = new RelationName("doc", "test");
ReferenceIdent referenceIdent = new ReferenceIdent(relationName, "object_column");
Reference reference = new Reference(referenceIdent, RowGranularity.DOC, new ArrayType<>(DataTypes.UNTYPED_OBJECT), ColumnPolicy.STRICT, Reference.IndexType.FULLTEXT, false, true, 0, Literal.of(Map.of("f", 10)));
String partitionIdent = "pIdent";
InputColumn inputColumn = new InputColumn(123);
List<ColumnIdent> primaryKeys = List.of(new ColumnIdent("colIdent"));
List<Symbol> partitionedBySymbols = List.of(reference);
ColumnIdent clusteredByColumn = new ColumnIdent("col1");
Settings settings = Settings.builder().put("fail_fast", true).build();
// fail_fast property set to true
SourceIndexWriterProjection expected = new SourceIndexWriterProjection(relationName, partitionIdent, reference, inputColumn, primaryKeys, partitionedBySymbols, clusteredByColumn, settings, null, null, List.of(), null, AbstractIndexWriterProjection.OUTPUTS, false);
BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(Version.V_4_6_0);
expected.writeTo(out);
StreamInput in = out.bytes().streamInput();
in.setVersion(Version.V_4_6_0);
assertThat(new SourceIndexWriterProjection(in).failFast(), is((!expected.failFast())));
BytesStreamOutput out2 = new BytesStreamOutput();
out2.setVersion(Version.V_4_7_0);
expected.writeTo(out2);
StreamInput in2 = out2.bytes().streamInput();
in2.setVersion(Version.V_4_7_0);
assertThat(new SourceIndexWriterProjection(in2).failFast(), is((expected.failFast())));
}
use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class LuceneReferenceResolverTest method testGetImplementationForPrimaryTerm.
@Test
public void testGetImplementationForPrimaryTerm() {
Reference primaryTerm = new Reference(new ReferenceIdent(name, "_primary_term"), RowGranularity.DOC, DataTypes.LONG, 0, null);
assertThat(luceneReferenceResolver.getImplementation(primaryTerm), instanceOf(PrimaryTermCollectorExpression.class));
}
use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class DocTableInfoTest method testGetColumnInfo.
@Test
public void testGetColumnInfo() throws Exception {
RelationName relationName = new RelationName(Schemas.DOC_SCHEMA_NAME, "dummy");
DocTableInfo info = new DocTableInfo(relationName, List.of(new Reference(new ReferenceIdent(relationName, new ColumnIdent("o", List.of())), RowGranularity.DOC, DataTypes.UNTYPED_OBJECT, 1, null)), List.of(), List.of(), List.of(), Map.of(), Map.of(), Map.of(), List.of(), List.of(), null, true, new String[0], new String[0], new IndexNameExpressionResolver(), 5, "0", Settings.EMPTY, List.of(), List.of(), ColumnPolicy.DYNAMIC, Version.CURRENT, null, false, Operation.ALL);
final ColumnIdent col = new ColumnIdent("o", List.of("foobar"));
Reference foobar = info.getReference(col);
assertNull(foobar);
// forWrite: false, errorOnUnknownObjectKey: true, parentPolicy: dynamic
DynamicReference reference = info.getDynamic(col, false, true);
assertNull(reference);
// forWrite: true, errorOnUnknownObjectKey: true, parentPolicy: dynamic
reference = info.getDynamic(col, true, true);
assertNotNull(reference);
assertSame(reference.valueType(), DataTypes.UNDEFINED);
// forWrite: true, errorOnUnknownObjectKey: false, parentPolicy: dynamic
reference = info.getDynamic(col, true, false);
assertNotNull(reference);
assertSame(reference.valueType(), DataTypes.UNDEFINED);
// forWrite: false, errorOnUnknownObjectKey: false, parentPolicy: dynamic
reference = info.getDynamic(col, false, false);
assertNotNull(reference);
assertTrue(reference instanceof VoidReference);
assertSame(reference.valueType(), DataTypes.UNDEFINED);
}
use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class DocTableInfoTest method testGetColumnInfoStrictParent.
@Test
public void testGetColumnInfoStrictParent() throws Exception {
RelationName dummy = new RelationName(Schemas.DOC_SCHEMA_NAME, "dummy");
ReferenceIdent foobarIdent = new ReferenceIdent(dummy, new ColumnIdent("foobar"));
Reference strictParent = new Reference(foobarIdent, RowGranularity.DOC, DataTypes.UNTYPED_OBJECT, ColumnPolicy.STRICT, Reference.IndexType.PLAIN, true, false, 1, null);
Map<ColumnIdent, Reference> references = Map.of(new ColumnIdent("foobar"), strictParent);
DocTableInfo info = new DocTableInfo(dummy, List.of(strictParent), List.of(), List.of(), List.of(), Map.of(), references, Map.of(), List.of(), List.of(), null, true, new String[0], new String[0], new IndexNameExpressionResolver(), 5, "0", Settings.EMPTY, List.of(), List.of(), ColumnPolicy.DYNAMIC, Version.CURRENT, null, false, Operation.ALL);
final ColumnIdent columnIdent = new ColumnIdent("foobar", Arrays.asList("foo", "bar"));
assertNull(info.getReference(columnIdent));
// forWrite: false, errorOnUnknownObjectKey: true, parentPolicy: strict
assertNull(info.getDynamic(columnIdent, false, true));
// forWrite: true, errorOnUnknownObjectKey: true, parentPolicy: strict
Asserts.assertThrowsMatches(() -> info.getDynamic(columnIdent, true, true), ColumnUnknownException.class, "Column foobar['foo']['bar'] unknown");
// forWrite: false, errorOnUnknownObjectKey: false, parentPolicy: strict
assertNull(info.getDynamic(columnIdent, false, false));
// forWrite: true, errorOnUnknownObjectKey: false, parentPolicy: strict
Asserts.assertThrowsMatches(() -> assertNull(info.getDynamic(columnIdent, true, false)), ColumnUnknownException.class, "Column foobar['foo']['bar'] unknown");
final ColumnIdent columnIdent2 = new ColumnIdent("foobar", Collections.singletonList("foo"));
assertNull(info.getReference(columnIdent2));
// forWrite: false, errorOnUnknownObjectKey: true, parentPolicy: strict
assertNull(info.getDynamic(columnIdent2, false, true));
// forWrite: true, errorOnUnknownObjectKey: true, parentPolicy: strict
Asserts.assertThrowsMatches(() -> assertNull(info.getDynamic(columnIdent2, true, true)), ColumnUnknownException.class, "Column foobar['foo'] unknown");
// forWrite: false, errorOnUnknownObjectKey: false, parentPolicy: strict
assertNull(info.getDynamic(columnIdent2, false, false));
// forWrite: true, errorOnUnknownObjectKey: false, parentPolicy: strict
Asserts.assertThrowsMatches(() -> assertNull(info.getDynamic(columnIdent2, true, false)), ColumnUnknownException.class, "Column foobar['foo'] unknown");
Reference colInfo = info.getReference(new ColumnIdent("foobar"));
assertNotNull(colInfo);
}
Aggregations