Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TESTCASES]Add testcases about function, ddl, dml #1588

Merged
merged 7 commits into from Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions query_server/sqllogicaltests/cases/ddl/rename_field.slt
Expand Up @@ -64,3 +64,29 @@ from ddl_tbl order by time, t0, t1, t2;
1999-12-31T00:10:00.025 tag11 tag22 NULL 333
1999-12-31T00:10:00.030 tag11 tag23 NULL 444
1999-12-31T01:00:00.035 tag14 tag24 NULL 555

query error Arrow error: Io error: Status \{ code: Internal, message: "Build logical plan: This feature is not implemented: rename time column", *
alter table ddl_tbl rename column time to time_001;

query
desc table ddl_tbl;
----
time TIMESTAMP(NANOSECOND) TIME DEFAULT
t0 STRING TAG DEFAULT
t1 STRING TAG DEFAULT
t2 STRING TAG DEFAULT
f0 BIGINT FIELD DEFAULT
f1 BIGINT FIELD DEFAULT

query error Arrow error: Io error: Status \{ code: Internal, message: "Build logical plan: sql parser error: Expected TO, found: ,", *
alter table ddl_tbl rename column f0, f1 to f0_new000, f1_new_001;

query
desc table ddl_tbl;
----
time TIMESTAMP(NANOSECOND) TIME DEFAULT
t0 STRING TAG DEFAULT
t1 STRING TAG DEFAULT
t2 STRING TAG DEFAULT
f0 BIGINT FIELD DEFAULT
f1 BIGINT FIELD DEFAULT
26 changes: 26 additions & 0 deletions query_server/sqllogicaltests/cases/ddl/rename_tag.slt
Expand Up @@ -62,3 +62,29 @@ select * from ddl_tbl order by time, t0, t1, t2;
1999-12-31T00:10:00.025 tag11 tag22 NULL 333 555
1999-12-31T00:10:00.030 tag11 tag23 NULL 444 333
1999-12-31T01:00:00.035 tag14 tag24 NULL 555 222

query error Arrow error: Io error: Status \{ code: Internal, message: "Build logical plan: sql parser error: Expected TO, found: ,", *
alter table ddl_tbl rename column t0, t1 to t0_new000, t1_new_001;

query T
desc table ddl_tbl;
----
time TIMESTAMP(NANOSECOND) TIME DEFAULT
t0 STRING TAG DEFAULT
t1 STRING TAG DEFAULT
t2 STRING TAG DEFAULT
f0 BIGINT FIELD DEFAULT
f1 BIGINT FIELD DEFAULT

query error Arrow error: Io error: Status \{ code: Internal, message: "Build logical plan: sql parser error: Expected TO, found: ,", *
alter table ddl_tbl rename column t0, f1 to t0_new000, f1_new_001;

query T
desc table ddl_tbl;
----
time TIMESTAMP(NANOSECOND) TIME DEFAULT
t0 STRING TAG DEFAULT
t1 STRING TAG DEFAULT
t2 STRING TAG DEFAULT
f0 BIGINT FIELD DEFAULT
f1 BIGINT FIELD DEFAULT
117 changes: 117 additions & 0 deletions query_server/sqllogicaltests/cases/dml/delete.slt
Expand Up @@ -78,3 +78,120 @@ delete from dml_tbl where f0 = 11;
# 非常量表达式
statement error Arrow error: Io error: Status \{ code: Internal, message: "Execute logical plan: Datafusion: This feature is not implemented: operator \|\| in delete statement", .*
delete from dml_tbl where t0 = t0 || 'xx';


query T
select time, t0, t1, t2, f0, f1
from dml_tbl order by time, t0, t1, t2;
----
1999-12-31T00:00:00.010 tag12 tag23 NULL NULL 222
1999-12-31T00:00:10.015 tag14 tag24 NULL 444 111
1999-12-31T00:00:10.020 tag14 tag21 NULL 222 555
1999-12-31T01:00:00.035 tag14 tag24 NULL 555 222

statement ok
delete from dml_tbl f1 where time = '1999-12-31T00:00:00.010';

query T
select time, t0, t1, t2, f0, f1
from dml_tbl order by time, t0, t1, t2;
----
1999-12-31T00:00:10.015 tag14 tag24 NULL 444 111
1999-12-31T00:00:10.020 tag14 tag21 NULL 222 555
1999-12-31T01:00:00.035 tag14 tag24 NULL 555 222

statement ok
delete from dml_tbl time where time = '1999-12-31T00:00:10.020';

query T
select time, t0, t1, t2, f0, f1
from dml_tbl order by time, t0, t1, t2;
----
1999-12-31T00:00:10.015 tag14 tag24 NULL 444 111
1999-12-31T01:00:00.035 tag14 tag24 NULL 555 222

statement ok
delete from dml_tbl;

query T
select time, t0, t1, t2, f0, f1
from dml_tbl order by time, t0, t1, t2;
----

query T
desc table dml_tbl;
----
time TIMESTAMP(NANOSECOND) TIME DEFAULT
t0 STRING TAG DEFAULT
t1 STRING TAG DEFAULT
t2 STRING TAG DEFAULT
f0 BIGINT FIELD DEFAULT
f1 BIGINT FIELD DEFAULT

query error Arrow error: Io error: Status \{ code: Internal, message: "Build logical plan: Datafusion: Error during planning: Table not found, tenant: cnosdb db: public, table: dml_not_exist", *
delete from dml_not_exist;

query
select time, t0, t1, f0_bigint, f1_bigint_unsign from dml_tb2 order by time, t0, t1, f0_bigint, f1_bigint_unsign;
----
1999-12-31T00:00:00 t000 t109 -1 1
1999-12-31T00:00:00.005 t001 t108 1 1
1999-12-31T00:00:00.010 t002 t107 -9 1
1999-12-31T00:00:00.015 t003 t106 155 1
1999-12-31T00:00:00.020 t004 t105 1 1
1999-12-31T00:00:00.025 t005 t104 132 1
1999-12-31T00:00:00.030 t006 t103 321 1
1999-12-31T00:00:00.035 t009 t100 165 1
1999-12-31T00:00:00.040 t007 t101 41 1
1999-12-31T00:00:00.045 t008 t102 451 10

query error Arrow error: Io error: Status \{ code: Internal, message: "Build logical plan: This feature is not implemented: Filtering on the field column on the tskv table in delete statement", *
delete from dml_tb2 where f0_bigint = -1 and time = '1999-12-31T00:00:00';

query
select time, t0, t1, f0_bigint, f1_bigint_unsign from dml_tb2 order by time, t0, t1, f0_bigint, f1_bigint_unsign;
----
1999-12-31T00:00:00 t000 t109 -1 1
1999-12-31T00:00:00.005 t001 t108 1 1
1999-12-31T00:00:00.010 t002 t107 -9 1
1999-12-31T00:00:00.015 t003 t106 155 1
1999-12-31T00:00:00.020 t004 t105 1 1
1999-12-31T00:00:00.025 t005 t104 132 1
1999-12-31T00:00:00.030 t006 t103 321 1
1999-12-31T00:00:00.035 t009 t100 165 1
1999-12-31T00:00:00.040 t007 t101 41 1
1999-12-31T00:00:00.045 t008 t102 451 10

query error Arrow error: Io error: Status \{ code: Internal, message: "Build logical plan: This feature is not implemented: Filtering on the field column on the tskv table in delete statement", *
delete from dml_tb2 where f0_bigint = -1 and time = '1999-12-31T00:00:00' and t0 = 't00';

query
select time, t0, t1, f0_bigint, f1_bigint_unsign from dml_tb2 order by time, t0, t1, f0_bigint, f1_bigint_unsign;
----
1999-12-31T00:00:00 t000 t109 -1 1
1999-12-31T00:00:00.005 t001 t108 1 1
1999-12-31T00:00:00.010 t002 t107 -9 1
1999-12-31T00:00:00.015 t003 t106 155 1
1999-12-31T00:00:00.020 t004 t105 1 1
1999-12-31T00:00:00.025 t005 t104 132 1
1999-12-31T00:00:00.030 t006 t103 321 1
1999-12-31T00:00:00.035 t009 t100 165 1
1999-12-31T00:00:00.040 t007 t101 41 1
1999-12-31T00:00:00.045 t008 t102 451 10

query error Arrow error: Io error: Status \{ code: Internal, message: "Build logical plan: Datafusion: Schema error: No field named times\. Valid fields are time, t0, t1, t2, t3, f0_bigint, f1_bigint_unsign, f2_boolean, f3_string, f4_double, loc0_point, loc1_linestring, loc2_polygon, loc3_multipoint, loc4_multilinestring, loc5_multipolygon, loc6_geometrycollection\.", *
DELETE FROM dml_tb2 WHERE times = '1999-12-31T00:00:00.111';

query
select time, t0, t1, f0_bigint, f1_bigint_unsign from dml_tb2 order by time, t0, t1, f0_bigint, f1_bigint_unsign;
----
1999-12-31T00:00:00 t000 t109 -1 1
1999-12-31T00:00:00.005 t001 t108 1 1
1999-12-31T00:00:00.010 t002 t107 -9 1
1999-12-31T00:00:00.015 t003 t106 155 1
1999-12-31T00:00:00.020 t004 t105 1 1
1999-12-31T00:00:00.025 t005 t104 132 1
1999-12-31T00:00:00.030 t006 t103 321 1
1999-12-31T00:00:00.035 t009 t100 165 1
1999-12-31T00:00:00.040 t007 t101 41 1
1999-12-31T00:00:00.045 t008 t102 451 10
93 changes: 93 additions & 0 deletions query_server/sqllogicaltests/cases/dml/setup.slt
Expand Up @@ -11,6 +11,12 @@ drop table if exists dml_tbl;
statement ok
CREATE TABLE IF NOT EXISTS dml_tbl(f0 BIGINT , f1 bigint , TAGS(t0, t1, t2) );

statement ok
drop table if exists dml_tb2;

statement ok
CREATE TABLE IF NOT EXISTS dml_tb2(f0_bigint bigint, f1_bigint_unsign bigint unsigned, f2_boolean BOOLEAN, f3_string STRING, f4_double DOUBLE, loc0_point geometry(point, 0), loc1_LINESTRING geometry(LINESTRING, 0), loc2_POLYGON geometry(POLYGON, 0), loc3_MULTIPOINT geometry(MULTIPOINT, 0), loc4_MULTILINESTRING geometry(MULTILINESTRING, 0), loc5_MULTIPOLYGON geometry(MULTIPOLYGON, 0), loc6_GEOMETRYCOLLECTION geometry(GEOMETRYCOLLECTION, 0), tags(t0, t1, t2, t3));

##########
## Query
##########
Expand All @@ -27,3 +33,90 @@ VALUES
('1999-12-31 00:10:00.025', 333, 555, 'tag11', 'tag22'),
('1999-12-31 00:10:00.030', 444, 333, 'tag11', 'tag23'),
('1999-12-31 01:00:00.035', 555, 222, 'tag14', 'tag24');




statement ok
INSERT dml_tb2(TIME, t0, t1, t2, t3, f0_bigint, f1_bigint_unsign, f2_boolean, f3_string, f4_double, loc0_point, loc1_LINESTRING, loc2_POLYGON, loc3_MULTIPOINT, loc4_MULTILINESTRING, loc5_MULTIPOLYGON, loc6_GEOMETRYCOLLECTION)
VALUES
('1999-12-31 00:00:00.000', 't000', 't109', 't200', 't300', -1, 1, true, 'string000', 3.1415926,
'POINT(0 0)',
'LINESTRING (301 101, 101 301, 401 401)',
'POLYGON ((302 102, 402 402, 202 402, 102 220, 230 120))',
'MULTIPOINT ((102 40), (40 30), (20 20), (30 10))',
'MULTILINESTRING ((10 10, 20 20, 10 40),(440 40, 30 30, 40 20, 30 10))',
'MULTIPOLYGON (((30 20, 45 40, 10 40, 340 20)),((15 5, 40 10, 10 20, 5 10, 15 52)))',
'GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (10 10, 20 20, 10 40),POLYGON ((40 40, 20 45, 45 130, 40 40)))'),
('1999-12-31 00:00:00.005', 't001', 't108', 't201', 't304', 1, 1, false, 'string0sss00', 3.1415926,
'POINT(0 1)',
'LINESTRING (303 103, 103 303, 403 403)',
'POLYGON ((130 120, 430 404, 2035 406, 108 290, 380 130))',
'MULTIPOINT ((10 40), (40 30), (20 20), (30 10))',
'MULTILINESTRING ((10 10, 20 20, 10 40),(440 40, 30 30, 40 20, 30 10))',
'MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 4 10, 10 20, 5 10, 15 5)))',
'GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (10 10, 20 20, 10 40),POLYGON ((40 40, 20 45, 45 30, 240 40)))'),
('1999-12-31 00:00:00.010', 't002', 't107', 't202', 't305', -9, 1, true, 'string000', 3.1415643926,
'POINT(1 0)',
'LINESTRING (302 101, 102 302, 44 45)',
'POLYGON ((304 101, 401 401, 201 401, 101 201, 301 101))',
'MULTIPOINT ((10 40), (40 30), (20 203), (30 10))',
'MULTILINESTRING ((10 10, 20 20, 10 440),(40 40, 30 30, 40 20, 30 10))',
'MULTIPOLYGON (((30 20, 45 40, 10 40, 30 2)),((15 5, 40 10, 10 20, 5 10, 15 5)))',
'GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (10 1, 20 20, 10 40),POLYGON ((40 40, 20 45, 45 30, 40 4)))'),
('1999-12-31 00:00:00.015', 't003', 't106', 't203', 't300', 155, 1, true, 'string000', 3.12415926,
'POINT(4 0)',
'LINESTRING (301 30, 50 34, 42 45)',
'POLYGON ((306 130, 440 402, 205 403, 150 202, 3045 102))',
'MULTIPOINT ((10 40), (40 350), (20 20), (30 10))',
'MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 140))',
'MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 4 10, 10 20, 5 10, 15 5)))',
'GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (17 10, 20 20, 10 40),POLYGON ((40 40, 20 45, 45 30, 40 40)))'),
('1999-12-31 00:00:00.020', 't004', 't105', 't204', 't300', 1, 1, true, 'string000', 3.1415926,
'POINT(1 3)',
'LINESTRING (35 18, 19 34, 30 420)',
'POLYGON ((230 210, 410 420, 210 420, 120 220, 302 102))',
'MULTIPOINT ((10 40), (40 630), (20 20), (30 10))',
'MULTILINESTRING ((10 10, 20 20, 140 40),(40 40, 30 30, 40 20, 30 10))',
'MULTIPOLYGON (((30 20, 45 40, 10 40, 0 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))',
'GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (10 0, 20 20, 10 40),POLYGON ((40 40, 20 45, 45 30, 40 40)))'),
('1999-12-31 00:00:00.025', 't005', 't104', 't205', 't306', 132, 1, false, 'string00eere0', 3.1413235926,
'POINT(5 6)',
'LINESTRING (33 12, 12 36, 60 30)',
'POLYGON ((320 130, 404 406, 203 402, 130 240, 310 105))',
'MULTIPOINT ((10 40), (40 30), (20 20), (30 410))',
'MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 140))',
'MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 35, 40 10, 10 20, 5 10, 15 5)))',
'GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (10 10, 20 20, 10 450),POLYGON ((40 40, 20 45, 45 30, 40 40)))'),
('1999-12-31 00:00:00.030', 't006', 't103', 't206', 't300', 321, 1, true, 'string000', 3.1415926,
'POINT(10 0)',
'LINESTRING (34 30, 70 60, 45 70)',
'POLYGON ((302 103, 420 404,520 140, 410 220, 330 102))',
'MULTIPOINT ((10 40), (40 30), (120 20), (30 10))',
'MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 430, 40 20, 30 10))',
'MULTIPOLYGON (((30 20, 45 40, 10 10, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))',
'GEOMETRYCOLLECTION (POINT (402 10),LINESTRING (10 10, 20 20, 10 40),POLYGON ((40 40, 20 45, 45 30, 40 40)))'),
('1999-12-31 00:00:00.035', 't009', 't100', 't200', 't300', 165, 1, true, 'strinsdffreg000', 3.145415926,
'POINT(0 20)',
'LINESTRING (30 13, 10 32, 41 44)',
'POLYGON ((330 1450, 460 430, 202 402, 130 240, 302 103))',
'MULTIPOINT ((10 40), (40 30), (220 20), (30 10))',
'MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 440 20, 30 10))',
'MULTIPOLYGON (((30 24, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))',
'GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (10 10, 20 20, 150 40),POLYGON ((40 40, 20 45, 45 30, 40 40)))'),
('1999-12-31 00:00:00.040', 't007', 't101', 't200', 't306', 41, 1, false, 'string000', 3.1415926,
'POINT(111 342)',
'LINESTRING (31 20, 13 36, 50 10)',
'POLYGON ((302 130, 430 440, 420 450, 150 2560, 3067 10))',
'MULTIPOINT ((10 40), (440 30), (20 20), (30 10))',
'MULTILINESTRING ((10 10, 240 20, 10 40),(40 40, 30 30, 40 20, 30 10))',
'MULTIPOLYGON (((30 20, 45 40, 10 40, 30 26)),((15 5, 40 10, 10 20, 5 10, 15 5)))',
'GEOMETRYCOLLECTION (POINT (40 130),LINESTRING (10 10, 220 20, 10 40),POLYGON ((40 40, 20 45, 45 30, 40 40)))'),
('1999-12-31 00:00:00.045', 't008', 't102', 't200', 't309', 451, 10, true, 'string6434300', 34.1415926,
'POINT(34 22)',
'LINESTRING (30 10, 10 30, 40 40)',
'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))',
'MULTIPOINT ((10 40), (40 30), (20 20), (30 140))',
'MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 140))',
'MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 240, 5 10, 15 5)))',
'GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (10 10, 230 20, 10 40),POLYGON ((40 40, 20 45, 45 30, 40 40)))');