private String toElasticsearchQuery(EnumerableRel root) { try { EnumerableRelImplementor relImplementor = new EnumerableRelImplementor(root.getCluster().getRexBuilder(), ImmutableMap.of()); final ElasticsearchRel.Implementor elasticsearchImplementor = new ElasticsearchRel.Implementor(); RelDataType rowType = root.getRowType(); final PhysType physType = PhysTypeImpl.of(relImplementor.getTypeFactory(), rowType, Prefer.ARRAY.prefer(JavaRowFormat.ARRAY)); List<Pair<String, Class>> pairs = Pair .zip(ElasticsearchRules.elasticsearchFieldNames(rowType), new AbstractList<Class>() { @Override public Class get(int index) { return physType.fieldClass(index); } @Override public int size() { return rowType.getFieldCount(); } }); return elasticsearchImplementor.convert(root.getInput(0), pairs); } catch (IOException ex) { throw new RuntimeException(ex); } finally { Prepare.CatalogReader.THREAD_LOCAL.remove(); } }
typeFactory, getRowType(), pref.prefer(result.format));
typeFactory, getRowType(), pref.prefer(result.format));
PhysTypeImpl.of( implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM)); final JdbcConvention jdbcConvention = (JdbcConvention) child.getConvention();
PhysTypeImpl.of( implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM)); final JdbcConvention jdbcConvention = (JdbcConvention) child.getConvention();
implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM));
implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM));
prefer.prefer(JavaRowFormat.ARRAY)); final Expression fields = block.append("fields", constantArrayList(
implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM)); return implementor.result(physType, builder.toBlock());
implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM)); return implementor.result(physType, builder.toBlock());
implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM)); return implementor.result(physType, builder.toBlock());
implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM)); return implementor.result(physType, builder.toBlock());
implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM)); return implementor.result(physType, builder.toBlock());
@Override public Result implement(EnumerableRelImplementor implementor, Prefer pref) { final BlockBuilder builder = new BlockBuilder(); Expression unionExp = null; for (Ord<RelNode> ord : Ord.zip(inputs)) { EnumerableRel input = (EnumerableRel) ord.e; final Result result = implementor.visitChild(this, ord.i, input, pref); Expression childExp = builder.append( "child" + ord.i, result.block); if (unionExp == null) { unionExp = childExp; } else { unionExp = createUnionExpression(unionExp, childExp, result.format == JavaRowFormat.ARRAY); } } builder.add(unionExp); final PhysType physType = PhysTypeImpl.of( implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM)); return implementor.result(physType, builder.toBlock()); } }
implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM)); return implementor.result(physType, builder.toBlock());
public JavaRowFormat preferCustom() { return prefer(JavaRowFormat.CUSTOM); }
public JavaRowFormat preferArray() { return prefer(JavaRowFormat.ARRAY); }
public JavaRowFormat preferArray() { return prefer(JavaRowFormat.ARRAY); }
public JavaRowFormat preferCustom() { return prefer(JavaRowFormat.CUSTOM); }
@Override public Result implement(EnumerableRelImplementor implementor, Prefer pref) { final BlockBuilder builder = new BlockBuilder(); Expression unionExp = null; for (Ord<RelNode> ord : Ord.zip(inputs)) { EnumerableRel input = (EnumerableRel) ord.e; final Result result = implementor.visitChild(this, ord.i, input, pref); Expression childExp = builder.append( "child" + ord.i, result.block); if (unionExp == null) { unionExp = childExp; } else { unionExp = createUnionExpression(unionExp, childExp, result.format == JavaRowFormat.ARRAY); } } builder.add(unionExp); final PhysType physType = PhysTypeImpl.of( implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.CUSTOM)); return implementor.result(physType, builder.toBlock()); } }