From 8fe6a2fe69a15a599088ca697abdd85091472c42 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Thu, 12 Sep 2024 16:37:49 +0100 Subject: [PATCH] revert unnecessary changes --- .../core/src/datasource/physical_plan/csv.rs | 16 +++--- datafusion/sql/tests/sql_integration.rs | 50 ++----------------- datafusion/sqllogictest/test_files/dates.slt | 6 +-- .../sqllogictest/test_files/interval.slt | 2 +- .../test_files/interval_mysql.slt | 2 +- .../sqllogictest/test_files/timestamps.slt | 6 +-- .../sqllogictest/test_files/type_coercion.slt | 4 +- 7 files changed, 22 insertions(+), 64 deletions(-) diff --git a/datafusion/core/src/datasource/physical_plan/csv.rs b/datafusion/core/src/datasource/physical_plan/csv.rs index 6cd1864deb1d..0e51effdf41a 100644 --- a/datafusion/core/src/datasource/physical_plan/csv.rs +++ b/datafusion/core/src/datasource/physical_plan/csv.rs @@ -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(()) diff --git a/datafusion/sql/tests/sql_integration.rs b/datafusion/sql/tests/sql_integration.rs index 7f9561e8d4f4..eb6ffd5b9443 100644 --- a/datafusion/sql/tests/sql_integration.rs +++ b/datafusion/sql/tests/sql_integration.rs @@ -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; @@ -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, @@ -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] @@ -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 \ diff --git a/datafusion/sqllogictest/test_files/dates.slt b/datafusion/sqllogictest/test_files/dates.slt index 59d83fa60033..2e56d5062e35 100644 --- a/datafusion/sqllogictest/test_files/dates.slt +++ b/datafusion/sqllogictest/test_files/dates.slt @@ -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 @@ -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 diff --git a/datafusion/sqllogictest/test_files/interval.slt b/datafusion/sqllogictest/test_files/interval.slt index 09c190852ec3..c73e340f9115 100644 --- a/datafusion/sqllogictest/test_files/interval.slt +++ b/datafusion/sqllogictest/test_files/interval.slt @@ -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 diff --git a/datafusion/sqllogictest/test_files/interval_mysql.slt b/datafusion/sqllogictest/test_files/interval_mysql.slt index 26d1e96cabd9..c05bb007e5f1 100644 --- a/datafusion/sqllogictest/test_files/interval_mysql.slt +++ b/datafusion/sqllogictest/test_files/interval_mysql.slt @@ -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 diff --git a/datafusion/sqllogictest/test_files/timestamps.slt b/datafusion/sqllogictest/test_files/timestamps.slt index 1237ee9b5ebb..1e3b516641ff 100644 --- a/datafusion/sqllogictest/test_files/timestamps.slt +++ b/datafusion/sqllogictest/test_files/timestamps.slt @@ -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 diff --git a/datafusion/sqllogictest/test_files/type_coercion.slt b/datafusion/sqllogictest/test_files/type_coercion.slt index 97d1b84e2ef6..0f9399cede2e 100644 --- a/datafusion/sqllogictest/test_files/type_coercion.slt +++ b/datafusion/sqllogictest/test_files/type_coercion.slt @@ -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