Skip to content

Commit 4005225

Browse files
committed
add test
1 parent 43f9045 commit 4005225

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

python/tests/test_expr.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
2929
Projection,
3030
Sort,
3131
TableScan,
32+
CopyTo,
33+
CreateIndex,
34+
DescribeTable,
35+
DmlStatement,
36+
DropCatalogSchema,
37+
RecursiveQuery,
38+
TransactionEnd,
39+
TransactionStart,
40+
Values,
3241
)
3342

3443

@@ -247,3 +256,80 @@ def test_fill_null(df):
247256
assert result.column(0) == pa.array([1, 2, 100])
248257
assert result.column(1) == pa.array([4, 25, 6])
249258
assert result.column(2) == pa.array([1234, 1234, 8])
259+
260+
261+
def test_copy_to():
262+
ctx = SessionContext()
263+
ctx.sql("CREATE TABLE foo (a int, b int)").collect()
264+
df = ctx.sql("COPY foo TO bar STORED AS CSV")
265+
plan = df.logical_plan()
266+
plan = plan.to_variant()
267+
assert isinstance(plan, CopyTo)
268+
269+
270+
def test_create_index():
271+
ctx = SessionContext()
272+
ctx.sql("CREATE TABLE foo (a int, b int)").collect()
273+
plan = ctx.sql("create index idx on foo (a)").logical_plan()
274+
plan = plan.to_variant()
275+
assert isinstance(plan, CreateIndex)
276+
277+
278+
def test_describe_table():
279+
ctx = SessionContext()
280+
ctx.sql("CREATE TABLE foo (a int, b int)").collect()
281+
plan = ctx.sql("describe foo").logical_plan()
282+
plan = plan.to_variant()
283+
assert isinstance(plan, DescribeTable)
284+
285+
286+
def test_dml_statement():
287+
ctx = SessionContext()
288+
ctx.sql("CREATE TABLE foo (a int, b int)").collect()
289+
plan = ctx.sql("insert into foo values (1, 2)").logical_plan()
290+
plan = plan.to_variant()
291+
assert isinstance(plan, DmlStatement)
292+
293+
294+
def drop_catalog_schema():
295+
ctx = SessionContext()
296+
plan = ctx.sql("drop schema cat").logical_plan()
297+
plan = plan.to_variant()
298+
assert isinstance(plan, DropCatalogSchema)
299+
300+
301+
def test_recursive_query():
302+
ctx = SessionContext()
303+
plan = ctx.sql(
304+
"""
305+
WITH RECURSIVE cte AS (
306+
SELECT 1 as n
307+
UNION ALL
308+
SELECT n + 1 FROM cte WHERE n < 5
309+
)
310+
SELECT * FROM cte;
311+
"""
312+
).logical_plan()
313+
plan = plan.inputs()[0].inputs()[0].to_variant()
314+
assert isinstance(plan, RecursiveQuery)
315+
316+
317+
def test_values():
318+
ctx = SessionContext()
319+
plan = ctx.sql("values (1, 'foo'), (2, 'bar')").logical_plan()
320+
plan = plan.to_variant()
321+
assert isinstance(plan, Values)
322+
323+
324+
def test_transaction_start():
325+
ctx = SessionContext()
326+
plan = ctx.sql("START TRANSACTION").logical_plan()
327+
plan = plan.to_variant()
328+
assert isinstance(plan, TransactionStart)
329+
330+
331+
def test_transaction_end():
332+
ctx = SessionContext()
333+
plan = ctx.sql("COMMIT").logical_plan()
334+
plan = plan.to_variant()
335+
assert isinstance(plan, TransactionEnd)

0 commit comments

Comments
 (0)