use of io.crate.analyze.relations.DocTableRelation in project crate by crate.
the class InputFactoryTest method prepare.
@Before
public void prepare() throws Exception {
Map<RelationName, AnalyzedRelation> sources = T3.sources(List.of(T3.T1), clusterService);
DocTableRelation tr1 = (DocTableRelation) sources.get(T3.T1);
expressions = new SqlExpressions(sources, tr1);
factory = new InputFactory(expressions.nodeCtx);
}
use of io.crate.analyze.relations.DocTableRelation in project crate by crate.
the class CollectTest method test_prune_output_of_collect_updates_estimated_row_size.
@Test
public void test_prune_output_of_collect_updates_estimated_row_size() throws Exception {
var e = SQLExecutor.builder(clusterService).addTable("create table t (x int, y int)").build();
TableStats tableStats = new TableStats();
Symbol x = e.asSymbol("x");
Collect collect = Collect.create(new DocTableRelation(e.resolveTableInfo("t")), List.of(x, e.asSymbol("y")), WhereClause.MATCH_ALL, tableStats, Row.EMPTY);
assertThat(collect.estimatedRowSize(), is(DataTypes.INTEGER.fixedSize() * 2L));
LogicalPlan prunedCollect = collect.pruneOutputsExcept(tableStats, List.of(x));
assertThat(prunedCollect.estimatedRowSize(), is((long) DataTypes.INTEGER.fixedSize()));
}
use of io.crate.analyze.relations.DocTableRelation in project crate by crate.
the class FetchRewriteTest method test_fetchrewrite_on_eval_with_nested_source_outputs.
@Test
public void test_fetchrewrite_on_eval_with_nested_source_outputs() throws Exception {
SQLExecutor e = SQLExecutor.builder(clusterService).addTable("create table tbl (x int)").build();
DocTableInfo tableInfo = e.resolveTableInfo("tbl");
var x = new AliasSymbol("x_alias", e.asSymbol("x"));
var relation = new DocTableRelation(tableInfo);
var collect = new Collect(relation, List.of(x), WhereClause.MATCH_ALL, 1L, DataTypes.INTEGER.fixedSize());
var eval = new Eval(collect, List.of(x));
FetchRewrite fetchRewrite = eval.rewriteToFetch(new TableStats(), List.of());
assertThat(fetchRewrite, Matchers.notNullValue());
assertThat(fetchRewrite.newPlan(), isPlan("Collect[doc.tbl | [_fetchid] | true]"));
assertThat(fetchRewrite.replacedOutputs(), Matchers.hasEntry(is(x), isAlias("x_alias", isFetchStub("_doc['x']"))));
}
use of io.crate.analyze.relations.DocTableRelation in project crate by crate.
the class FetchRewriteTest method test_fetch_rewrite_on_eval_removes_eval_and_extends_replaced_outputs.
@Test
public void test_fetch_rewrite_on_eval_removes_eval_and_extends_replaced_outputs() throws Exception {
SQLExecutor e = SQLExecutor.builder(clusterService).addTable("create table tbl (x int)").build();
DocTableInfo tableInfo = e.resolveTableInfo("tbl");
var x = e.asSymbol("x");
var relation = new DocTableRelation(tableInfo);
var collect = new Collect(relation, List.of(x), WhereClause.MATCH_ALL, 1L, DataTypes.INTEGER.fixedSize());
var eval = new Eval(collect, List.of(new Function(Signature.scalar("add", DataTypes.INTEGER.getTypeSignature(), DataTypes.INTEGER.getTypeSignature(), DataTypes.INTEGER.getTypeSignature()), List.of(x, x), DataTypes.INTEGER)));
FetchRewrite fetchRewrite = eval.rewriteToFetch(new TableStats(), List.of());
assertThat(fetchRewrite, Matchers.notNullValue());
assertThat(fetchRewrite.newPlan(), isPlan("Collect[doc.tbl | [_fetchid] | true]"));
assertThat(fetchRewrite.replacedOutputs(), Matchers.hasEntry(isFunction("add", isReference("x"), isReference("x")), isFunction("add", isFetchStub("_doc['x']"), isFetchStub("_doc['x']"))));
assertThat(List.copyOf(fetchRewrite.replacedOutputs().keySet()), is(eval.outputs()));
}
use of io.crate.analyze.relations.DocTableRelation in project crate by crate.
the class AbstractWindowFunctionTest method prepareFunctions.
@Before
public void prepareFunctions() {
DocTableInfo tableInfo = SQLExecutor.tableInfo(new RelationName("doc", "t1"), "create table doc.t1 (x int, y bigint, z string, d double)", clusterService);
DocTableRelation tableRelation = new DocTableRelation(tableInfo);
Map<RelationName, AnalyzedRelation> tableSources = Map.of(tableInfo.ident(), tableRelation);
memoryManager = new OnHeapMemoryManager(bytes -> {
});
sqlExpressions = new SqlExpressions(tableSources, tableRelation, User.CRATE_USER, additionalModules);
inputFactory = new InputFactory(sqlExpressions.nodeCtx);
}
Aggregations