You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/09/22 01:25:00 UTC
(superset) branch master updated: fix(sqllab): restore SQL code folding (#44236)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 1b8800c84d1 fix(sqllab): restore SQL code folding (#44236)
1b8800c84d1 is described below
commit 1b8800c84d1f1b09209400965133f071d8fc1812
Author: Endi Monan <65...@users.noreply.github.com>
AuthorDate: Tue Sep 22 03:24:52 2026 +0200
fix(sqllab): restore SQL code folding (#44236)
Co-authored-by: Joe Li <jo...@preset.io>
---
docs/docs/using-superset/exploring-data.mdx | 2 ++
.../AsyncAceEditor/AsyncAceEditor.test.tsx | 33 ++++++++++++++++++++++
.../src/components/AsyncAceEditor/index.tsx | 4 +--
.../superset-ui-core/types/ace-builds.d.ts | 1 +
4 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/docs/docs/using-superset/exploring-data.mdx b/docs/docs/using-superset/exploring-data.mdx
index 9fd758cabc1..5b3b7cce3f8 100644
--- a/docs/docs/using-superset/exploring-data.mdx
+++ b/docs/docs/using-superset/exploring-data.mdx
@@ -370,6 +370,8 @@ tutorial dashboard to see the four charts side by side and compare the different
**Resizable panels**: The dividers between the SQL editor, schema browser, and results pane are draggable. Adjust them to match your workflow and screen size.
+**Code folding**: In the built-in Ace editor, use the arrows beside the line numbers to collapse or expand multiline parenthesized queries and block comments. Folding hides those lines without changing the SQL.
+
**Dialect-aware Format SQL**: The **Format SQL** button applies the SQL dialect of the currently selected database — Trino, Presto, MySQL, PostgreSQL, etc. — rather than a generic formatter. Switch to a different database in the toolbar and re-format to get dialect-specific output. Jinja template syntax (`{{ }}`, `{% %}`) is preserved during formatting and will not cause format errors.
### Time Range Natural Language Expressions
diff --git a/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx
index 0af0e62cff2..0ab1d697845 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/AsyncAceEditor.test.tsx
@@ -351,6 +351,39 @@ test('renders FullSQLEditor', async () => {
});
});
+test.each([
+ ['SQLEditor', SQLEditor],
+ ['FullSQLEditor', FullSQLEditor],
+])('%s folds SQL blocks without changing the query', async (_, Editor) => {
+ const ref = createRef<AceEditor>();
+ const sql = [
+ 'WITH nested_query AS (',
+ ' SELECT 1 AS value',
+ ')',
+ 'SELECT * FROM nested_query;',
+ '/* multi-line',
+ ' comment */',
+ ].join('\n');
+ render(<Editor ref={ref as React.Ref<never>} defaultValue={sql} />);
+ await waitFor(() => expect(ref.current).not.toBeNull());
+
+ const { session } = ref.current!.editor;
+ expect(session.getFoldWidget(0)).toBe('start');
+ expect(session.getFoldWidget(4)).toBe('start');
+ session.foldAll();
+ expect(session.getAllFolds().map(fold => fold.start.row)).toEqual([0, 4]);
+ expect(session.getValue()).toBe(sql);
+
+ session.unfold();
+ expect(session.getAllFolds()).toHaveLength(0);
+ expect(session.getValue()).toBe(sql);
+ expect(session.getTokens(3)).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({ type: 'keyword', value: 'SELECT' }),
+ ]),
+ );
+});
+
test('renders MarkdownEditor', async () => {
const { container } = render(<MarkdownEditor />);
diff --git a/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/index.tsx
index 2165426d5ee..7fbdb57b484 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/index.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/index.tsx
@@ -81,11 +81,11 @@ export interface AceCompleterKeyword extends AceCompleterKeywordData {
}
/**
- * Async loaders to import brace modules. Must manually create call `import(...)`
+ * Async loaders to import Ace modules. Must manually create call `import(...)`
* promises because webpack can only analyze async imports statically.
*/
export const aceModuleLoaders = {
- 'mode/sql': () => import('brace/mode/sql'),
+ 'mode/sql': () => import('ace-builds/src-min-noconflict/mode-sql'),
'mode/markdown': () => import('brace/mode/markdown'),
'mode/css': () => import('brace/mode/css'),
'mode/json': () => import('brace/mode/json'),
diff --git a/superset-frontend/packages/superset-ui-core/types/ace-builds.d.ts b/superset-frontend/packages/superset-ui-core/types/ace-builds.d.ts
index 63890d0e61a..5013dabeb15 100644
--- a/superset-frontend/packages/superset-ui-core/types/ace-builds.d.ts
+++ b/superset-frontend/packages/superset-ui-core/types/ace-builds.d.ts
@@ -20,3 +20,4 @@ declare module 'ace-builds/src-min-noconflict/worker-css';
declare module 'ace-builds/src-min-noconflict/worker-javascript';
declare module 'ace-builds/src-min-noconflict/worker-html';
declare module 'ace-builds/src-min-noconflict/ace';
+declare module 'ace-builds/src-min-noconflict/mode-sql';