Skip to content

Commit

Permalink
revert unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Sep 12, 2024
1 parent 268d478 commit 8fe6a2f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 64 deletions.
16 changes: 8 additions & 8 deletions datafusion/core/src/datasource/physical_plan/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,15 +1329,15 @@ mod tests {

let df = ctx.sql(r#"select * from t1"#).await?.collect().await?;
let expected = [
"+-------+-----------------------------+",
"| col1 | col2 |",
"+-------+-----------------------------+",
"| 1 | hello\rworld |",
"| 2 | something\relse |",
"+-------+------------------------+",
"| col1 | col2 |",
"+-------+------------------------+",
"| 1 | hello\rworld |",
"| 2 | something\relse |",
"| 3 | \rmany\rlines\rmake\rgood test\r |",
"| 4 | unquoted |",
"| value | end |",
"+-------+-----------------------------+",
"| 4 | unquoted |",
"| value | end |",
"+-------+------------------------+",
];
crate::assert_batches_eq!(expected, &df);
Ok(())
Expand Down
50 changes: 4 additions & 46 deletions datafusion/sql/tests/sql_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ use datafusion_functions_aggregate::{
};
use datafusion_functions_aggregate::{average::avg_udaf, grouping::grouping_udaf};
use rstest::rstest;
use sqlparser::dialect::{
Dialect, GenericDialect, HiveDialect, MySqlDialect, PostgreSqlDialect,
};
use sqlparser::dialect::{Dialect, GenericDialect, HiveDialect, MySqlDialect};

mod cases;
mod common;
Expand Down Expand Up @@ -2684,14 +2682,6 @@ fn quick_test_with_options(sql: &str, expected: &str, options: ParserOptions) {
assert_eq!(format!("{plan}"), expected);
}

fn pg_quick_test(sql: &str, expected: &str) {
let dialect = &PostgreSqlDialect {};
let plan =
logical_plan_with_dialect_and_options(sql, dialect, ParserOptions::default())
.unwrap();
assert_eq!(format!("{plan}"), expected);
}

fn prepare_stmt_quick_test(
sql: &str,
expected_plan: &str,
Expand Down Expand Up @@ -2760,18 +2750,10 @@ fn join_with_aliases() {

#[test]
fn negative_interval_plus_interval_in_projection() {
let sql = "select -interval 2 day + interval 5 day;";
let expected =
"Projection: IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: -2, nanoseconds: 0 }\") + IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }\")\n EmptyRelation";
quick_test(sql, expected);
}

#[test]
fn pg_negative_interval_plus_interval_in_projection() {
let sql = "select -interval '2 days' + interval '5 days';";
let expected =
"Projection: IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: -2, nanoseconds: 0 }\") + IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }\")\n EmptyRelation";
pg_quick_test(sql, expected);
quick_test(sql, expected);
}

#[test]
Expand All @@ -2783,46 +2765,22 @@ fn complex_interval_expression_in_projection() {
quick_test(sql, expected);
}

#[test]
fn pg_complex_interval_expression_in_projection() {
let sql = "select -interval '2 days' + interval '5 days'+ (-interval '3 days' + interval '5 days');";
let expected =
"Projection: IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: -2, nanoseconds: 0 }\") + IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }\") + IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: -3, nanoseconds: 0 }\") + IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }\")\n EmptyRelation";
pg_quick_test(sql, expected);
}

#[test]
fn negative_sum_intervals_in_projection() {
let sql = "select -((interval 2 day + interval 5 day) + -(interval 4 day + interval 7 day));";
let expected =
"Projection: (- IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 2, nanoseconds: 0 }\") + IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }\") + (- IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 4, nanoseconds: 0 }\") + IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 7, nanoseconds: 0 }\")))\n EmptyRelation";
quick_test(sql, expected);
}

#[test]
fn pg_negative_sum_intervals_in_projection() {
let sql = "select -((interval '2 days' + interval '5 days') + -(interval '4 days' + interval '7 days'));";
let expected =
"Projection: (- IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 2, nanoseconds: 0 }\") + IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }\") + (- IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 4, nanoseconds: 0 }\") + IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 7, nanoseconds: 0 }\")))\n EmptyRelation";
pg_quick_test(sql, expected);
quick_test(sql, expected);
}

#[test]
fn date_plus_interval_in_projection() {
let sql = "select t_date32 + interval 5 day FROM test";
let sql = "select t_date32 + interval '5 day' FROM test";
let expected =
"Projection: test.t_date32 + IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }\")\n TableScan: test";
quick_test(sql, expected);
}

#[test]
fn pg_date_plus_interval_in_projection() {
let sql = "select t_date32 + interval '5 days' FROM test";
let expected =
"Projection: test.t_date32 + IntervalMonthDayNano(\"IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }\")\n TableScan: test";
pg_quick_test(sql, expected);
}

#[test]
fn date_plus_interval_in_filter() {
let sql = "select t_date64 FROM test \
Expand Down
6 changes: 3 additions & 3 deletions datafusion/sqllogictest/test_files/dates.slt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ h
query T rowsort
select i_item_desc
from test
where d3_date > d2_date + INTERVAL 5 day AND i_item_desc != 'g';
where d3_date > d2_date + INTERVAL '5 day' AND i_item_desc != 'g';
----
h

Expand All @@ -77,8 +77,8 @@ h
## Use OR
query T rowsort
select i_item_desc from test
where d3_date > d2_date + INTERVAL 5 day
OR d3_date = d2_date + INTERVAL 3 day;
where d3_date > d2_date + INTERVAL '5 day'
OR d3_date = d2_date + INTERVAL '3 day';
----
d
g
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/interval.slt
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ select '1 month'::interval - ts from t;

# interval + date
query D
select interval 1 month + '2012-01-01'::date;
select interval '1 month' + '2012-01-01'::date;
----
2012-02-01

Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/interval_mysql.slt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# Use `interval` SQL literal syntax with MySQL dialect

# this should fail generic dialect
# this should fail with the generic dialect
query error DataFusion error: Error during planning: Cannot coerce arithmetic expression Interval\(MonthDayNano\) \+ Utf8 to valid types
select interval '1' + '1' month

Expand Down
6 changes: 3 additions & 3 deletions datafusion/sqllogictest/test_files/timestamps.slt
Original file line number Diff line number Diff line change
Expand Up @@ -3156,18 +3156,18 @@ select arrow_cast(123, 'Duration(Nanosecond)') < interval '1 seconds';
true

query B
select interval 1 second < arrow_cast(123, 'Duration(Nanosecond)')
select interval '1 second' < arrow_cast(123, 'Duration(Nanosecond)')
----
false

# interval as LHS
query B
select interval 2 second = interval 2 second;
select interval '2 second' = interval '2 second';
----
true

query B
select interval 1 second < interval 2 second;
select interval '1 second' < interval '2 second';
----
true

Expand Down
4 changes: 2 additions & 2 deletions datafusion/sqllogictest/test_files/type_coercion.slt
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ SELECT '2023-05-01 12:30:00'::timestamp - interval '1 month';

# interval - date
query error DataFusion error: Error during planning: Cannot coerce arithmetic expression Interval\(MonthDayNano\) \- Date32 to valid types
select interval 1 month - '2023-05-01'::date;
select interval '1 month' - '2023-05-01'::date;

# interval - timestamp
query error DataFusion error: Error during planning: Cannot coerce arithmetic expression Interval\(MonthDayNano\) \- Timestamp\(Nanosecond, None\) to valid types
SELECT interval 1 month - '2023-05-01 12:30:00'::timestamp;
SELECT interval '1 month' - '2023-05-01 12:30:00'::timestamp;

# dictionary(int32, utf8) -> utf8
query T
Expand Down

0 comments on commit 8fe6a2f

Please sign in to comment.