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

Minor: make unsupported nanosecond part a real (not internal) error #13733

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Minor: make unsupported nanosecond part a real (not internal) error
  • Loading branch information
alamb committed Dec 11, 2024
commit 39b1670bff6a056ec3d3e7e8778fae4811acd097
4 changes: 2 additions & 2 deletions datafusion/functions/src/datetime/date_part.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use datafusion_common::cast::{
as_timestamp_microsecond_array, as_timestamp_millisecond_array,
as_timestamp_nanosecond_array, as_timestamp_second_array,
};
use datafusion_common::{exec_err, internal_err, ExprSchema, Result, ScalarValue};
use datafusion_common::{exec_err, internal_err, not_impl_err, ExprSchema, Result, ScalarValue};
use datafusion_expr::scalar_doc_sections::DOC_SECTION_DATETIME;
use datafusion_expr::TypeSignature::Exact;
use datafusion_expr::{
Expand Down Expand Up @@ -292,7 +292,7 @@ fn get_date_part_doc() -> &'static Documentation {
fn seconds_as_i32(array: &dyn Array, unit: TimeUnit) -> Result<ArrayRef> {
// Nanosecond is neither supported in Postgres nor DuckDB, to avoid to deal with overflow and precision issue we don't support nanosecond
if unit == Nanosecond {
return internal_err!("unit {unit:?} not supported");
return not_impl_err!("unit {unit:?} not supported");
}

let conversion_factor = match unit {
Expand Down
20 changes: 10 additions & 10 deletions datafusion/sqllogictest/test_files/expr/date_part.slt
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ SELECT EXTRACT(microsecond FROM timestamp '2020-09-08T12:00:12.12345678+00:00')
----
12123456

query error DataFusion error: Internal error: unit Nanosecond not supported
query error DataFusion error: This feature is not implemented: unit Nanosecond not supported
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This demonstrates the behavior change -- it is not an internal error anymore

SELECT EXTRACT(nanosecond FROM timestamp '2020-09-08T12:00:12.12345678+00:00')

query I
Expand All @@ -243,7 +243,7 @@ SELECT EXTRACT("microsecond" FROM timestamp '2020-09-08T12:00:12.12345678+00:00'
----
12123456

query error DataFusion error: Internal error: unit Nanosecond not supported
query error DataFusion error: This feature is not implemented: unit Nanosecond not supported
SELECT EXTRACT("nanosecond" FROM timestamp '2020-09-08T12:00:12.12345678+00:00')

query I
Expand All @@ -261,7 +261,7 @@ SELECT EXTRACT('microsecond' FROM timestamp '2020-09-08T12:00:12.12345678+00:00'
----
12123456

query error DataFusion error: Internal error: unit Nanosecond not supported
query error DataFusion error: This feature is not implemented: unit Nanosecond not supported
SELECT EXTRACT('nanosecond' FROM timestamp '2020-09-08T12:00:12.12345678+00:00')


Expand All @@ -281,7 +281,7 @@ SELECT date_part('microsecond', timestamp '2020-09-08T12:00:12.12345678+00:00')
----
12123456

query error DataFusion error: Internal error: unit Nanosecond not supported
query error DataFusion error: This feature is not implemented: unit Nanosecond not supported
SELECT date_part('nanosecond', timestamp '2020-09-08T12:00:12.12345678+00:00')


Expand All @@ -300,7 +300,7 @@ SELECT date_part('microsecond', '2020-09-08T12:00:12.12345678+00:00')
----
12123456

query error DataFusion error: Internal error: unit Nanosecond not supported
query error DataFusion error: This feature is not implemented: unit Nanosecond not supported
SELECT date_part('nanosecond', '2020-09-08T12:00:12.12345678+00:00')

# test_date_part_time
Expand Down Expand Up @@ -356,7 +356,7 @@ SELECT extract(microsecond from arrow_cast('23:32:50'::time, 'Time32(Second)'))
----
50000000

query error DataFusion error: Internal error: unit Nanosecond not supported
query error DataFusion error: This feature is not implemented: unit Nanosecond not supported
SELECT extract(nanosecond from arrow_cast('23:32:50'::time, 'Time32(Second)'))

query R
Expand Down Expand Up @@ -420,7 +420,7 @@ SELECT extract(microsecond from arrow_cast('23:32:50.123'::time, 'Time32(Millise
----
50123000

query error DataFusion error: Internal error: unit Nanosecond not supported
query error DataFusion error: This feature is not implemented: unit Nanosecond not supported
SELECT extract(nanosecond from arrow_cast('23:32:50.123'::time, 'Time32(Millisecond)'))

query R
Expand Down Expand Up @@ -484,7 +484,7 @@ SELECT extract(microsecond from arrow_cast('23:32:50.123456'::time, 'Time64(Micr
----
50123456

query error DataFusion error: Internal error: unit Nanosecond not supported
query error DataFusion error: This feature is not implemented: unit Nanosecond not supported
SELECT extract(nanosecond from arrow_cast('23:32:50.123456'::time, 'Time64(Microsecond)'))

query R
Expand Down Expand Up @@ -564,7 +564,7 @@ SELECT extract(us from arrow_cast('23:32:50.123456789'::time, 'Time64(Nanosecond
----
50123456

query error DataFusion error: Internal error: unit Nanosecond not supported
query error DataFusion error: This feature is not implemented: unit Nanosecond not supported
SELECT date_part('nanosecond', arrow_cast('23:32:50.123456789'::time, 'Time64(Nanosecond)'))

query R
Expand Down Expand Up @@ -874,5 +874,5 @@ SELECT (date_part('microsecond', now()) = EXTRACT(microsecond FROM now()))
----
true

query error DataFusion error: Internal error: unit Nanosecond not supported
query error DataFusion error: This feature is not implemented: unit Nanosecond not supported
SELECT (date_part('nanosecond', now()) = EXTRACT(nanosecond FROM now()))
Loading