:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(sql-editor): add a json viewer to json columns (#94447)
Fernando Gomesdbdd40a1ca07
diff --git a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsxindex b4d70433e49c..dada41ff03f7 100644--- a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx+++ b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx@@ -34,6 +34,7 @@ import { Link } from 'lib/lemon-ui/Link'import { LoadingBar } from 'lib/lemon-ui/LoadingBar'import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'import { copyToClipboard } from 'lib/utils/copyToClipboard'+import { tryJsonParse } from 'lib/utils/json'import { InsightErrorState, StatelessInsightLoadingState } from 'scenes/insights/EmptyStates'import { insightLogic } from 'scenes/insights/insightLogic'import { HogQLBoldNumber } from 'scenes/insights/views/BoldNumber/BoldNumber'@@ -622,6 +623,7 @@ export function OutputPane({ tabId, showToolbar = true, biMode = false, onShareTconst vizKey = useMemo(() => `SQLEditorScene`, [])const [selectedRow, setSelectedRow] = useState<Record<string, any> | null>(null)+ const [selectedJson, setSelectedJson] = useState<object | null>(null)const setProgress = useCallback((loadId: string, progress: number) => {setProgressCache((prev) => ({ ...prev, [loadId]: progress }))@@ -741,7 +743,23 @@ export function OutputPane({ tabId, showToolbar = true, biMode = false, onShareTreturn <TZLabel time={value} timestampStyle="absolute" />}- return value+ const parsedJson: unknown =+ typeof value === 'string' && cleanClickhouseType(type) === 'String'+ ? tryJsonParse(value)+ : null+ if (!parsedJson || typeof parsedJson !== 'object') {+ return value+ }++ return (+ <button+ type="button"+ className="block h-full w-full truncate text-left"+ onClick={() => setSelectedJson(parsedJson)}+ >+ {value}+ </button>+ )},}}) ?? []),@@ -912,6 +930,11 @@ export function OutputPane({ tabId, showToolbar = true, biMode = false, onShareTcolumns={response?.columns || []}columnKeys={response?.columns?.map((column: string, index: number) => `${column}_${index}`) || []}/>+ <LemonModal title="JSON" isOpen={selectedJson !== null} onClose={() => setSelectedJson(null)} width={800}>+ <pre className="max-h-[70vh] overflow-auto whitespace-pre-wrap break-words font-mono">+ {selectedJson ? JSON.stringify(selectedJson, null, 2) : ''}+ </pre>+ </LemonModal></div>)}