File tree Expand file tree Collapse file tree 9 files changed +47
-10
lines changed
Expand file tree Collapse file tree 9 files changed +47
-10
lines changed Original file line number Diff line number Diff line change 9898 - name : Lint
9999 run : |
100100 python -m pip install --upgrade pip
101- python -m pip install --upgrade pkgmt codespell nox
101+ python -m pip install --upgrade pkgmt nox
102102 pkgmt lint
103- codespell
104103
105104 - name : Install dependencies
106105 run : |
@@ -113,7 +112,7 @@ jobs:
113112 nox --session test_unit --no-install --reuse-existing-virtualenvs
114113
115114 - name : Upload failed images artifacts
116- uses : actions/upload-artifact@v3
115+ uses : actions/upload-artifact@v4
117116 if : failure()
118117 with :
119118 name : failed-image-artifacts ${{ matrix.os }} ${{ matrix.python-version }}
@@ -158,7 +157,7 @@ jobs:
158157 nox --session test_unit_sqlalchemy_one --no-install --reuse-existing-virtualenvs
159158
160159 - name : Upload failed images artifacts sqlalchemyv1
161- uses : actions/upload-artifact@v3
160+ uses : actions/upload-artifact@v4
162161 if : failure()
163162 with :
164163 name : failed-image-artifacts-sqlalchemy ${{ matrix.os }} ${{ matrix.python-version }}
Original file line number Diff line number Diff line change 2121sphinx :
2222 builder : html
2323 fail_on_warning : true
24+ configuration : doc/_config.yml
Original file line number Diff line number Diff line change 11# CHANGELOG
22
3- ## 0.10.18dev
3+ ## 0.11.0dev
4+
5+ * [ API Change] Disabled ` %sql ` and ` %%sql ` on Databricks ([ #1047 ] ( https://github.com/ploomber/jupysql/issues/1047 ) )
46
57## 0.10.17 (2025-01-08)
68
Original file line number Diff line number Diff line change @@ -361,7 +361,9 @@ some_engine = create_engine("sqlite:///some.db")
361361
362362## Use ` %sql ` /` %%sql ` in Databricks
363363
364- Databricks uses the same name (` %sql ` /` %%sql ` ) for its SQL magics; however, JupySQL exposes a ` %jupysql ` /` %%jupysql ` alias so you can use both:
364+ Databricks uses the same name (` %sql ` /` %%sql ` ) for its SQL magics; however, since this
365+ clashes with Databricks' ` %%sql ` command, JupySQL will enable an ` %jupysql ` /` %%jupysql `
366+ alias if a ` DATABRICKS_RUNTIME_VERSION ` is declared:
365367
366368``` {code-cell} ipython3
367369%jupysql duckdb://
Original file line number Diff line number Diff line change 1- """Renter large-table-template.sql
2- """
1+ """Renter large-table-template.sql"""
32
43from pathlib import Path
54from jinja2 import Template
Original file line number Diff line number Diff line change 11from sql .magic import load_ipython_extension
22
33
4- __version__ = "0.10.18dev "
4+ __version__ = "0.11.0dev "
55
66
77__all__ = ["load_ipython_extension" ]
Original file line number Diff line number Diff line change 77
88class Column (list ):
99 "Store a column of tabular data; record its name and whether it is numeric"
10+
1011 is_quantity = True
1112 name = ""
1213
Original file line number Diff line number Diff line change 11import json
2+ import os
23import re
34from pathlib import Path
45
@@ -704,7 +705,7 @@ def get_query_type(command: str):
704705
705706def set_configs (ip , file_path , alternate_path ):
706707 """Set user defined SqlMagic configuration settings"""
707- sql = ip .find_cell_magic ("sql " ).__self__
708+ sql = ip .find_cell_magic ("jupysql " ).__self__
708709 user_configs , loaded_from = util .get_user_configs (file_path , alternate_path )
709710 default_configs = util .get_default_configs (sql )
710711 table_rows = []
@@ -769,6 +770,12 @@ def load_SqlMagic_configs(ip):
769770
770771def load_ipython_extension (ip ):
771772 """Load the magics, this function is executed when the user runs: %load_ext sql"""
773+
774+ # If running within Databricks, do not use the sql magics
775+ if "DATABRICKS_RUNTIME_VERSION" in os .environ :
776+ del SqlMagic .magics ["cell" ]["sql" ]
777+ del SqlMagic .magics ["line" ]["sql" ]
778+
772779 sql_magic = SqlMagic (ip )
773780 _set_sql_magic (sql_magic )
774781 ip .register_magics (sql_magic )
Original file line number Diff line number Diff line change 2323from sql .run .resultset import ResultSet
2424from sql import magic
2525from sql .warnings import JupySQLQuotedNamedParametersWarning
26+ from sql ._testing import TestingShell
27+ from sql .magic import load_ipython_extension
2628
2729
2830from conftest import runsql
@@ -2767,3 +2769,27 @@ def test_disabled_named_parameters_shows_disabled_warning(ip):
27672769 )
27682770
27692771 assert expected_warning in str (excinfo .value )
2772+
2773+
2774+ @pytest .mark .skip (
2775+ reason = (
2776+ "Running this breaks all subsequent tests because "
2777+ "TestingShell is a singleton. We need to find a way to isolate this test"
2778+ )
2779+ )
2780+ def test_databricks_sql_magic_disabled (monkeypatch ):
2781+ monkeypatch .setenv ("DATABRICKS_RUNTIME_VERSION" , "10.0.0" )
2782+ ip = TestingShell .preconfigured_shell ()
2783+ load_ipython_extension (ip )
2784+
2785+ ip .run_cell ("%jupysql duckdb://" )
2786+ ip .run_cell ("%jupysql select 1" )
2787+
2788+ with pytest .raises (UsageError ) as excinfo_line :
2789+ ip .run_cell ("%sql select 1" )
2790+
2791+ with pytest .raises (UsageError ) as excinfo_cell :
2792+ ip .run_cell ("%%sql\n select 1" )
2793+
2794+ assert "Line magic function `%sql` not found" in str (excinfo_line .value )
2795+ assert "Cell magic `%%sql` not found" in str (excinfo_cell .value )
You can’t perform that action at this time.
0 commit comments