use of io.crate.expression.InputFactory 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));
}
use of io.crate.expression.InputFactory in project crate by crate.
the class ProjectionToProjectorVisitorTest method prepare.
@Before
public void prepare() {
nodeCtx = createNodeContext();
MockitoAnnotations.initMocks(this);
visitor = new ProjectionToProjectorVisitor(clusterService, new NodeLimits(new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), new NoneCircuitBreakerService(), nodeCtx, THREAD_POOL, Settings.EMPTY, mock(TransportActionProvider.class, Answers.RETURNS_DEEP_STUBS), new InputFactory(nodeCtx), EvaluatingNormalizer.functionOnlyNormalizer(nodeCtx), t -> null, t -> null);
memoryManager = new OnHeapMemoryManager(usedBytes -> {
});
avgSignature = Signature.aggregate("avg", DataTypes.INTEGER.getTypeSignature(), DataTypes.DOUBLE.getTypeSignature());
}
use of io.crate.expression.InputFactory in project crate by crate.
the class ProjectorsTest method prepare.
@Before
public void prepare() throws Exception {
nodeCtx = createNodeContext();
memoryManager = new OnHeapMemoryManager(bytes -> {
});
projectorFactory = new ProjectionToProjectorVisitor(clusterService, new NodeLimits(new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), new NoneCircuitBreakerService(), nodeCtx, THREAD_POOL, Settings.EMPTY, mock(TransportActionProvider.class, Answers.RETURNS_DEEP_STUBS), new InputFactory(nodeCtx), new EvaluatingNormalizer(nodeCtx, RowGranularity.SHARD, r -> Literal.ofUnchecked(r.valueType(), r.valueType().sanitizeValue("1")), null), t -> null, t -> null, Version.CURRENT, new ShardId("dummy", UUID.randomUUID().toString(), 0), null);
}
use of io.crate.expression.InputFactory in project crate by crate.
the class MapRowUsingInputsTest method createInputs.
@Before
public void createInputs() throws Exception {
InputFactory inputFactory = new InputFactory(createNodeContext());
InputFactory.Context<CollectExpression<Row, ?>> ctx = inputFactory.ctxForInputColumns(txnCtx);
var addFunction = new Function(Signature.scalar(ArithmeticFunctions.Names.ADD, DataTypes.LONG.getTypeSignature(), DataTypes.LONG.getTypeSignature(), DataTypes.LONG.getTypeSignature()).withFeatures(Scalar.DETERMINISTIC_AND_COMPARISON_REPLACEMENT), List.of(new InputColumn(0, DataTypes.LONG), Literal.of(2L)), DataTypes.LONG);
inputs = Collections.singletonList(ctx.add(addFunction));
expressions = ctx.expressions();
}
use of io.crate.expression.InputFactory in project crate by crate.
the class FileReadingCollectorTest method prepare.
@Before
public void prepare() throws Exception {
NodeContext nodeCtx = new NodeContext(new Functions(Map.of()));
inputFactory = new InputFactory(nodeCtx);
}
Aggregations