private Expression toRows(PhysType physType, Expression expression) { if (physType.getFormat() == JavaRowFormat.SCALAR && Object[].class.isAssignableFrom(elementType) && getRowType().getFieldCount() == 1 && (table.unwrap(ScannableTable.class) != null || table.unwrap(FilterableTable.class) != null || table.unwrap(ProjectableFilterableTable.class) != null)) { return Expressions.call(BuiltInMethod.SLICE0.method, expression); } JavaRowFormat oldFormat = format(); if (physType.getFormat() == oldFormat && !hasCollectionField(rowType)) { return expression; } final ParameterExpression row_ = Expressions.parameter(elementType, "row"); final int fieldCount = table.getRowType().getFieldCount(); List<Expression> expressionList = new ArrayList<>(fieldCount); for (int i = 0; i < fieldCount; i++) { expressionList.add(fieldExpression(row_, i, physType, oldFormat)); } return Expressions.call(expression, BuiltInMethod.SELECT.method, Expressions.lambda(Function1.class, physType.record(expressionList), row_)); }
private Expression toRows(PhysType physType, Expression expression) { if (physType.getFormat() == JavaRowFormat.SCALAR && Object[].class.isAssignableFrom(elementType) && getRowType().getFieldCount() == 1 && (table.unwrap(ScannableTable.class) != null || table.unwrap(FilterableTable.class) != null || table.unwrap(ProjectableFilterableTable.class) != null)) { return Expressions.call(BuiltInMethod.SLICE0.method, expression); } JavaRowFormat oldFormat = format(); if (physType.getFormat() == oldFormat && !hasCollectionField(rowType)) { return expression; } final ParameterExpression row_ = Expressions.parameter(elementType, "row"); final int fieldCount = table.getRowType().getFieldCount(); List<Expression> expressionList = new ArrayList<>(fieldCount); for (int i = 0; i < fieldCount; i++) { expressionList.add(fieldExpression(row_, i, physType, oldFormat)); } return Expressions.call(expression, BuiltInMethod.SELECT.method, Expressions.lambda(Function1.class, physType.record(expressionList), row_)); }