The SQL/Python node (also called the CODE node) lets you write custom code when built-in nodes don’t provide the exact transformation you need. Toggle between SQL and Python modes for advanced calculations, complex business logic, or custom data manipulation.Your code runs in a secure, sandboxed environment and operates on data from the parent node. The result becomes the output that flows to the next node.
The parent node’s output is available as a table named data:
SELECT * FROM data
If one of your source columns is also named data, bare unquoted data always refers to the parent table, not the column. Use double quotes ("data") or a table alias (FROM data AS t then t.data) to reference it as a column instead.
You have access to standard SQL: SELECT, WHERE, CASE WHEN, GROUP BY, ORDER BY, joins, and common string, date, and math functions.
When the node has more than one parent, each parent is available as a table named after its step label (shown on the node in the canvas: A1, B1, C1). The position-0 parent is also aliased as data.
-- Two parents: customers (A1) and orders (B1)SELECT A1.customer_name, SUM(B1.total) AS total_spendFROM A1JOIN B1 ON A1.id = B1.customer_idGROUP BY A1.customer_name
Step labels update automatically if you reorder or add parents. Go Fig translates stale labels on your behalf so your queries keep working.
SELECT customer_name, revenue, CASE WHEN revenue > 10000 THEN 'Enterprise' WHEN revenue > 5000 THEN 'Growth' WHEN revenue > 1000 THEN 'Standard' ELSE 'Starter' END AS tierFROM dataWHERE revenue > 0ORDER BY revenue DESC
Creates a custom “tier” column based on revenue thresholds, filters out zero-revenue customers, and sorts by revenue.
The parent node’s output is available as a pandas DataFrame named data. Access columns with dot or bracket notation (data.revenue or data['Customer Name']).Three libraries are pre-imported: pandas (pd), numpy (np), and fig, Go Fig’s helper library for fuzzy matching, fiscal-year conversion, z-scores, safe percentage change, and deduplication (see Fig Helpers).
Each parent is exposed as a DataFrame named after its step label (A1, B1, C1). The position-0 parent is also bound to data.
# Two parents: customers (A1) and orders (B1)result = B1.merge(A1[['id', 'customer_name']], left_on='customer_id', right_on='id', how='left')return result
Your code must return a DataFrame, not a Series or scalar. The last expression should be a DataFrame:
# ✅ Returns a DataFrameresult = data.copy()result['commission'] = result['revenue'] * 0.1result# ❌ Returns a Series or scalardata['revenue']data['revenue'].sum()
For security, code runs in an isolated sandbox: no import statements (only the pre-imported pd, np, and fig), no exec/eval/compile, no filesystem or system access, and no network requests. If you need more, preprocess your data outside Go Fig and import it as a data source.
Check column names: data.columns (Python) or SELECT * FROM data LIMIT 5 (SQL)
Check data types: data.dtypes (Python)
Handle nulls: .fillna() (Python) or COALESCE() (SQL)
Build incrementally: test each part before adding complexity
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Go Fig Documentation","colors":{"primary":"#0EA5E9","light":"#0EA5E9","dark":"#0EA5E9"},"logo":{"light":"https://mintcdn.com/gofig/1F70rJ09g-reP40S/logo/full_logo_h.png?fit=max\u0026auto=format\u0026n=1F70rJ09g-reP40S\u0026q=85\u0026s=4ed68f93c9deb5b8a64380d54793646b","dark":"https://mintcdn.com/gofig/1F70rJ09g-reP40S/logo/full_logo_h_white.png?fit=max\u0026auto=format\u0026n=1F70rJ09g-reP40S\u0026q=85\u0026s=edae2323c92138224d0ef5e073a727f1"},"favicon":"https://mintcdn.com/gofig/1F70rJ09g-reP40S/logo/favicon.ico?fit=max\u0026auto=format\u0026n=1F70rJ09g-reP40S\u0026q=85\u0026s=fe93194d9c3f16381d12a62e48156d1b","navbar":{"links":[{"href":"mailto:[email protected]","label":"Support"}],"primary":{"type":"button","label":"Sign In","href":"https://app.gofig.ai"}},"footer":{"socials":{"website":"https://gofig.ai","facebook":"https://www.facebook.com/gofigai","twitter":"https://twitter.com/gofigai","instagram":"https://www.instagram.com/gofigai","linkedin":"https://www.linkedin.com/company/gofigai","youtube":"https://www.youtube.com/@GoFigAI"}},"seo":{},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"metadata":{"timestamp":false},"styling":{"latex":true},"navigation":{"global":{"anchors":[{"anchor":"Documentation","icon":"book-open","href":"https://docs.gofig.ai"},{"anchor":"Security Hub","icon":"shield-check","href":"https://gofig.ai/security"},{"anchor":"Slack Community","icon":"slack","href":"https://join.slack.com/t/gofigapp/shared_invite/zt-2iagi9ol2-aRD7XmodFJ4c9QFzOQHhdg"},{"anchor":"Contact Support","icon":"life-ring","href":"https://gofig.ai/demo"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"gofig","hasAudioNarration":false,"actualSubdomain":"gofig","customDomains":["docs.gofig.ai"],"gitSource":{"type":"github","owner":"go-fig-ai","repo":"fig-app","deployBranch":"main","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae4b044737a5e6c8f11775f","collectionId":"11b450e1-935d-4fbb-beb6-6e63160359b6","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae4b044737a5e6c8f11775f"},"feedback":{"thumbs":true},"entitlements":{},"buildId":"6ae4b044737a5e6c8f11775f","clientVersion":"0.0.4076","searchFilterCounts":[{"language":"default","tag":"Guides","count":37},{"language":"default","tag":"Flows","count":18},{"language":"default","tag":"Nodes","count":15},{"language":"default","tag":"Integrations","count":12},{"language":"default","tag":"Centralize your data","count":12},{"language":"default","tag":"Getting started","count":11},{"language":"default","tag":"Databases and warehouses","count":6},{"language":"default","tag":"Process","count":6},{"language":"default","tag":"Dashboards","count":4},{"language":"default","tag":"Connect your AI (MCP)","count":4}]},"assistantConfig":{"enableStarterQuestions":false},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"comment-mode","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"workflows/nodes/code","slug":"/workflows/nodes/code","pageMetadata":{"title":"SQL/Python","description":"Write custom SQL queries or Python scripts directly in your Go Fig flow for advanced transformations and logic","href":"/workflows/nodes/code"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Write custom SQL queries or Python scripts directly in your Go Fig flow for advanced transformations and logic\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Frame,Heading,OptimizedImage,Tip,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Frame)_missingMdxReference(`Frame`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`what-this-node-does`,children:`What This Node Does`}),`\n`,_jsx(_components.p,{children:`The SQL/Python node (also called the CODE node) lets you write custom code when built-in nodes don’t provide the exact transformation you need. Toggle between SQL and Python modes for advanced calculations, complex business logic, or custom data manipulation.`}),`\n`,_jsx(_components.p,{children:`Your code runs in a secure, sandboxed environment and operates on data from the parent node. The result becomes the output that flows to the next node.`}),`\n`,_jsx(Frame,{children:_jsx(OptimizedImage,{src:`https://mintcdn.com/gofig/5rnC6kUtziv2cwlt/images/node-code-modal.png?fit=max\u0026auto=format\u0026n=5rnC6kUtziv2cwlt\u0026q=85\u0026s=83226270476108f5542762e86387f53c`,alt:`The SQL/Python node configuration with a SQL/Python language toggle and a code editor referencing the upstream step.`,style:{borderRadius:`0.5rem`},\"data-og-width\":`700`,width:`700`,\"data-og-height\":`701`,height:`701`,\"data-path\":`images/node-code-modal.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/gofig/5rnC6kUtziv2cwlt/images/node-code-modal.png?w=280\u0026fit=max\u0026auto=format\u0026n=5rnC6kUtziv2cwlt\u0026q=85\u0026s=3434b67d9bac3834fe5b59f4e828afeb 280w, https://mintcdn.com/gofig/5rnC6kUtziv2cwlt/images/node-code-modal.png?w=560\u0026fit=max\u0026auto=format\u0026n=5rnC6kUtziv2cwlt\u0026q=85\u0026s=2bd4c86b7ee421470ca1471c7ad02a23 560w, https://mintcdn.com/gofig/5rnC6kUtziv2cwlt/images/node-code-modal.png?w=840\u0026fit=max\u0026auto=format\u0026n=5rnC6kUtziv2cwlt\u0026q=85\u0026s=2ec57df1276472bf7dd0bea97b7bcee0 840w, https://mintcdn.com/gofig/5rnC6kUtziv2cwlt/images/node-code-modal.png?w=1100\u0026fit=max\u0026auto=format\u0026n=5rnC6kUtziv2cwlt\u0026q=85\u0026s=00059bb836c8b99105b2f1505fdbd904 1100w, https://mintcdn.com/gofig/5rnC6kUtziv2cwlt/images/node-code-modal.png?w=1650\u0026fit=max\u0026auto=format\u0026n=5rnC6kUtziv2cwlt\u0026q=85\u0026s=55e95a3feab3d230b1cfbcc47b2b5fc5 1650w, https://mintcdn.com/gofig/5rnC6kUtziv2cwlt/images/node-code-modal.png?w=2500\u0026fit=max\u0026auto=format\u0026n=5rnC6kUtziv2cwlt\u0026q=85\u0026s=abdd39ce50c41f2ff72e6883add4a8a7 2500w`})}),`\n`,_jsx(Heading,{level:`2`,id:`when-to-use-this-node`,children:`When to Use This Node`}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Use it when:`})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`A built-in node can’t do what you need (custom calculations, complex conditional logic, advanced string or date work)`}),`\n`,_jsx(_components.li,{children:`You’re preserving existing SQL queries from another tool`}),`\n`,_jsx(_components.li,{children:`You need pandas or numpy operations`}),`\n`]}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Skip it when:`})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`A built-in node (Transform, Filter, PivotTable) can do the same job faster and more clearly`}),`\n`,_jsx(_components.li,{children:`Teammates without coding experience need to read the flow`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`language-toggle`,children:`Language Toggle`}),`\n`,_jsx(_components.p,{children:`A toggle at the top switches between SQL and Python. Both operate on the same parent data:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`SQL Mode`}),`: Standard SQL `,_jsx(_components.code,{children:`SELECT`}),` statements.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Python Mode`}),`: Python with pandas and numpy.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`sql-mode`,children:`SQL Mode`}),`\n`,_jsxs(_components.p,{children:[`The parent node’s output is available as a table named `,_jsx(_components.code,{children:`data`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` FROM`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` data`})]}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`If one of your source columns is also named `,_jsx(_components.code,{children:`data`}),`, bare unquoted `,_jsx(_components.code,{children:`data`}),` always refers to the parent table, not the column. Use double quotes (`,_jsx(_components.code,{children:`\"data\"`}),`) or a table alias (`,_jsx(_components.code,{children:`FROM data AS t`}),` then `,_jsx(_components.code,{children:`t.data`}),`) to reference it as a column instead.`]})}),`\n`,_jsxs(_components.p,{children:[`You have access to standard SQL: `,_jsx(_components.code,{children:`SELECT`}),`, `,_jsx(_components.code,{children:`WHERE`}),`, `,_jsx(_components.code,{children:`CASE WHEN`}),`, `,_jsx(_components.code,{children:`GROUP BY`}),`, `,_jsx(_components.code,{children:`ORDER BY`}),`, joins, and common string, date, and math functions.`]}),`\n`,_jsx(Heading,{level:`3`,id:`joining-multiple-parents`,children:`Joining Multiple Parents`}),`\n`,_jsxs(_components.p,{children:[`When the node has more than one parent, each parent is available as a table named after its `,_jsx(_components.strong,{children:`step label`}),` (shown on the node in the canvas: `,_jsx(_components.code,{children:`A1`}),`, `,_jsx(_components.code,{children:`B1`}),`, `,_jsx(_components.code,{children:`C1`}),`). The position-0 parent is also aliased as `,_jsx(_components.code,{children:`data`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`-- Two parents: customers (A1) and orders (B1)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` A1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`customer_name`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` SUM`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`B1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`total`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` total_spend`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`FROM`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` A1`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`JOIN`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` B1 `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`ON`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` A1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`id`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` B1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`customer_id`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`GROUP BY`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` A1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`customer_name`})]}),`\n`]})})}),`\n`,_jsx(Tip,{children:_jsx(_components.p,{children:`Step labels update automatically if you reorder or add parents. Go Fig translates stale labels on your behalf so your queries keep working.`})}),`\n`,_jsx(Heading,{level:`3`,id:`example`,children:`Example`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`12`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`12`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` customer_name,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` revenue,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` CASE`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` WHEN`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` revenue `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 10000`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` THEN`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Enterprise'`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` WHEN`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` revenue `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 5000`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` THEN`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Growth'`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` WHEN`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` revenue `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1000`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` THEN`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Standard'`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` ELSE`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Starter'`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` END`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` tier`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`FROM`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` data`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`WHERE`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` revenue `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`ORDER BY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` revenue `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`DESC`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Creates a custom “tier” column based on revenue thresholds, filters out zero-revenue customers, and sorts by revenue.`}),`\n`,_jsx(Heading,{level:`2`,id:`python-mode`,children:`Python Mode`}),`\n`,_jsxs(_components.p,{children:[`The parent node’s output is available as a pandas DataFrame named `,_jsx(_components.code,{children:`data`}),`. Access columns with dot or bracket notation (`,_jsx(_components.code,{children:`data.revenue`}),` or `,_jsx(_components.code,{children:`data['Customer Name']`}),`).`]}),`\n`,_jsxs(_components.p,{children:[`Three libraries are pre-imported: `,_jsx(_components.strong,{children:`pandas`}),` (`,_jsx(_components.code,{children:`pd`}),`), `,_jsx(_components.strong,{children:`numpy`}),` (`,_jsx(_components.code,{children:`np`}),`), and `,_jsx(_components.strong,{children:`fig`}),`, Go Fig’s helper library for fuzzy matching, fiscal-year conversion, z-scores, safe percentage change, and deduplication (see `,_jsx(_components.a,{href:`/workflows/nodes/fig-helpers`,children:`Fig Helpers`}),`).`]}),`\n`,_jsx(Heading,{level:`3`,id:`joining-multiple-parents-2`,children:`Joining Multiple Parents`}),`\n`,_jsxs(_components.p,{children:[`Each parent is exposed as a DataFrame named after its `,_jsx(_components.strong,{children:`step label`}),` (`,_jsx(_components.code,{children:`A1`}),`, `,_jsx(_components.code,{children:`B1`}),`, `,_jsx(_components.code,{children:`C1`}),`). The position-0 parent is also bound to `,_jsx(_components.code,{children:`data`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Two parents: customers (A1) and orders (B1)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` B1.merge(A1[[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'id'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'customer_name'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]], `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`left_on`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'customer_id'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`right_on`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'id'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`how`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'left'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`must-return-a-dataframe`,children:`Must Return a DataFrame`}),`\n`,_jsx(_components.p,{children:`Your code must return a DataFrame, not a Series or scalar. The last expression should be a DataFrame:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`8`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# ✅ Returns a DataFrame`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` data.copy()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`result[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'commission'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'revenue'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0.1`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`result`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# ❌ Returns a Series or scalar`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`data[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'revenue'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`data[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'revenue'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].sum()`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`example-2`,children:`Example`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Filter to high-revenue customers, then add a calculated column`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`filtered `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` data[data[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'revenue'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].copy()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`filtered[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'commission'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` filtered[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'revenue'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0.1`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`filtered`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Filters customers with revenue over $1,000, calculates a 10% commission, and returns the result.`}),`\n`,_jsx(Heading,{level:`3`,id:`sandbox-restrictions`,children:`Sandbox Restrictions`}),`\n`,_jsxs(_components.p,{children:[`For security, code runs in an isolated sandbox: no `,_jsx(_components.code,{children:`import`}),` statements (only the pre-imported `,_jsx(_components.code,{children:`pd`}),`, `,_jsx(_components.code,{children:`np`}),`, and `,_jsx(_components.code,{children:`fig`}),`), no `,_jsx(_components.code,{children:`exec`}),`/`,_jsx(_components.code,{children:`eval`}),`/`,_jsx(_components.code,{children:`compile`}),`, no filesystem or system access, and no network requests. If you need more, preprocess your data outside Go Fig and import it as a data source.`]}),`\n`,_jsx(Heading,{level:`2`,id:`tips`,children:`Tips`}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Test with small data first`}),`: In Python, use `,_jsx(_components.code,{children:`data.head()`}),` to develop against the first few rows before running on the full dataset.`]})}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`SQL vs Python`}),`: Use SQL for familiar queries and filtering. Use Python for row-wise iteration, custom functions, or pandas-specific operations.`]})}),`\n`,_jsxs(Warning,{children:[_jsxs(_components.p,{children:[`Always use `,_jsx(_components.code,{children:`.copy()`}),` when creating filtered DataFrames in Python to avoid `,_jsx(_components.code,{children:`SettingWithCopyWarning`}),`:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`filtered `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` data[data[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'revenue'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].copy()`})]}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`2`,id:`debugging`,children:`Debugging`}),`\n`,_jsx(_components.p,{children:`If your code isn’t behaving as expected:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Check column names`}),`: `,_jsx(_components.code,{children:`data.columns`}),` (Python) or `,_jsx(_components.code,{children:`SELECT * FROM data LIMIT 5`}),` (SQL)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Check data types`}),`: `,_jsx(_components.code,{children:`data.dtypes`}),` (Python)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Handle nulls`}),`: `,_jsx(_components.code,{children:`.fillna()`}),` (Python) or `,_jsx(_components.code,{children:`COALESCE()`}),` (SQL)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Build incrementally`}),`: test each part before adding complexity`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"SQL/Python","description":"Write custom SQL queries or Python scripts directly in your Go Fig flow for advanced transformations and logic","href":"/workflows/nodes/code"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"What This Node Does","slug":"what-this-node-does","depth":2,"children":[]},{"title":"When to Use This Node","slug":"when-to-use-this-node","depth":2,"children":[]},{"title":"Language Toggle","slug":"language-toggle","depth":2,"children":[]},{"title":"SQL Mode","slug":"sql-mode","depth":2,"children":[{"title":"Joining Multiple Parents","slug":"joining-multiple-parents","depth":3,"children":[]},{"title":"Example","slug":"example","depth":3,"children":[]}]},{"title":"Python Mode","slug":"python-mode","depth":2,"children":[{"title":"Joining Multiple Parents","slug":"joining-multiple-parents-2","depth":3,"children":[]},{"title":"Must Return a DataFrame","slug":"must-return-a-dataframe","depth":3,"children":[]},{"title":"Example","slug":"example-2","depth":3,"children":[]},{"title":"Sandbox Restrictions","slug":"sandbox-restrictions","depth":3,"children":[]}]},{"title":"Tips","slug":"tips","depth":2,"children":[]},{"title":"Debugging","slug":"debugging","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"gofig","siteName":"Go Fig Documentation","title":"SQL/Python - Go Fig Documentation","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-29T21:56:18.694Z","originalFileLocation":"workflows/nodes/code.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Write custom SQL queries or Python scripts directly in your Go Fig flow for advanced transformations and logic\">\u003cmeta data-mint-head name=\"application-name\" content=\"Go Fig Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/gofig/IrgIkHyt3SwCl1f5/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/gofig/IrgIkHyt3SwCl1f5/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/gofig/IrgIkHyt3SwCl1f5/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/gofig/IrgIkHyt3SwCl1f5/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/gofig/IrgIkHyt3SwCl1f5/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/gofig/IrgIkHyt3SwCl1f5/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/gofig/IrgIkHyt3SwCl1f5/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/gofig/IrgIkHyt3SwCl1f5/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/gofig/IrgIkHyt3SwCl1f5/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"SQL/Python - Go Fig Documentation\">\u003cmeta data-mint-head property=\"og:description\" content=\"Write custom SQL queries or Python scripts directly in your Go Fig flow for advanced transformations and logic\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Go Fig Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.gofig.ai/workflows/nodes/code\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://gofig.mintlify.site/_mintlify/api/og/v2?division=Process\u0026amp;title=SQL%2FPython\u0026amp;description=Write+custom+SQL+queries+or+Python+scripts+directly+in+your+Go+Fig+flow+for+advanced+transformations+and+logic\u0026amp;theme=2ebe9092a589ee1a0115b6f9\u0026amp;signature=b2d10d388787e050deb679b06bbd375702b71428e597d6c0eb0553e667c1f7cb\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"SQL/Python - Go Fig Documentation\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Write custom SQL queries or Python scripts directly in your Go Fig flow for advanced transformations and logic\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://gofig.mintlify.site/_mintlify/api/og/v2?division=Process\u0026amp;title=SQL%2FPython\u0026amp;description=Write+custom+SQL+queries+or+Python+scripts+directly+in+your+Go+Fig+flow+for+advanced+transformations+and+logic\u0026amp;theme=2ebe9092a589ee1a0115b6f9\u0026amp;signature=b2d10d388787e050deb679b06bbd375702b71428e597d6c0eb0553e667c1f7cb\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/gofig/IrgIkHyt3SwCl1f5/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Go Fig Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#0EA5E9\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.gofig.ai/workflows/nodes/code\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/workflows/nodes/code.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.gofig.ai/#organization\",\"name\":\"Go Fig Documentation\",\"url\":\"https://docs.gofig.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/gofig/1F70rJ09g-reP40S/logo/full_logo_h.png?fit=max\u0026auto=format\u0026n=1F70rJ09g-reP40S\u0026q=85\u0026s=4ed68f93c9deb5b8a64380d54793646b\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.gofig.ai#website\",\"name\":\"Go Fig Documentation\",\"url\":\"https://docs.gofig.ai\",\"publisher\":{\"@id\":\"https://docs.gofig.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.gofig.ai/workflows/nodes/code#webpage\",\"url\":\"https://docs.gofig.ai/workflows/nodes/code\",\"name\":\"SQL/Python\",\"description\":\"Write custom SQL queries or Python scripts directly in your Go Fig flow for advanced transformations and logic\",\"dateModified\":\"2026-09-29T21:56:18.694Z\",\"isPartOf\":{\"@id\":\"https://docs.gofig.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.gofig.ai/workflows/nodes/code#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.gofig.ai/workflows/nodes/code#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Flows\",\"item\":\"https://docs.gofig.ai/workflows/building-workflows\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nodes\",\"item\":\"https://docs.gofig.ai/workflows/nodes/get-data\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Process\",\"item\":\"https://docs.gofig.ai/workflows/nodes/transform\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"SQL/Python\",\"item\":\"https://docs.gofig.ai/workflows/nodes/code\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.gofig.ai/workflows/nodes/code#article\",\"headline\":\"SQL/Python\",\"name\":\"SQL/Python\",\"description\":\"Write custom SQL queries or Python scripts directly in your Go Fig flow for advanced transformations and logic\",\"url\":\"https://docs.gofig.ai/workflows/nodes/code\",\"mainEntityOfPage\":{\"@id\":\"https://docs.gofig.ai/workflows/nodes/code#webpage\"},\"dateModified\":\"2026-09-29T21:56:18.694Z\",\"publisher\":{\"@id\":\"https://docs.gofig.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.gofig.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Go Fig Documentation\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Go Fig Documentation","nav":{"global":{"anchors":[{"anchor":"Documentation","icon":"book-open","href":"https://docs.gofig.ai"},{"anchor":"Security Hub","icon":"shield-check","href":"https://gofig.ai/security"},{"anchor":"Slack Community","icon":"slack","href":"https://join.slack.com/t/gofigapp/shared_invite/zt-2iagi9ol2-aRD7XmodFJ4c9QFzOQHhdg"},{"anchor":"Contact Support","icon":"life-ring","href":"https://gofig.ai/demo"}]},"tabs":[{"tab":"Guides","groups":[{"group":"Getting started","pages":[{"title":"Getting started with Go Fig","icon":"rocket","href":""},{"title":"Connecting to your data","icon":"link","href":"/getting-started/connecting-data"},{"title":"Navigating the App","icon":"compass","href":"/getting-started/navigating-the-app"},{"title":"Pivoting Data","icon":"magnifying-glass-chart","href":"/getting-started/pivoting-data"},{"title":"Celeste AI Assistant","icon":"sparkles","href":"/getting-started/celeste"},{"title":"Celeste AI usage and controls","icon":"sliders","href":"/getting-started/celeste-ai-usage"},{"title":"Signal","icon":"signal","href":"/getting-started/signal"},{"group":"Connect your AI (MCP)","pages":[{"title":"Connect your AI (MCP)","icon":"robot","href":"/getting-started/mcp"},{"title":"Enable MCP for your Organization","icon":"shield-check","href":"/getting-started/mcp-org-settings"},{"title":"Connect your AI via MCP","icon":"plug","href":"/getting-started/ai-connector"},{"title":"Using Go Fig with Claude for Excel","icon":"table","href":"/getting-started/claude-for-excel"}]}]},{"group":"Flows","pages":[{"title":"Building a flow","icon":"sitemap","href":"/workflows/building-workflows"},{"group":"Nodes","pages":[{"group":"Input","pages":[{"title":"Get Data","icon":"database","href":"/workflows/nodes/get-data"},{"title":"Import Data","icon":"cloud-upload","href":"/workflows/nodes/import-data"}]},{"group":"Process","pages":[{"title":"Transform","icon":"table","href":"/workflows/nodes/transform"},{"title":"AI Enrichment","description":"Use AI to add new fields to your data: classify, extract, or generate text per row","icon":"sparkles","href":"/workflows/nodes/ai-enrichment"},{"title":"SQL/Python","href":"/workflows/nodes/code"},{"title":"Fig Helpers","description":"Go Fig's built-in Python helper library for the Code node: fuzzy matching, fiscal year conversion, z-scores, safe percentage change, and deduplication.","icon":"wand-magic-sparkles","href":"/workflows/nodes/fig-helpers"},{"title":"Forecast","icon":"circle-nodes","href":"/workflows/nodes/forecast"},{"title":"Segment","icon":"circle-nodes","href":"/workflows/nodes/segment"}]},{"group":"Merge","pages":[{"title":"XLOOKUP","icon":"link","href":"/workflows/nodes/xlookup"},{"title":"Append","icon":"layer-group","href":"/workflows/nodes/append"}]},{"group":"Output","pages":[{"title":"Save Table","icon":"download","href":"/workflows/nodes/save-table"},{"title":"Chart","icon":"chart-pie","href":"/workflows/nodes/chart"},{"title":"AI Summary","icon":"sparkles","href":"/workflows/nodes/ai-summary"}]},{"group":"Tools","pages":[{"title":"Note","icon":"note-sticky","href":"/workflows/nodes/note"},{"title":"Scenarios","icon":"tags","href":"/workflows/nodes/scenarios"}]}]},{"title":"Exporting data","icon":"file-export","href":"/workflows/exporting-data"},{"title":"Celeste flow tips","icon":"sparkles","href":"/workflows/ai-tips"}]},{"group":"Dashboards","pages":[{"title":"Building Dashboards","icon":"chart-line","href":"/dashboards/building-dashboards"},{"title":"Charts","icon":"chart-pie","href":"/dashboards/charts"},{"title":"Text and Media","icon":"text","href":"/dashboards/text-and-media"},{"title":"Sharing Dashboards","icon":"share-nodes","href":"/dashboards/sharing"}]},{"group":"Collaboration","pages":[{"title":"Sharing projects","icon":"folder-open","href":"/collaboration/sharing-projects"},{"title":"Publishing analysis","icon":"megaphone","href":"/collaboration/publishing"},{"title":"Access control","icon":"shield","href":"/collaboration/access-control"}]},{"group":"Embedded analytics","pages":[{"title":"Embedded analytics","icon":"frame","href":"/embedded/embedded-analytics"}]}]},{"tab":"Integrations","pages":[{"title":"Integrations","href":"/connectors/databases/snowflake"}]}]},"basePath":"","title":"SQL/Python - Go Fig Documentation","buildId":"dpl_8LJbrAiZvr1K98WQNZXCyY5AvT34","deploymentId":"dpl_8LJbrAiZvr1K98WQNZXCyY5AvT34","dynamics":["07c022d89b","a74be98ba7"],"chunks":["Frame-NdetNziF.js","DynamicMarkdown-CD8713Yy.js","zoom-image-lightbox-DMoL6lHz.js","lightbox-handle-r17bVUz3.js"]}