Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: dataframe should preserve state on unmount (#10759) (#10762)

Mate Mijolović69e0067c503b
diff --git a/frontend/src/plugins/impl/data-frames/__tests__/schema.test.ts b/frontend/src/plugins/impl/data-frames/__tests__/schema.test.ts
index 8f519775fc..64b50f63bc 100644
--- a/frontend/src/plugins/impl/data-frames/__tests__/schema.test.ts
+++ b/frontend/src/plugins/impl/data-frames/__tests__/schema.test.ts
@@ -1,7 +1,8 @@
/* Copyright 2026 Marimo. All rights reserved. */
import { describe, expect, it } from "vitest";
-import { columnToFieldTypesSchema } from "../schema";
+import { columnToFieldTypesSchema, TransformationsSchema } from "../schema";
+import type { ColumnId } from "../types";
describe("columnToFieldTypesSchema", () => {
it("keeps known field types", () => {
@@ -36,3 +37,35 @@ describe("columnToFieldTypesSchema", () => {
expect(result).toEqual([["geom", ["geometry", "geometry"]]]);
});
});
+
+describe("FilterRowsTransformSchema", () => {
+ const condition = {
+ column_id: "col" as ColumnId,
+ operator: "in" as const,
+ value: ["a"],
+ type: "condition" as const,
+ negate: false,
+ };
+
+ it("does not wrap where in a FilterGroup", () => {
+ const result = TransformationsSchema.parse({
+ transforms: [
+ {
+ type: "filter_rows",
+ operation: "keep_rows",
+ where: [condition],
+ },
+ ],
+ });
+
+ expect(result).toEqual({
+ transforms: [
+ {
+ type: "filter_rows",
+ operation: "keep_rows",
+ where: [condition],
+ },
+ ],
+ });
+ });
+});
diff --git a/frontend/src/plugins/impl/data-frames/schema.ts b/frontend/src/plugins/impl/data-frames/schema.ts
index c571996210..7028a000a9 100644
--- a/frontend/src/plugins/impl/data-frames/schema.ts
+++ b/frontend/src/plugins/impl/data-frames/schema.ts
@@ -129,17 +129,11 @@ const FilterRowsTransformSchema = z.object({
negate: false,
},
])
- .transform((value): FilterGroupType => {
- const validConditions = value.filter((condition) => {
- return isConditionValueValid(condition.operator, condition.value);
- });
- return {
- type: "group",
- operator: "and",
- children: validConditions,
- negate: false,
- };
- }),
+ .transform((value) =>
+ value.filter((condition) =>
+ isConditionValueValid(condition.operator, condition.value),
+ ),
+ ),
});
const GroupByTransformSchema = z