Skip to content

Commit

Permalink
fix(sqlness): sqlness isolation (#4780)
Browse files Browse the repository at this point in the history
* fix: isolate logs

* fix: copy cases

* fix: clippy
  • Loading branch information
v0y4g3r authored Sep 29, 2024
1 parent d9f2f0c commit 0a82b12
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ INSERT INTO demo(host, cpu, memory, ts) values ('host1', 66.6, 1024, 16552765570

Affected Rows: 2

COPY DATABASE public TO '/tmp/demo/export/parquet/' WITH (FORMAT="parquet");
COPY DATABASE public TO '${SQLNESS_HOME}/demo/export/parquet/' WITH (FORMAT="parquet");

Affected Rows: 2

COPY DATABASE public TO '/tmp/demo/export/parquet_range/' WITH (FORMAT="parquet", start_time='2022-06-15 07:02:37.000Z', end_time='2022-06-15 07:02:37.1Z');
COPY DATABASE public TO '${SQLNESS_HOME}/demo/export/parquet_range/' WITH (FORMAT="parquet", start_time='2022-06-15 07:02:37.000Z', end_time='2022-06-15 07:02:37.1Z');

Affected Rows: 1

Expand All @@ -23,7 +23,7 @@ SELECT * FROM demo ORDER BY ts;
++
++

COPY DATABASE public FROM '/tmp/demo/export/parquet/';
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet/';

Affected Rows: 2

Expand All @@ -40,7 +40,7 @@ DELETE FROM demo;

Affected Rows: 2

COPY DATABASE public FROM '/tmp/demo/export/parquet_range/';
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet_range/';

Affected Rows: 1

Expand All @@ -56,7 +56,7 @@ DELETE FROM demo;

Affected Rows: 1

COPY DATABASE public FROM '/tmp/demo/export/parquet_range/' LIMIT 2;
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet_range/' LIMIT 2;

Error: 2000(InvalidSyntax), Invalid SQL, error: limit is not supported

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ CREATE TABLE demo(host string, cpu double, memory double, ts TIMESTAMP time inde

INSERT INTO demo(host, cpu, memory, ts) values ('host1', 66.6, 1024, 1655276557000), ('host2', 88.8, 333.3, 1655276558000);

COPY DATABASE public TO '/tmp/demo/export/parquet/' WITH (FORMAT="parquet");
COPY DATABASE public TO '${SQLNESS_HOME}/demo/export/parquet/' WITH (FORMAT="parquet");

COPY DATABASE public TO '/tmp/demo/export/parquet_range/' WITH (FORMAT="parquet", start_time='2022-06-15 07:02:37.000Z', end_time='2022-06-15 07:02:37.1Z');
COPY DATABASE public TO '${SQLNESS_HOME}/demo/export/parquet_range/' WITH (FORMAT="parquet", start_time='2022-06-15 07:02:37.000Z', end_time='2022-06-15 07:02:37.1Z');

DELETE FROM demo;

SELECT * FROM demo ORDER BY ts;

COPY DATABASE public FROM '/tmp/demo/export/parquet/';
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet/';

SELECT * FROM demo ORDER BY ts;

DELETE FROM demo;

COPY DATABASE public FROM '/tmp/demo/export/parquet_range/';
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet_range/';

SELECT * FROM demo ORDER BY ts;

DELETE FROM demo;

COPY DATABASE public FROM '/tmp/demo/export/parquet_range/' LIMIT 2;
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet_range/' LIMIT 2;

DROP TABLE demo;
8 changes: 4 additions & 4 deletions tests/cases/standalone/common/copy/copy_from_fs_csv.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ values

Affected Rows: 3

Copy demo TO '/tmp/demo/export/csv/demo.csv' with (format='csv');
Copy demo TO '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv');

Affected Rows: 3

CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp time index);

Affected Rows: 0

Copy with_filename FROM '/tmp/demo/export/csv/demo.csv' with (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');

Affected Rows: 2

Expand All @@ -36,7 +36,7 @@ CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time

Affected Rows: 0

Copy with_path FROM '/tmp/demo/export/csv/' with (format='csv', start_time='2023-06-15 07:02:37');
Copy with_path FROM '${SQLNESS_HOME}/demo/export/csv/' with (format='csv', start_time='2023-06-15 07:02:37');

Affected Rows: 1

Expand All @@ -52,7 +52,7 @@ CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp t

Affected Rows: 0

Copy with_pattern FROM '/tmp/demo/export/csv/' WITH (pattern = 'demo.*', format='csv', end_time='2025-06-15 07:02:39');
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/csv/' WITH (pattern = 'demo.*', format='csv', end_time='2025-06-15 07:02:39');

Affected Rows: 3

Expand Down
8 changes: 4 additions & 4 deletions tests/cases/standalone/common/copy/copy_from_fs_csv.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ values
('host2', 88.8, 333.3, 1655276558000),
('host3', 99.9, 444.4, 1722077263000);

Copy demo TO '/tmp/demo/export/csv/demo.csv' with (format='csv');
Copy demo TO '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv');

CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp time index);

Copy with_filename FROM '/tmp/demo/export/csv/demo.csv' with (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');

select * from with_filename order by ts;

CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time index);

Copy with_path FROM '/tmp/demo/export/csv/' with (format='csv', start_time='2023-06-15 07:02:37');
Copy with_path FROM '${SQLNESS_HOME}/demo/export/csv/' with (format='csv', start_time='2023-06-15 07:02:37');

select * from with_path order by ts;

CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp time index);

Copy with_pattern FROM '/tmp/demo/export/csv/' WITH (pattern = 'demo.*', format='csv', end_time='2025-06-15 07:02:39');
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/csv/' WITH (pattern = 'demo.*', format='csv', end_time='2025-06-15 07:02:39');

select * from with_pattern order by ts;

Expand Down
8 changes: 4 additions & 4 deletions tests/cases/standalone/common/copy/copy_from_fs_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ values

Affected Rows: 3

Copy demo TO '/tmp/demo/export/json/demo.json' with (format='json');
Copy demo TO '${SQLNESS_HOME}/demo/export/json/demo.json' with (format='json');

Affected Rows: 3

CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp time index);

Affected Rows: 0

Copy with_filename FROM '/tmp/demo/export/json/demo.json' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/json/demo.json' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');

Affected Rows: 2

Expand All @@ -36,7 +36,7 @@ CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time

Affected Rows: 0

Copy with_path FROM '/tmp/demo/export/json/' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
Copy with_path FROM '${SQLNESS_HOME}/demo/export/json/' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');

Affected Rows: 2

Expand All @@ -53,7 +53,7 @@ CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp t

Affected Rows: 0

Copy with_pattern FROM '/tmp/demo/export/json/' WITH (pattern = 'demo.*',format='json', end_time='2022-06-15 07:02:39');
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/json/' WITH (pattern = 'demo.*',format='json', end_time='2022-06-15 07:02:39');

Affected Rows: 2

Expand Down
8 changes: 4 additions & 4 deletions tests/cases/standalone/common/copy/copy_from_fs_json.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ values
('host2', 88.8, 333.3, 1655276558000),
('host3', 99.9, 444.4, 1722077263000);

Copy demo TO '/tmp/demo/export/json/demo.json' with (format='json');
Copy demo TO '${SQLNESS_HOME}/demo/export/json/demo.json' with (format='json');

CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp time index);

Copy with_filename FROM '/tmp/demo/export/json/demo.json' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/json/demo.json' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');

select * from with_filename order by ts;

CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time index);

Copy with_path FROM '/tmp/demo/export/json/' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
Copy with_path FROM '${SQLNESS_HOME}/demo/export/json/' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');

select * from with_path order by ts;

CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp time index);

Copy with_pattern FROM '/tmp/demo/export/json/' WITH (pattern = 'demo.*',format='json', end_time='2022-06-15 07:02:39');
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/json/' WITH (pattern = 'demo.*',format='json', end_time='2022-06-15 07:02:39');

select * from with_pattern order by ts;

Expand Down
18 changes: 9 additions & 9 deletions tests/cases/standalone/common/copy/copy_from_fs_parquet.result
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ values

Affected Rows: 3

Copy demo TO '/tmp/demo/export/parquet_files/demo.parquet';
Copy demo TO '${SQLNESS_HOME}/demo/export/parquet_files/demo.parquet';

Affected Rows: 3

Copy demo_2 TO '/tmp/demo/export/parquet_files/demo_2.parquet';
Copy demo_2 TO '${SQLNESS_HOME}/demo/export/parquet_files/demo_2.parquet';

Affected Rows: 3

CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp time index);

Affected Rows: 0

Copy with_filename FROM '/tmp/demo/export/parquet_files/demo.parquet' with (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/parquet_files/demo.parquet' with (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');

Affected Rows: 2

Expand All @@ -53,7 +53,7 @@ CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time

Affected Rows: 0

Copy with_path FROM '/tmp/demo/export/parquet_files/';
Copy with_path FROM '${SQLNESS_HOME}/demo/export/parquet_files/';

Affected Rows: 6

Expand All @@ -74,7 +74,7 @@ CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp t

Affected Rows: 0

Copy with_pattern FROM '/tmp/demo/export/parquet_files/' WITH (PATTERN = 'demo.*', start_time='2022-06-15 07:02:39');
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/parquet_files/' WITH (PATTERN = 'demo.*', start_time='2022-06-15 07:02:39');

Affected Rows: 2

Expand All @@ -91,7 +91,7 @@ CREATE TABLE without_limit_rows(host string, cpu double, memory double, ts times

Affected Rows: 0

Copy without_limit_rows FROM '/tmp/demo/export/parquet_files/';
Copy without_limit_rows FROM '${SQLNESS_HOME}/demo/export/parquet_files/';

Affected Rows: 6

Expand All @@ -107,7 +107,7 @@ CREATE TABLE with_limit_rows_segment(host string, cpu double, memory double, ts

Affected Rows: 0

Copy with_limit_rows_segment FROM '/tmp/demo/export/parquet_files/' LIMIT 3;
Copy with_limit_rows_segment FROM '${SQLNESS_HOME}/demo/export/parquet_files/' LIMIT 3;

Affected Rows: 3

Expand All @@ -119,9 +119,9 @@ select count(*) from with_limit_rows_segment;
| 3 |
+----------+

Copy with_limit_rows_segment FROM '/tmp/demo/export/parquet_files/' LIMIT hello;
Copy with_limit_rows_segment FROM '${SQLNESS_HOME}/demo/export/parquet_files/' LIMIT hello;

Error: 2000(InvalidSyntax), Unexpected token while parsing SQL statement, expected: 'the number of maximum rows', found: ;: sql parser error: Expected literal int, found: hello at Line: 1, Column 75
Error: 2000(InvalidSyntax), Unexpected token while parsing SQL statement, expected: 'the number of maximum rows', found: ;: sql parser error: Expected literal int, found: hello at Line: 1, Column 86

drop table demo;

Expand Down
16 changes: 8 additions & 8 deletions tests/cases/standalone/common/copy/copy_from_fs_parquet.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,41 @@ values
('host5', 99.9, 444.4, 1655276556000),
('host6', 222.2, 555.5, 1722077264000);

Copy demo TO '/tmp/demo/export/parquet_files/demo.parquet';
Copy demo TO '${SQLNESS_HOME}/demo/export/parquet_files/demo.parquet';

Copy demo_2 TO '/tmp/demo/export/parquet_files/demo_2.parquet';
Copy demo_2 TO '${SQLNESS_HOME}/demo/export/parquet_files/demo_2.parquet';

CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp time index);

Copy with_filename FROM '/tmp/demo/export/parquet_files/demo.parquet' with (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/parquet_files/demo.parquet' with (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');

select * from with_filename order by ts;

CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time index);

Copy with_path FROM '/tmp/demo/export/parquet_files/';
Copy with_path FROM '${SQLNESS_HOME}/demo/export/parquet_files/';

select * from with_path order by ts;

CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp time index);

Copy with_pattern FROM '/tmp/demo/export/parquet_files/' WITH (PATTERN = 'demo.*', start_time='2022-06-15 07:02:39');
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/parquet_files/' WITH (PATTERN = 'demo.*', start_time='2022-06-15 07:02:39');

select * from with_pattern order by ts;

CREATE TABLE without_limit_rows(host string, cpu double, memory double, ts timestamp time index);

Copy without_limit_rows FROM '/tmp/demo/export/parquet_files/';
Copy without_limit_rows FROM '${SQLNESS_HOME}/demo/export/parquet_files/';

select count(*) from without_limit_rows;

CREATE TABLE with_limit_rows_segment(host string, cpu double, memory double, ts timestamp time index);

Copy with_limit_rows_segment FROM '/tmp/demo/export/parquet_files/' LIMIT 3;
Copy with_limit_rows_segment FROM '${SQLNESS_HOME}/demo/export/parquet_files/' LIMIT 3;

select count(*) from with_limit_rows_segment;

Copy with_limit_rows_segment FROM '/tmp/demo/export/parquet_files/' LIMIT hello;
Copy with_limit_rows_segment FROM '${SQLNESS_HOME}/demo/export/parquet_files/' LIMIT hello;

drop table demo;

Expand Down
6 changes: 3 additions & 3 deletions tests/cases/standalone/common/copy/copy_to_fs.result
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ insert into demo(host, cpu, memory, ts) values ('host1', 66.6, 1024, 16552765570

Affected Rows: 2

COPY demo TO '/tmp/export/demo.parquet' WITH (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
COPY demo TO '${SQLNESS_HOME}/export/demo.parquet' WITH (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');

Affected Rows: 1

COPY demo TO '/tmp/export/demo.csv' WITH (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
COPY demo TO '${SQLNESS_HOME}/export/demo.csv' WITH (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');

Affected Rows: 1

COPY demo TO '/tmp/export/demo.json' WITH (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
COPY demo TO '${SQLNESS_HOME}/export/demo.json' WITH (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');

Affected Rows: 1

Expand Down
6 changes: 3 additions & 3 deletions tests/cases/standalone/common/copy/copy_to_fs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ CREATE TABLE demo(host string, cpu DOUBLE, memory DOUBLE, ts TIMESTAMP TIME INDE

insert into demo(host, cpu, memory, ts) values ('host1', 66.6, 1024, 1655276557000), ('host2', 88.8, 333.3, 1655276558000);

COPY demo TO '/tmp/export/demo.parquet' WITH (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
COPY demo TO '${SQLNESS_HOME}/export/demo.parquet' WITH (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');

COPY demo TO '/tmp/export/demo.csv' WITH (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
COPY demo TO '${SQLNESS_HOME}/export/demo.csv' WITH (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');

COPY demo TO '/tmp/export/demo.json' WITH (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
COPY demo TO '${SQLNESS_HOME}/export/demo.json' WITH (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');

drop table demo;
Loading

0 comments on commit 0a82b12

Please sign in to comment.