File tree 2 files changed +38
-3
lines changed
2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -602,7 +602,7 @@ def create_table(
602
602
* ,
603
603
schema : sch .SchemaLike | None = None ,
604
604
database : str | None = None ,
605
- temp : bool = False ,
605
+ temp : bool | None = None ,
606
606
overwrite : bool = False ,
607
607
) -> ir .Table :
608
608
"""Create a new table.
@@ -682,7 +682,7 @@ def create_table(
682
682
raw_table = sg .table (temp_name , catalog = catalog , db = db , quoted = False )
683
683
target = sge .Schema (
684
684
this = sg .table (
685
- "#" * temp + temp_name , catalog = catalog , db = db , quoted = quoted
685
+ "#" * bool ( temp ) + temp_name , catalog = catalog , db = db , quoted = quoted
686
686
),
687
687
expressions = schema .to_sqlglot (self .dialect ),
688
688
)
@@ -701,7 +701,7 @@ def create_table(
701
701
# for the subsequent `Insert`, so we need to shove a `#` in
702
702
# front of the table identifier.
703
703
_table = sg .table (
704
- "##" * temp + temp_name ,
704
+ "##" * bool ( temp ) + temp_name ,
705
705
catalog = catalog ,
706
706
db = db ,
707
707
quoted = self .compiler .quoted ,
Original file line number Diff line number Diff line change 18
18
MSSQL_PYODBC_DRIVER ,
19
19
MSSQL_USER ,
20
20
)
21
+ from ibis .backends .tests .errors import PyODBCProgrammingError
22
+ from ibis .util import gen_name
21
23
22
24
RAW_DB_TYPES = [
23
25
# Exact numbers
@@ -259,3 +261,36 @@ def test_dot_sql_with_unnamed_columns(con):
259
261
260
262
df = expr .execute ()
261
263
assert len (df ) == 1
264
+
265
+
266
+ @pytest .mark .parametrize (
267
+ "temp" ,
268
+ [
269
+ param (
270
+ True ,
271
+ marks = pytest .mark .xfail (
272
+ raises = PyODBCProgrammingError ,
273
+ reason = "dropping temp tables isn't implemented" ,
274
+ ),
275
+ ),
276
+ False ,
277
+ None ,
278
+ ],
279
+ ids = [
280
+ "temp" ,
281
+ "no-temp" ,
282
+ "no-temp-none" ,
283
+ ],
284
+ )
285
+ def test_create_temp_table (con , temp ):
286
+ t = con .create_table (
287
+ name := gen_name ("mssql_delete_me" ),
288
+ schema = {"a" : "int" },
289
+ temp = temp ,
290
+ )
291
+ try :
292
+ assert int (t .count ().execute ()) == 0
293
+ assert t .schema () == ibis .schema ({"a" : "int" })
294
+ assert t .columns == ("a" ,)
295
+ finally :
296
+ con .drop_table (name )
You can’t perform that action at this time.
0 commit comments