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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: dont show sql keywords when completion `.column_name` (#4453)
Myles Scolnick240ead590235
diff --git a/frontend/src/core/codemirror/language/sql.ts b/frontend/src/core/codemirror/language/sql.tsindex 1eefb2d416..a477d1d947 100644--- a/frontend/src/core/codemirror/language/sql.ts+++ b/frontend/src/core/codemirror/language/sql.ts@@ -35,6 +35,7 @@ import {MySQL,SQLite,MSSQL,+ keywordCompletionSource,} from "@codemirror/lang-sql";import { LRUCache } from "@/utils/lru";import type { DataSourceConnection } from "@/core/kernel/messages";@@ -173,6 +174,7 @@ export class SQLLanguageAdapter implements LanguageAdapter {_completionConfig: CompletionConfig,_hotkeys: HotkeyProvider,): Extension[] {+ const keywordCompletion = keywordCompletionSource(StandardSQL);return [sql({dialect: StandardSQL,@@ -182,9 +184,23 @@ export class SQLLanguageAdapter implements LanguageAdapter {// handles the Escape key correctly in VimdefaultKeymap: false,activateOnTyping: true,- }),- StandardSQL.language.data.of({- autocomplete: tablesCompletionSource(this),+ override: [+ tablesCompletionSource(this),+ (ctx) => {+ // We want to ignore keyword completions on something like+ // `WHERE my_table.col`+ // ^cursor+ const textBefore = ctx.matchBefore(/\.\w*/);+ if (textBefore) {+ // If there is a match, we are typing after a dot,+ // so we don't want to trigger SQL keyword completion+ return null;+ }++ const result = keywordCompletion(ctx);+ return result;+ },+ ],}),];}diff --git a/marimo/_data/get_datasets.py b/marimo/_data/get_datasets.pyindex 0799557054..ed081fb608 100644--- a/marimo/_data/get_datasets.py+++ b/marimo/_data/get_datasets.py@@ -233,6 +233,7 @@ def _db_type_to_data_type(db_type: str) -> DataType:return "time"if db_type in ["timestamp",+ "timestamp_ns","timestamp with time zone","timestamptz","datetime",diff --git a/marimo/_runtime/runner/hooks_post_execution.py b/marimo/_runtime/runner/hooks_post_execution.pyindex b5a10979cd..d7f9c19f3d 100644--- a/marimo/_runtime/runner/hooks_post_execution.py+++ b/marimo/_runtime/runner/hooks_post_execution.py@@ -324,17 +324,13 @@ def _broadcast_outputs(# don't clear console because this cell was running and# its console outputs are not staleexception_type = type(run_result.exception).__name__+ msg = str(run_result.exception)+ if not msg:+ msg = f"This cell raised an exception: {exception_type}"CellOp.broadcast_error(data=[MarimoExceptionRaisedError(- msg="This cell raised an exception: {}{}".format(- exception_type,- (- f"('{str(run_result.exception)}')"- if str(run_result.exception)- else ""- ),- ),+ msg=msg,exception_type=exception_type,raising_cell=None,)diff --git a/tests/_cli/test_cli_export.py b/tests/_cli/test_cli_export.pyindex 83402f8549..d24713e50d 100644--- a/tests/_cli/test_cli_export.py+++ b/tests/_cli/test_cli_export.py@@ -248,7 +248,7 @@ class TestExportHTML:assert p.returncode != 0, p.stderr.decode()html = normalize_index_html(p.stdout.decode())# Errors but still produces HTML- assert "ZeroDivisionError" in p.stderr.decode()+ assert " division by zero" in p.stderr.decode()assert "<marimo-code" in html@staticmethod@@ -866,7 +866,7 @@ class TestExportIpynb:capture_output=True,)assert p.returncode != 0, p.stderr.decode()- assert "ZeroDivisionError" in p.stderr.decode()+ assert " division by zero" in p.stderr.decode()output = p.stdout.decode()output = _delete_lines_with_files(output)snapshot("ipynb_with_errors.txt", output)diff --git a/tests/_runtime/test_runtime.py b/tests/_runtime/test_runtime.pyindex 8a71ab88ac..b20779978c 100644--- a/tests/_runtime/test_runtime.py+++ b/tests/_runtime/test_runtime.py@@ -2963,10 +2963,8 @@ class TestErrorHandling:assert len(errors) == 1assert errors[0].type == "exception"- assert (- errors[0].msg- == "This cell raised an exception: ValueError('some secret error')"- )+ assert errors[0].msg == "some secret error"+ assert errors[0].exception_type == "ValueError"async def test_error_handling_in_run_mode(self, run_mode_kernel: MockedKernel, exec_req: ExecReqProviderdiff --git a/tests/_server/export/snapshots/run_until_completion_with_stack_trace.txt b/tests/_server/export/snapshots/run_until_completion_with_stack_trace.txtindex 0c5705ad8b..25f1bd7e33 100644--- a/tests/_server/export/snapshots/run_until_completion_with_stack_trace.txt+++ b/tests/_server/export/snapshots/run_until_completion_with_stack_trace.txt@@ -16,7 +16,7 @@{"output": [{- "msg": "This cell raised an exception: ValueError('Failed to authenticate. The correct password is 's3cret'.')",+ "msg": "Failed to authenticate. The correct password is 's3cret'.","exception_type": "ValueError","raising_cell": null,"type": "exception"diff --git a/tests/_server/export/snapshots/run_until_completion_with_stack_trace_py313.txt b/tests/_server/export/snapshots/run_until_completion_with_stack_trace_py313.txtdeleted file mode 100644index d85fcbbc38..0000000000--- a/tests/_server/export/snapshots/run_until_completion_with_stack_trace_py313.txt+++ /dev/null@@ -1,30 +0,0 @@-[- {- "output": "",- "console": [- "running internal tests\n"- ],- "status": "idle"- },- {- "output": "<pre style='font-size: 12px'>15</pre>",- "console": [- "internal error\n"- ],- "status": "idle"- },- {- "output": [- {- "msg": "This cell raised an exception: ValueError('Failed to authenticate. The correct password is [REDACTED]')",- "exception_type": "ValueError",- "raising_cell": null,- "type": "exception"- }- ],- "console": [- "<span class=\"codehilite\"><div class=\"highlight\"><pre><span></span><span class=\"gt\">Traceback (most recent call last):</span>\n "</span>, line <span class=\"m\">3</span>, in <span class=\"n\"><module></span>\n<span class=\"w\"> </span><span class=\"k\">raise</span> <span class=\"ne\">ValueError</span><span class=\"p\">(</span>\n<span class=\"w\"> </span> <span class=\"s2\">"Failed to authenticate. The correct password is '[REDACTED]'."</span>\n<span class=\"w\"> </span><span class=\"p\">)</span>\n<span class=\"gr\">ValueError</span>: <span class=\"n\">Failed to authenticate. The correct password is '[REDACTED]'.</span>\n</pre></div>\n</span>"- ],- "status": "idle"- }-]