You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/08 20:11:03 UTC
[GitHub] [arrow-datafusion] alamb opened a new pull request, #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
alamb opened a new pull request, #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149
Draft as it builds on https://github.com/apache/arrow-datafusion/pull/4148
# Which issue does this PR close?
Closes https://github.com/apache/arrow-datafusion/issues/3702
# Rationale for this change
This will make predicate evaluation on unsigned columns faster in some cases
# What changes are included in this PR?
1. Add support for unsigned columns
2. Add tests (using the harness I wrote in https://github.com/apache/arrow-datafusion/pull/4147)
# Are these changes tested?
Yes
# Are there any user-facing changes?
Predicates on unsigned columns should be faster
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] liukun4515 commented on a diff in pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
liukun4515 commented on code in PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#discussion_r1021104791
##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -292,6 +296,25 @@ fn is_support_data_type(data_type: &DataType) -> bool {
)
}
+fn is_decimal_type(dt: &DataType) -> bool {
+ matches!(dt, DataType::Decimal128(_, _))
+}
+
+fn is_unsigned_type(dt: &DataType) -> bool {
+ matches!(
+ dt,
+ DataType::UInt8 | DataType::UInt16 | DataType::UInt32 | DataType::UInt64
+ )
+}
+
+/// Until https://github.com/apache/arrow-rs/issues/1043 is done
+/// (support for unsigned <--> decimal casts) we also don't do that
+/// kind of cast in this optimizer
+fn is_unsupported_cast(dt1: &DataType, dt2: &DataType) -> bool {
Review Comment:
https://github.com/apache/arrow-rs/pull/3106
##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -292,6 +296,25 @@ fn is_support_data_type(data_type: &DataType) -> bool {
)
}
+fn is_decimal_type(dt: &DataType) -> bool {
+ matches!(dt, DataType::Decimal128(_, _))
+}
+
+fn is_unsigned_type(dt: &DataType) -> bool {
+ matches!(
+ dt,
+ DataType::UInt8 | DataType::UInt16 | DataType::UInt32 | DataType::UInt64
+ )
+}
+
+/// Until https://github.com/apache/arrow-rs/issues/1043 is done
+/// (support for unsigned <--> decimal casts) we also don't do that
+/// kind of cast in this optimizer
+fn is_unsupported_cast(dt1: &DataType, dt2: &DataType) -> bool {
Review Comment:
https://github.com/apache/arrow-rs/pull/3106 PTAL @alamb
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#discussion_r1020749158
##########
datafusion/core/tests/sql/joins.rs:
##########
@@ -1428,9 +1428,9 @@ async fn reduce_left_join_1() -> Result<()> {
"Explain [plan_type:Utf8, plan:Utf8]",
" Projection: t1.t1_id, t1.t1_name, t1.t1_int, t2.t2_id, t2.t2_name, t2.t2_int [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N, t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
" Inner Join: t1.t1_id = t2.t2_id [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N, t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
- " Filter: CAST(t1.t1_id AS Int64) < Int64(100) [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N]",
Review Comment:
This was the original regression noted in https://github.com/apache/arrow-datafusion/pull/3699#discussion_r986810683 that lead to https://github.com/apache/arrow-datafusion/issues/3702
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] liukun4515 commented on a diff in pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
liukun4515 commented on code in PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#discussion_r1021063450
##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -292,6 +296,25 @@ fn is_support_data_type(data_type: &DataType) -> bool {
)
}
+fn is_decimal_type(dt: &DataType) -> bool {
+ matches!(dt, DataType::Decimal128(_, _))
+}
+
+fn is_unsigned_type(dt: &DataType) -> bool {
+ matches!(
+ dt,
+ DataType::UInt8 | DataType::UInt16 | DataType::UInt32 | DataType::UInt64
+ )
+}
+
+/// Until https://github.com/apache/arrow-rs/issues/1043 is done
+/// (support for unsigned <--> decimal casts) we also don't do that
+/// kind of cast in this optimizer
+fn is_unsupported_cast(dt1: &DataType, dt2: &DataType) -> bool {
Review Comment:
I will try to implement them recently.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] ursabot commented on pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#issuecomment-1315741564
Benchmark runs are scheduled for baseline = c9361e0210861962074eb10d7e480949bb862b97 and contender = 4653df4652c8af5d4e8841c489c1ab2e85a54e69. 4653df4652c8af5d4e8841c489c1ab2e85a54e69 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/0ea7314af2bd45fb87bed6e86461edd6...ac82cebba10e4930a41ff8295eb92015/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/c7b982c5387148d3a304155d03f19a94...3d7fc9cd93e04af9884721475d3c6bd2/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/1c2448734be34e1d990b8a3ce384318d...3c1cb95f359647e0874db55dbaefd781/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/fc3f156367c743e197cf057a20d73070...fd4b33f0ff764b4ab55e5dd56c160748/)
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] liukun4515 commented on a diff in pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
liukun4515 commented on code in PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#discussion_r1021064844
##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -639,12 +693,12 @@ mod tests {
// but the type of c6 is uint32
// the rewriter will not throw error and just return the original expr
let schema = expr_test_schema();
- let expr_input = cast(col("c6"), DataType::Int64).eq(lit(0i64));
+ let expr_input = cast(col("c6"), DataType::Float64).eq(lit(0f64));
Review Comment:
the comment of `"c6 > 0" will be cast to `cast(c6 as int64) > 0` should be change to `"c6 > 0" will be cast to `cast(c6 as float64) > 0`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#discussion_r1022021161
##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -639,12 +693,12 @@ mod tests {
// but the type of c6 is uint32
// the rewriter will not throw error and just return the original expr
let schema = expr_test_schema();
- let expr_input = cast(col("c6"), DataType::Int64).eq(lit(0i64));
+ let expr_input = cast(col("c6"), DataType::Float64).eq(lit(0f64));
Review Comment:
Fixed in c6946f065
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb merged pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
alamb merged PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#discussion_r1020749024
##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -292,6 +296,25 @@ fn is_support_data_type(data_type: &DataType) -> bool {
)
}
+fn is_decimal_type(dt: &DataType) -> bool {
+ matches!(dt, DataType::Decimal128(_, _))
+}
+
+fn is_unsigned_type(dt: &DataType) -> bool {
+ matches!(
+ dt,
+ DataType::UInt8 | DataType::UInt16 | DataType::UInt32 | DataType::UInt64
+ )
+}
+
+/// Until https://github.com/apache/arrow-rs/issues/1043 is done
+/// (support for unsigned <--> decimal casts) we also don't do that
+/// kind of cast in this optimizer
+fn is_unsupported_cast(dt1: &DataType, dt2: &DataType) -> bool {
Review Comment:
I found this with the test (which failed when it tried to invoke the arrow cast kernels for decimal <--> unsigned)
##########
datafusion/core/tests/sql/joins.rs:
##########
@@ -1428,9 +1428,9 @@ async fn reduce_left_join_1() -> Result<()> {
"Explain [plan_type:Utf8, plan:Utf8]",
" Projection: t1.t1_id, t1.t1_name, t1.t1_int, t2.t2_id, t2.t2_name, t2.t2_int [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N, t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
" Inner Join: t1.t1_id = t2.t2_id [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N, t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
- " Filter: CAST(t1.t1_id AS Int64) < Int64(100) [t1_id:UInt32;N, t1_name:Utf8;N, t1_int:UInt32;N]",
Review Comment:
🎉 the casts have been removed!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] liukun4515 commented on a diff in pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
liukun4515 commented on code in PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#discussion_r1021063144
##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -292,6 +296,25 @@ fn is_support_data_type(data_type: &DataType) -> bool {
)
}
+fn is_decimal_type(dt: &DataType) -> bool {
+ matches!(dt, DataType::Decimal128(_, _))
+}
+
+fn is_unsigned_type(dt: &DataType) -> bool {
+ matches!(
+ dt,
+ DataType::UInt8 | DataType::UInt16 | DataType::UInt32 | DataType::UInt64
+ )
+}
+
+/// Until https://github.com/apache/arrow-rs/issues/1043 is done
+/// (support for unsigned <--> decimal casts) we also don't do that
+/// kind of cast in this optimizer
+fn is_unsupported_cast(dt1: &DataType, dt2: &DataType) -> bool {
Review Comment:
Casting for `unsigned value <-> decimal ` is not supported now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] liukun4515 commented on a diff in pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
liukun4515 commented on code in PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#discussion_r1021064844
##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -639,12 +693,12 @@ mod tests {
// but the type of c6 is uint32
// the rewriter will not throw error and just return the original expr
let schema = expr_test_schema();
- let expr_input = cast(col("c6"), DataType::Int64).eq(lit(0i64));
+ let expr_input = cast(col("c6"), DataType::Float64).eq(lit(0f64));
Review Comment:
the comment of ```"c6 > 0" will be cast to `cast(c6 as int64) > 0``` should be change to `"c6 > 0"` will be cast to `cast(c6 as float64) > 0`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb commented on pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
alamb commented on PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#issuecomment-1312458202
Here is the next PR for unwrapping casts for your review @liukun4515
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] liukun4515 commented on a diff in pull request #4149: Support unsigned integers in `unwrap_cast_in_comparison` Optimizer rule
Posted by GitBox <gi...@apache.org>.
liukun4515 commented on code in PR #4149:
URL: https://github.com/apache/arrow-datafusion/pull/4149#discussion_r1021064844
##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -639,12 +693,12 @@ mod tests {
// but the type of c6 is uint32
// the rewriter will not throw error and just return the original expr
let schema = expr_test_schema();
- let expr_input = cast(col("c6"), DataType::Int64).eq(lit(0i64));
+ let expr_input = cast(col("c6"), DataType::Float64).eq(lit(0f64));
Review Comment:
the comment of ```"c6 > 0" will be cast to `cast(c6 as int64) > 0``` should be change to ```"c6 > 0"` will be cast to `cast(c6 as float64) > 0```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org