mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-07-03 12:30:40 +00:00
test: move CSV skip bad records coverage to integration (#8237)
Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
@@ -2348,6 +2348,46 @@ async fn test_cast_type_issue_1594(instance: Arc<dyn MockInstance>) {
|
||||
check_output_stream(output, expected).await;
|
||||
}
|
||||
|
||||
#[apply(both_instances_cases)]
|
||||
async fn test_copy_from_csv_skip_bad_records(instance: Arc<dyn MockInstance>) {
|
||||
let instance = instance.frontend();
|
||||
|
||||
assert!(matches!(execute_sql(
|
||||
&instance,
|
||||
"create table csv_skip_bad_records(host_id INT, host_name STRING, reading_value DOUBLE, ts TIMESTAMP TIME INDEX, PRIMARY KEY(host_id));",
|
||||
)
|
||||
.await.data, OutputData::AffectedRows(0)));
|
||||
|
||||
let filepath = find_testing_resource("/tests/data/csv/skip_bad_records.csv");
|
||||
|
||||
let output = execute_sql(
|
||||
&instance,
|
||||
&format!(
|
||||
"copy csv_skip_bad_records from '{}' WITH(FORMAT='csv', skip_bad_records='true');",
|
||||
&filepath
|
||||
),
|
||||
)
|
||||
.await
|
||||
.data;
|
||||
|
||||
assert!(matches!(output, OutputData::AffectedRows(2)));
|
||||
|
||||
let output = execute_sql(
|
||||
&instance,
|
||||
"select * from csv_skip_bad_records order by host_id;",
|
||||
)
|
||||
.await
|
||||
.data;
|
||||
let expected = "\
|
||||
+---------+-----------+---------------+---------------------+
|
||||
| host_id | host_name | reading_value | ts |
|
||||
+---------+-----------+---------------+---------------------+
|
||||
| 1 | Alice | 10.5 | 2024-01-01T00:00:00 |
|
||||
| 2 | Bob | 30.5 | 2024-01-01T00:00:02 |
|
||||
+---------+-----------+---------------+---------------------+";
|
||||
check_output_stream(output, expected).await;
|
||||
}
|
||||
|
||||
#[apply(both_instances_cases)]
|
||||
async fn test_information_schema_dot_tables(instance: Arc<dyn MockInstance>) {
|
||||
let instance = instance.frontend();
|
||||
|
||||
@@ -183,24 +183,6 @@ select * from csv_null_prefix_import;
|
||||
| final | 2023-11-14T22:13:23 |
|
||||
+-------+---------------------+
|
||||
|
||||
CREATE TABLE csv_skip_bad_records(host_id int, host_name string, reading_value double, ts timestamp time index);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- SQLNESS ENV PWD
|
||||
Copy csv_skip_bad_records FROM '$PWD/tests/data/csv/skip_bad_records.csv' WITH (format='csv', skip_bad_records='true');
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
select * from csv_skip_bad_records order by ts;
|
||||
|
||||
+---------+-----------+---------------+---------------------+
|
||||
| host_id | host_name | reading_value | ts |
|
||||
+---------+-----------+---------------+---------------------+
|
||||
| 1 | Alice | 10.5 | 2024-01-01T00:00:00 |
|
||||
| 2 | Bob | 30.5 | 2024-01-01T00:00:02 |
|
||||
+---------+-----------+---------------+---------------------+
|
||||
|
||||
drop table demo;
|
||||
|
||||
Affected Rows: 0
|
||||
@@ -237,7 +219,3 @@ drop table csv_null_prefix_import;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table csv_skip_bad_records;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
|
||||
@@ -73,13 +73,6 @@ Copy csv_null_prefix_import FROM '${SQLNESS_HOME}/demo/export/csv_null_prefix.cs
|
||||
|
||||
select * from csv_null_prefix_import;
|
||||
|
||||
CREATE TABLE csv_skip_bad_records(host_id int, host_name string, reading_value double, ts timestamp time index);
|
||||
|
||||
-- SQLNESS ENV PWD
|
||||
Copy csv_skip_bad_records FROM '$PWD/tests/data/csv/skip_bad_records.csv' WITH (format='csv', skip_bad_records='true');
|
||||
|
||||
select * from csv_skip_bad_records order by ts;
|
||||
|
||||
drop table demo;
|
||||
|
||||
drop table with_filename;
|
||||
@@ -97,5 +90,3 @@ drop table demo_with_less_columns;
|
||||
drop table csv_null_prefix;
|
||||
|
||||
drop table csv_null_prefix_import;
|
||||
|
||||
drop table csv_skip_bad_records;
|
||||
|
||||
Reference in New Issue
Block a user