Skip to content

Commit c7e423f

Browse files
committed
feat: Support casting Utf8 to Interval
1 parent 5833202 commit c7e423f

File tree

14 files changed

+68
-58
lines changed

14 files changed

+68
-58
lines changed

Cargo.lock

Lines changed: 12 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion-cli/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repository = "https://github.com/apache/arrow-datafusion"
2828
rust-version = "1.59"
2929

3030
[dependencies]
31-
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "096ef28dde6b1ae43ce89ba2c3a9d98295f2972e" }
31+
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "7e9519cbe4a994094c142a0a3e254c114df5c9ab" }
3232
clap = { version = "3", features = ["derive", "cargo"] }
3333
datafusion = { path = "../datafusion/core", version = "7.0.0" }
3434
dirs = "4.0.0"

datafusion-examples/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ path = "examples/avro_sql.rs"
3434
required-features = ["datafusion/avro"]
3535

3636
[dev-dependencies]
37-
arrow-flight = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "096ef28dde6b1ae43ce89ba2c3a9d98295f2972e" }
37+
arrow-flight = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "7e9519cbe4a994094c142a0a3e254c114df5c9ab" }
3838
async-trait = "0.1.41"
3939
datafusion = { path = "../datafusion/core" }
4040
futures = "0.3"

datafusion/common/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ jit = ["cranelift-module"]
3838
pyarrow = ["pyo3"]
3939

4040
[dependencies]
41-
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "096ef28dde6b1ae43ce89ba2c3a9d98295f2972e", features = ["prettyprint"] }
41+
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "7e9519cbe4a994094c142a0a3e254c114df5c9ab", features = ["prettyprint"] }
4242
avro-rs = { version = "0.13", features = ["snappy"], optional = true }
4343
cranelift-module = { version = "0.82.0", optional = true }
4444
ordered-float = "2.10"
45-
parquet = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "096ef28dde6b1ae43ce89ba2c3a9d98295f2972e", features = ["arrow"], optional = true }
45+
parquet = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "7e9519cbe4a994094c142a0a3e254c114df5c9ab", features = ["arrow"], optional = true }
4646
pyo3 = { version = "0.16", optional = true }
47-
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "037562f7975fcc92b725efbfbaaf050272668593" }
47+
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "2c1becf622f2283514ecbb7e3f01bd858edeaa71" }

datafusion/common/src/scalar.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,14 @@ impl ScalarValue {
13391339
DataType::Interval(IntervalUnit::YearMonth) => {
13401340
typed_cast!(array, index, IntervalYearMonthArray, IntervalYearMonth)
13411341
}
1342+
DataType::Interval(IntervalUnit::MonthDayNano) => {
1343+
typed_cast!(
1344+
array,
1345+
index,
1346+
IntervalMonthDayNanoArray,
1347+
IntervalMonthDayNano
1348+
)
1349+
}
13421350
DataType::Timestamp(TimeUnit::Millisecond, tz_opt) => {
13431351
typed_cast_tz!(
13441352
array,

datafusion/core/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ unicode_expressions = ["datafusion-physical-expr/regex_expressions"]
5555

5656
[dependencies]
5757
ahash = { version = "0.7", default-features = false }
58-
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "096ef28dde6b1ae43ce89ba2c3a9d98295f2972e", features = ["prettyprint"] }
58+
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "7e9519cbe4a994094c142a0a3e254c114df5c9ab", features = ["prettyprint"] }
5959
async-trait = "0.1.41"
6060
avro-rs = { version = "0.13", features = ["snappy"], optional = true }
6161
chrono = { version = "0.4", default-features = false }
@@ -73,13 +73,13 @@ num-traits = { version = "0.2", optional = true }
7373
num_cpus = "1.13.0"
7474
ordered-float = "2.10"
7575
parking_lot = "0.12"
76-
parquet = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "096ef28dde6b1ae43ce89ba2c3a9d98295f2972e", features = ["arrow"] }
76+
parquet = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "7e9519cbe4a994094c142a0a3e254c114df5c9ab", features = ["arrow"] }
7777
paste = "^1.0"
7878
pin-project-lite= "^0.2.7"
7979
pyo3 = { version = "0.16", optional = true }
8080
rand = "0.8"
8181
smallvec = { version = "1.6", features = ["union"] }
82-
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "037562f7975fcc92b725efbfbaaf050272668593" }
82+
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "2c1becf622f2283514ecbb7e3f01bd858edeaa71" }
8383
tempfile = "3"
8484
tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread", "sync", "fs", "parking_lot"] }
8585
tokio-stream = "0.1"

datafusion/core/fuzz-utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ edition = "2021"
2323
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
2424

2525
[dependencies]
26-
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "096ef28dde6b1ae43ce89ba2c3a9d98295f2972e", features = ["prettyprint"] }
26+
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "7e9519cbe4a994094c142a0a3e254c114df5c9ab", features = ["prettyprint"] }
2727
env_logger = "0.9.0"
2828
rand = "0.8"

datafusion/core/src/sql/planner.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,6 +2845,7 @@ pub fn convert_data_type(sql_type: &SQLDataType) -> Result<DataType> {
28452845
SQLDataType::Timestamp => Ok(DataType::Timestamp(TimeUnit::Nanosecond, None)),
28462846
SQLDataType::Date => Ok(DataType::Date32),
28472847
SQLDataType::Decimal(precision, scale) => make_decimal_type(*precision, *scale),
2848+
SQLDataType::Interval => Ok(DataType::Interval(IntervalUnit::MonthDayNano)),
28482849
other => Err(DataFusionError::NotImplemented(format!(
28492850
"Unsupported SQL type {:?}",
28502851
other

datafusion/core/tests/sql/expr.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -554,63 +554,63 @@ async fn test_interval_expressions() -> Result<()> {
554554
// day nano intervals
555555
test_expression!(
556556
"interval '1'",
557-
"0 years 0 mons 0 days 0 hours 0 mins 1.00 secs"
557+
"0 years 0 mons 0 days 0 hours 0 mins 1.000 secs"
558558
);
559559
test_expression!(
560560
"interval '1 second'",
561-
"0 years 0 mons 0 days 0 hours 0 mins 1.00 secs"
561+
"0 years 0 mons 0 days 0 hours 0 mins 1.000 secs"
562562
);
563563
test_expression!(
564564
"interval '500 milliseconds'",
565565
"0 years 0 mons 0 days 0 hours 0 mins 0.500 secs"
566566
);
567567
test_expression!(
568568
"interval '5 second'",
569-
"0 years 0 mons 0 days 0 hours 0 mins 5.00 secs"
569+
"0 years 0 mons 0 days 0 hours 0 mins 5.000 secs"
570570
);
571571
test_expression!(
572572
"interval '0.5 minute'",
573-
"0 years 0 mons 0 days 0 hours 0 mins 30.00 secs"
573+
"0 years 0 mons 0 days 0 hours 0 mins 30.000 secs"
574574
);
575575
test_expression!(
576576
"interval '.5 minute'",
577-
"0 years 0 mons 0 days 0 hours 0 mins 30.00 secs"
577+
"0 years 0 mons 0 days 0 hours 0 mins 30.000 secs"
578578
);
579579
test_expression!(
580580
"interval '5 minute'",
581-
"0 years 0 mons 0 days 0 hours 5 mins 0.00 secs"
581+
"0 years 0 mons 0 days 0 hours 5 mins 0.000 secs"
582582
);
583583
test_expression!(
584584
"interval '5 minute 1 second'",
585-
"0 years 0 mons 0 days 0 hours 5 mins 1.00 secs"
585+
"0 years 0 mons 0 days 0 hours 5 mins 1.000 secs"
586586
);
587587
test_expression!(
588588
"interval '1 hour'",
589-
"0 years 0 mons 0 days 1 hours 0 mins 0.00 secs"
589+
"0 years 0 mons 0 days 1 hours 0 mins 0.000 secs"
590590
);
591591
test_expression!(
592592
"interval '5 hour'",
593-
"0 years 0 mons 0 days 5 hours 0 mins 0.00 secs"
593+
"0 years 0 mons 0 days 5 hours 0 mins 0.000 secs"
594594
);
595595
test_expression!(
596596
"interval '1 day'",
597-
"0 years 0 mons 1 days 0 hours 0 mins 0.00 secs"
597+
"0 years 0 mons 1 days 0 hours 0 mins 0.000 secs"
598598
);
599599
test_expression!(
600600
"interval '1 day 1'",
601-
"0 years 0 mons 1 days 0 hours 0 mins 1.00 secs"
601+
"0 years 0 mons 1 days 0 hours 0 mins 1.000 secs"
602602
);
603603
test_expression!(
604604
"interval '0.5'",
605605
"0 years 0 mons 0 days 0 hours 0 mins 0.500 secs"
606606
);
607607
test_expression!(
608608
"interval '0.5 day 1'",
609-
"0 years 0 mons 0 days 12 hours 0 mins 1.00 secs"
609+
"0 years 0 mons 0 days 12 hours 0 mins 1.000 secs"
610610
);
611611
test_expression!(
612612
"interval '0.49 day'",
613-
"0 years 0 mons 0 days 11 hours 45 mins 36.00 secs"
613+
"0 years 0 mons 0 days 11 hours 45 mins 36.000 secs"
614614
);
615615
test_expression!(
616616
"interval '0.499 day'",
@@ -626,16 +626,16 @@ async fn test_interval_expressions() -> Result<()> {
626626
);
627627
test_expression!(
628628
"interval '0.49999999999 day'",
629-
"0 years 0 mons 0 days 12 hours 0 mins 0.00 secs"
629+
"0 years 0 mons 0 days 12 hours 0 mins 0.000 secs"
630630
);
631631
test_expression!(
632632
"interval '5 day'",
633-
"0 years 0 mons 5 days 0 hours 0 mins 0.00 secs"
633+
"0 years 0 mons 5 days 0 hours 0 mins 0.000 secs"
634634
);
635635
// Hour is ignored, this matches PostgreSQL
636636
test_expression!(
637637
"interval '5 day' hour",
638-
"0 years 0 mons 5 days 0 hours 0 mins 0.00 secs"
638+
"0 years 0 mons 5 days 0 hours 0 mins 0.000 secs"
639639
);
640640
test_expression!(
641641
"interval '5 day 4 hours 3 minutes 2 seconds 100 milliseconds'",
@@ -644,60 +644,60 @@ async fn test_interval_expressions() -> Result<()> {
644644
// month intervals
645645
test_expression!(
646646
"interval '0.5 month'",
647-
"0 years 0 mons 15 days 0 hours 0 mins 0.00 secs"
647+
"0 years 0 mons 15 days 0 hours 0 mins 0.000 secs"
648648
);
649649
test_expression!(
650650
"interval '0.5' month",
651-
"0 years 0 mons 15 days 0 hours 0 mins 0.00 secs"
651+
"0 years 0 mons 15 days 0 hours 0 mins 0.000 secs"
652652
);
653653
test_expression!(
654654
"interval '1 month'",
655-
"0 years 1 mons 0 days 0 hours 0 mins 0.00 secs"
655+
"0 years 1 mons 0 days 0 hours 0 mins 0.000 secs"
656656
);
657657
test_expression!(
658658
"interval '1' MONTH",
659-
"0 years 1 mons 0 days 0 hours 0 mins 0.00 secs"
659+
"0 years 1 mons 0 days 0 hours 0 mins 0.000 secs"
660660
);
661661
test_expression!(
662662
"interval '5 month'",
663-
"0 years 5 mons 0 days 0 hours 0 mins 0.00 secs"
663+
"0 years 5 mons 0 days 0 hours 0 mins 0.000 secs"
664664
);
665665
test_expression!(
666666
"interval '13 month'",
667-
"1 years 1 mons 0 days 0 hours 0 mins 0.00 secs"
667+
"1 years 1 mons 0 days 0 hours 0 mins 0.000 secs"
668668
);
669669
test_expression!(
670670
"interval '0.5 year'",
671-
"0 years 6 mons 0 days 0 hours 0 mins 0.00 secs"
671+
"0 years 6 mons 0 days 0 hours 0 mins 0.000 secs"
672672
);
673673
test_expression!(
674674
"interval '1 year'",
675-
"1 years 0 mons 0 days 0 hours 0 mins 0.00 secs"
675+
"1 years 0 mons 0 days 0 hours 0 mins 0.000 secs"
676676
);
677677
test_expression!(
678678
"interval '2 year'",
679-
"2 years 0 mons 0 days 0 hours 0 mins 0.00 secs"
679+
"2 years 0 mons 0 days 0 hours 0 mins 0.000 secs"
680680
);
681681
test_expression!(
682682
"interval '2' year",
683-
"2 years 0 mons 0 days 0 hours 0 mins 0.00 secs"
683+
"2 years 0 mons 0 days 0 hours 0 mins 0.000 secs"
684684
);
685685
// complex
686686
test_expression!(
687687
"interval '1 year 1 day'",
688-
"0 years 12 mons 1 days 0 hours 0 mins 0.00 secs"
688+
"0 years 12 mons 1 days 0 hours 0 mins 0.000000000 secs"
689689
);
690690
test_expression!(
691691
"interval '1 year 1 day 1 hour'",
692-
"0 years 12 mons 1 days 1 hours 0 mins 0.00 secs"
692+
"0 years 12 mons 1 days 1 hours 0 mins 0.000000000 secs"
693693
);
694694
test_expression!(
695695
"interval '1 year 1 day 1 hour 1 minute'",
696-
"0 years 12 mons 1 days 1 hours 1 mins 0.00 secs"
696+
"0 years 12 mons 1 days 1 hours 1 mins 0.000000000 secs"
697697
);
698698
test_expression!(
699699
"interval '1 year 1 day 1 hour 1 minute 1 second'",
700-
"0 years 12 mons 1 days 1 hours 1 mins 1.00 secs"
700+
"0 years 12 mons 1 days 1 hours 1 mins 1.000000000 secs"
701701
);
702702

703703
Ok(())

0 commit comments

Comments
 (0)