use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class EvaluatingNormalizerTest method prepareFunctionTree.
/**
* prepare the following where clause as function symbol tree:
* <p>
* where test.dummy.load = 0.08 or name != 'x' and name != 'y'
* <p>
* test.dummy.load is a expression that can be evaluated on node level
* name would be a doc level reference and is untouched
*/
private Function prepareFunctionTree() {
Reference load_1 = dummyLoadInfo;
Literal<Double> d01 = Literal.of(0.08);
Function load_eq_01 = new Function(EqOperator.SIGNATURE, List.of(load_1, d01), EqOperator.RETURN_TYPE);
Symbol name_ref = new Reference(new ReferenceIdent(new RelationName(Schemas.DOC_SCHEMA_NAME, "foo"), "name"), RowGranularity.DOC, DataTypes.STRING, 0, null);
Symbol x_literal = Literal.of("x");
Symbol y_literal = Literal.of("y");
Function name_eq_x = new Function(EqOperator.SIGNATURE, List.of(name_ref, x_literal), EqOperator.RETURN_TYPE);
Function nameNeqX = new Function(NotPredicate.SIGNATURE, Collections.singletonList(name_eq_x), NotPredicate.SIGNATURE.getReturnType().createType());
Function name_eq_y = new Function(EqOperator.SIGNATURE, List.of(name_ref, y_literal), EqOperator.RETURN_TYPE);
Function nameNeqY = new Function(NotPredicate.SIGNATURE, Collections.singletonList(name_eq_y), NotPredicate.SIGNATURE.getReturnType().createType());
Function op_and = new Function(AndOperator.SIGNATURE, List.of(nameNeqX, nameNeqY), AndOperator.RETURN_TYPE);
return new Function(OrOperator.SIGNATURE, List.of(load_eq_01, op_and), OrOperator.RETURN_TYPE);
}
use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class GroupByAnalyzerTest method testGroupByLiteralAliasedWithRealColumnNameGroupsByColumnValue.
@Test
public void testGroupByLiteralAliasedWithRealColumnNameGroupsByColumnValue() {
QueriedSelectRelation relation = analyze("select 58 as age from foo.users group by age;");
assertThat(relation.groupBy().isEmpty(), is(false));
List<Symbol> groupBySymbols = relation.groupBy();
ReferenceIdent groupByIdent = ((Reference) groupBySymbols.get(0)).ident();
assertThat(groupByIdent.columnIdent().fqn(), is("age"));
assertThat(groupByIdent.tableIdent().fqn(), is("foo.users"));
}
use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class NodeStatsTest method prepare.
@Before
public void prepare() {
idRef = new Reference(new ReferenceIdent(SysNodesTableInfo.IDENT, SysNodesTableInfo.Columns.ID), RowGranularity.DOC, DataTypes.STRING, 1, null);
nameRef = new Reference(new ReferenceIdent(SysNodesTableInfo.IDENT, SysNodesTableInfo.Columns.ID), RowGranularity.DOC, DataTypes.STRING, 2, null);
hostnameRef = new Reference(new ReferenceIdent(SysNodesTableInfo.IDENT, SysNodesTableInfo.Columns.HOSTNAME), RowGranularity.DOC, DataTypes.STRING, 3, null);
collectPhase = mock(RoutedCollectPhase.class);
when(collectPhase.where()).thenReturn(Literal.BOOLEAN_FALSE);
nodes.add(newNode("nodeOne"));
nodes.add(newNode("nodeTwo"));
nodeCtx = createNodeContext();
}
use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class LuceneOrderedDocCollectorTest method testSearchAfterWithSystemColumn.
@Test
public void testSearchAfterWithSystemColumn() {
Reference sysColReference = new Reference(new ReferenceIdent(new RelationName(Schemas.DOC_SCHEMA_NAME, "table"), DocSysColumns.SCORE), RowGranularity.DOC, DataTypes.FLOAT, 0, null);
OrderBy orderBy = new OrderBy(List.of(sysColReference, REFERENCE), new boolean[] { false, false }, new boolean[] { false, false });
FieldDoc lastCollected = new FieldDoc(0, 0, new Object[] { 2L });
OptimizeQueryForSearchAfter queryForSearchAfter = new OptimizeQueryForSearchAfter(orderBy, mock(QueryShardContext.class), name -> valueFieldType);
Query nextPageQuery = queryForSearchAfter.apply(lastCollected);
// returns null which leads to reuse of old query without paging optimization
assertNull(nextPageQuery);
}
use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class DocValuesGroupByOptimizedIteratorTest method test_group_by_doc_values_optimized_iterator_for_single_numeric_key.
@Test
public void test_group_by_doc_values_optimized_iterator_for_single_numeric_key() throws Exception {
SumAggregation<?> sumAggregation = (SumAggregation<?>) functions.getQualified(Signature.aggregate(SumAggregation.NAME, DataTypes.LONG.getTypeSignature(), DataTypes.LONG.getTypeSignature()), List.of(DataTypes.LONG), DataTypes.LONG);
var sumDocValuesAggregator = sumAggregation.getDocValueAggregator(List.of(new Reference(new ReferenceIdent(RelationName.fromIndexName("test"), "z"), RowGranularity.DOC, DataTypes.LONG, ColumnPolicy.DYNAMIC, IndexType.PLAIN, true, true, 0, null)), mock(DocTableInfo.class), List.of());
var keyExpressions = List.of(new LongColumnReference("y"));
var it = DocValuesGroupByOptimizedIterator.GroupByIterator.forSingleKey(List.of(sumDocValuesAggregator), indexSearcher, new Reference(new ReferenceIdent(RelationName.fromIndexName("test"), "y"), RowGranularity.DOC, DataTypes.LONG, ColumnPolicy.DYNAMIC, IndexType.PLAIN, true, true, 0, null), keyExpressions, RamAccounting.NO_ACCOUNTING, null, null, new MatchAllDocsQuery(), new CollectorContext());
var rowConsumer = new TestingRowConsumer();
rowConsumer.accept(it, null);
assertThat(rowConsumer.getResult(), containsInAnyOrder(new Object[] { 0L, 6L }, new Object[] { 1L, 4L }));
}
Aggregations