public PlanNode visitFilter()

in paimon-presto-0.236/src/main/java/org/apache/paimon/presto/PrestoComputePushdown.java [138:211]


        public PlanNode visitFilter(FilterNode filter, Void context) {
            if (!(filter.getSource() instanceof TableScanNode)) {
                return filter;
            }

            TableScanNode tableScan = (TableScanNode) filter.getSource();

            Map<String, PrestoColumnHandle> nameToColumnHandlesMapping =
                    tableScan.getAssignments().entrySet().stream()
                            .collect(
                                    Collectors.toMap(
                                            e -> e.getKey().getName(),
                                            e -> (PrestoColumnHandle) e.getValue()));

            RowExpression filterPredicate = filter.getPredicate();

            DomainTranslator.ExtractionResult<Subfield> decomposedFilter =
                    rowExpressionService
                            .getDomainTranslator()
                            .fromPredicate(
                                    session,
                                    filterPredicate,
                                    new SubfieldExtractor(
                                                    functionResolution,
                                                    rowExpressionService.getExpressionOptimizer(),
                                                    session)
                                            .toColumnExtractor());

            // Build paimon predicate presto column.
            TupleDomain<PrestoColumnHandle> entireColumnDomain =
                    decomposedFilter
                            .getTupleDomain()
                            .transform(
                                    subfield ->
                                            subfield.getPath().isEmpty()
                                                    ? subfield.getRootName()
                                                    : null)
                            .transform(nameToColumnHandlesMapping::get);

            // Build paimon predicate column list.
            Map<VariableReferenceExpression, ColumnHandle> assignments = tableScan.getAssignments();
            Optional<List<ColumnHandle>> projectedColumns =
                    extractColumns(filterPredicate, assignments);

            // Build paimon new presto table handle use pushdown.
            PrestoTableHandle oldPrestoTableHandle =
                    (PrestoTableHandle) tableScan.getTable().getConnectorHandle();
            PrestoTableHandle newPrestoTableHandle =
                    new PrestoTableHandle(
                            oldPrestoTableHandle.getSchemaName(),
                            oldPrestoTableHandle.getTableName(),
                            oldPrestoTableHandle.getSerializedTable(),
                            entireColumnDomain,
                            projectedColumns,
                            Optional.empty());

            PrestoTableLayoutHandle newLayoutHandle =
                    new PrestoTableLayoutHandle(
                            newPrestoTableHandle, tableScan.getCurrentConstraint());
            TableScanNode newTableScan =
                    new TableScanNode(
                            tableScan.getId(),
                            new TableHandle(
                                    tableScan.getTable().getConnectorId(),
                                    newPrestoTableHandle,
                                    tableScan.getTable().getTransaction(),
                                    Optional.of(newLayoutHandle)),
                            tableScan.getOutputVariables(),
                            tableScan.getAssignments(),
                            tableScan.getCurrentConstraint(),
                            tableScan.getEnforcedConstraint());

            return new FilterNode(filter.getId(), newTableScan, filterPredicate);
        }