Repository: dask/dask
File: dask/dataframe/dask_expr/_concat.py (Python)

Code before:
                return

            frames = [
                (
                    frame[cols]
                    if set(cols) != set(get_columns_or_name(frame))
                    or len(cols) != len(get_columns_or_name(frame))
                    else frame
                )
                for frame, cols in zip(self._frames, columns_frame)
                if len(cols) > 0
            ]
            result = type(self)(
                self.join,
                self.ignore_order,
                self._kwargs,
                self.axis,
                self.ignore_unknown_divisions,
                self.interleave_partitions,
                *frames,
            )
            if result.columns == _convert_to_list(parent.operand("columns")):
                if result.ndim == parent.ndim:
                    return result
                elif result.ndim < parent.ndim:
                    return ToFrame(result)

            return type(parent)(result, *parent.operands[1:])


class StackPartition(Concat):
    _parameters = ["join", "ignore_order", "axis", "_kwargs"]
    _defaults = {"join": "outer", "ignore_order": False, "_kwargs": {}, "axis": 0}

    def _layer(self):
        dsk, i = {}, 0
        kwargs = self._kwargs.copy()
        kwargs["ignore_order"] = self.ignore_order
        ctr = 0
        meta = strip_unknown_categories(self._meta)
        for df in self._frames:
            try:
                check_meta(df._meta, self._meta)
                match = True
            except (ValueError, TypeError):
                match = False

            for i in range(df.npartitions):
                if match:
                    dsk[(self._name, ctr)] = df._name, i
                else:

Review comment (suggestion):
Ordering was a bit messed up here as well. I attempted to pass the arguments here using keywords but that doesn't work. Our paramters parsing logic isn't smart enough and doesn't capture the frames properly but instead raises a cryptic error message

Code after:
            ]
            if all(
                set(cols) == set(get_columns_or_name(frame))
                and len(cols) == len(get_columns_or_name(frame))
                for frame, cols in zip(self._frames, columns_frame)
            ):
                return

            frames = [
                (
                    frame[cols]
                    if set(cols) != set(get_columns_or_name(frame))
                    or len(cols) != len(get_columns_or_name(frame))
                    else frame
                )
                for frame, cols in zip(self._frames, columns_frame)
                if len(cols) > 0
            ]
            result = type(self)(
                self.join,
                self.ignore_order,
                self.axis,
                self.ignore_unknown_divisions,
                self.interleave_partitions,
                self._kwargs,
                *frames,
            )

            if result.columns == _convert_to_list(parent.operand("columns")):
                if result.ndim == parent.ndim:
                    return result
                elif result.ndim < parent.ndim:
                    return ToFrame(result)

            return type(parent)(result, *parent.operands[1:])


class StackPartition(Concat):

    def _layer(self):
        dsk, i = {}, 0
        kwargs = self._kwargs.copy()
        kwargs["ignore_order"] = self.ignore_order
        ctr = 0
        meta = strip_unknown_categories(self._meta)
        for df in self._frames:
            try:
                check_meta(df._meta, self._meta)
                match = True
            except (ValueError, TypeError):
                match = False