use of io.crate.expression.reference.DocRefResolver in project crate by crate.
the class GeneratedColumnsTest method testSubscriptExpressionThatReturnsAnArray.
@Test
public void testSubscriptExpressionThatReturnsAnArray() throws Exception {
SQLExecutor e = SQLExecutor.builder(clusterService).addTable("create table t (obj object as (arr array(integer)), arr as obj['arr'])").build();
QueriedSelectRelation query = e.analyze("select obj, arr from t");
DocTableInfo table = ((DocTableRelation) query.from().get(0)).tableInfo();
GeneratedColumns<Doc> generatedColumns = new GeneratedColumns<>(new InputFactory(e.nodeCtx), CoordinatorTxnCtx.systemTransactionContext(), GeneratedColumns.Validation.NONE, new DocRefResolver(Collections.emptyList()), Collections.emptyList(), table.generatedColumns());
BytesReference bytes = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().startObject("obj").startArray("arr").value(10).value(20).endArray().endObject().endObject());
generatedColumns.setNextRow(new Doc(1, table.concreteIndices()[0], "1", 1, 1, 1, XContentHelper.convertToMap(bytes, false, XContentType.JSON).v2(), bytes::utf8ToString));
Map.Entry<Reference, Input<?>> generatedColumn = generatedColumns.generatedToInject().iterator().next();
assertThat((List<Object>) generatedColumn.getValue().value(), contains(10, 20));
}
Aggregations