Search in sources :

Example 6 with DynamicReference

use of io.crate.expression.symbol.DynamicReference 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);
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) VoidReference(io.crate.expression.symbol.VoidReference) Reference(io.crate.metadata.Reference) DynamicReference(io.crate.expression.symbol.DynamicReference) VoidReference(io.crate.expression.symbol.VoidReference) DynamicReference(io.crate.expression.symbol.DynamicReference) RelationName(io.crate.metadata.RelationName) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) ReferenceIdent(io.crate.metadata.ReferenceIdent) Test(org.junit.Test)

Aggregations

DynamicReference (io.crate.expression.symbol.DynamicReference)6 Reference (io.crate.metadata.Reference)6 ColumnIdent (io.crate.metadata.ColumnIdent)5 ReferenceIdent (io.crate.metadata.ReferenceIdent)4 ColumnUnknownException (io.crate.exceptions.ColumnUnknownException)3 VoidReference (io.crate.expression.symbol.VoidReference)3 Test (org.junit.Test)3 GeneratedReference (io.crate.metadata.GeneratedReference)2 RelationName (io.crate.metadata.RelationName)2 ColumnValidationException (io.crate.exceptions.ColumnValidationException)1 FetchReference (io.crate.expression.symbol.FetchReference)1 IndexReference (io.crate.metadata.IndexReference)1 DocTableInfo (io.crate.metadata.doc.DocTableInfo)1 CheckConstraint (io.crate.sql.tree.CheckConstraint)1 ColumnPolicy (io.crate.sql.tree.ColumnPolicy)1 QualifiedNameReference (io.crate.sql.tree.QualifiedNameReference)1 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)1 SymbolMatchers.isReference (io.crate.testing.SymbolMatchers.isReference)1 DataType (io.crate.types.DataType)1 LinkedHashSet (java.util.LinkedHashSet)1