/* Databricks SQL lab */ function DatabricksPage({ tweaks, onBackHome }) { const primary = tweaks.primaryColor; const [code, setCode] = React.useState(''); const [unlocked, setUnlocked] = React.useState(false); const [unlockLoading, setUnlockLoading] = React.useState(false); const [unlockError, setUnlockError] = React.useState(''); const [jdbcUrl, setJdbcUrl] = React.useState(DEFAULT_DATABRICKS_JDBC_URL); const [token, setToken] = React.useState(''); const [statement, setStatement] = React.useState(DEFAULT_DATABRICKS_QUERY); const [rowLimit, setRowLimit] = React.useState(50); const [loading, setLoading] = React.useState(false); const [error, setError] = React.useState(''); const [result, setResult] = React.useState(null); const parsed = React.useMemo(() => { try { return parseDatabricksJdbcUrlPreview(jdbcUrl); } catch (err) { return { error: err.message }; } }, [jdbcUrl]); const canRun = !loading && !parsed.error && token.trim() && statement.trim(); const unlock = async (candidateCode) => { const trimmedCode = candidateCode.trim(); setUnlockLoading(true); setUnlockError(''); try { await verifyJourneyCode(trimmedCode); sessionStorage.setItem(JOURNEY_CODE_STORAGE_KEY, trimmedCode); setCode(trimmedCode); setUnlocked(true); } catch (err) { sessionStorage.removeItem(JOURNEY_CODE_STORAGE_KEY); setUnlocked(false); setUnlockError(err.message === 'Invalid code' ? 'Code is not correct.' : err.message); } finally { setUnlockLoading(false); } }; React.useEffect(() => { const savedCode = sessionStorage.getItem(JOURNEY_CODE_STORAGE_KEY); if (savedCode) unlock(savedCode); }, []); const runQuery = async (event) => { event.preventDefault(); if (!canRun) return; setLoading(true); setError(''); setResult(null); try { const response = await fetch('/api/databricks/query', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jdbcUrl, token, statement, rowLimit, code, }), }); const payload = await response.json().catch(() => null); if (!response.ok || !payload?.ok) { throw new Error(payload?.error || 'Databricks query failed.'); } setResult(payload); } catch (err) { setError(err.message || 'Databricks query failed.'); } finally { setLoading(false); } }; if (!unlocked) { return (
Private Databricks lab

Databricks SQL Lab

Uses the Journey code before opening the Databricks SQL runner.

{ event.preventDefault(); unlock(code); }} style={{ display: 'flex', flexDirection: 'column', gap: 14 }}> setCode(event.target.value)} placeholder="32-character secret code" autoComplete="off" spellCheck="false" style={databricksFieldStyle()} /> {unlockError && (
{unlockError}
)}
); } return (
Admin workspace

Databricks SQL Lab

Practice with your Databricks JDBC details through a server proxy to the SQL Statement Execution API.

Connection

JDBC URL is parsed here; token is never saved.