-
Notifications
You must be signed in to change notification settings - Fork 338
feat: [comet-parquet-exec] Schema adapter fixes #1139
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
Changes from 7 commits
bf6b4d4
d4d71bc
b6036f2
0b43b23
0602e24
74add9c
2021406
42d9f93
d220ae3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -585,6 +585,7 @@ pub fn spark_cast( | |
| eval_mode: EvalMode, | ||
| timezone: &str, | ||
| allow_incompat: bool, | ||
| ugly_hack_for_poc: bool, // TODO we definitely don't want to do this | ||
| ) -> DataFusionResult<ColumnarValue> { | ||
| match arg { | ||
| ColumnarValue::Array(array) => Ok(ColumnarValue::Array(cast_array( | ||
|
|
@@ -593,6 +594,7 @@ pub fn spark_cast( | |
| eval_mode, | ||
| timezone.to_owned(), | ||
| allow_incompat, | ||
| ugly_hack_for_poc, | ||
| )?)), | ||
| ColumnarValue::Scalar(scalar) => { | ||
| // Note that normally CAST(scalar) should be fold in Spark JVM side. However, for | ||
|
|
@@ -606,6 +608,7 @@ pub fn spark_cast( | |
| eval_mode, | ||
| timezone.to_owned(), | ||
| allow_incompat, | ||
| ugly_hack_for_poc, | ||
| )?, | ||
| 0, | ||
| )?; | ||
|
|
@@ -620,6 +623,7 @@ fn cast_array( | |
| eval_mode: EvalMode, | ||
| timezone: String, | ||
| allow_incompat: bool, | ||
| ugly_hack_for_poc: bool, | ||
| ) -> DataFusionResult<ArrayRef> { | ||
| let array = array_with_timezone(array, timezone.clone(), Some(to_type))?; | ||
| let from_type = array.data_type().clone(); | ||
|
|
@@ -643,6 +647,7 @@ fn cast_array( | |
| eval_mode, | ||
| timezone, | ||
| allow_incompat, | ||
| ugly_hack_for_poc, | ||
| )?, | ||
| ); | ||
|
|
||
|
|
@@ -723,7 +728,9 @@ fn cast_array( | |
| timezone, | ||
| allow_incompat, | ||
| )?), | ||
| _ if is_datafusion_spark_compatible(from_type, to_type, allow_incompat) => { | ||
| _ if ugly_hack_for_poc | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the cases (that we know of) where this gets invoked? (If we know we can replace this flag with an explicit check for those cases, perhaps?)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that we need to implement specific logic for adapting parquet schemas, rather than re-using our Spark-compatible cast. There is likely some overlap, so we can refactor the common code out. For example, regular spark casts do not need to support unsigned integers, but we need this when adapting Parquet schemas. |
||
| || is_datafusion_spark_compatible(from_type, to_type, allow_incompat) => | ||
| { | ||
| // use DataFusion cast only when we know that it is compatible with Spark | ||
| Ok(cast_with_options(&array, to_type, &CAST_OPTIONS)?) | ||
| } | ||
|
|
@@ -840,6 +847,7 @@ fn cast_struct_to_struct( | |
| eval_mode, | ||
| timezone.clone(), | ||
| allow_incompat, | ||
| false, | ||
| )?; | ||
| cast_fields.push((Arc::clone(&to_fields[i]), cast_field)); | ||
| } | ||
|
|
@@ -861,6 +869,7 @@ fn casts_struct_to_string(array: &StructArray, timezone: &str) -> DataFusionResu | |
| EvalMode::Legacy, | ||
| timezone, | ||
| true, | ||
| false, | ||
| ) | ||
| .and_then(|cv| cv.into_array(arr.len())) | ||
| }) | ||
|
|
@@ -1505,6 +1514,7 @@ impl PhysicalExpr for Cast { | |
| self.eval_mode, | ||
| &self.timezone, | ||
| self.allow_incompat, | ||
| false, | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -2117,6 +2127,7 @@ mod tests { | |
| EvalMode::Legacy, | ||
| timezone.clone(), | ||
| false, | ||
| false, | ||
| )?; | ||
| assert_eq!( | ||
| *result.data_type(), | ||
|
|
@@ -2327,6 +2338,7 @@ mod tests { | |
| EvalMode::Legacy, | ||
| "UTC".to_owned(), | ||
| false, | ||
| false, | ||
| ); | ||
| assert!(result.is_err()) | ||
| } | ||
|
|
@@ -2340,6 +2352,7 @@ mod tests { | |
| EvalMode::Legacy, | ||
| "Not a valid timezone".to_owned(), | ||
| false, | ||
| false, | ||
| ); | ||
| assert!(result.is_err()) | ||
| } | ||
|
|
@@ -2364,6 +2377,7 @@ mod tests { | |
| EvalMode::Legacy, | ||
| "UTC".to_owned(), | ||
| false, | ||
| false, | ||
| ) | ||
| .unwrap(); | ||
| let string_array = string_array.as_string::<i32>(); | ||
|
|
@@ -2400,6 +2414,7 @@ mod tests { | |
| EvalMode::Legacy, | ||
| "UTC", | ||
| false, | ||
| false, | ||
| ) | ||
| .unwrap(); | ||
| if let ColumnarValue::Array(cast_array) = cast_array { | ||
|
|
@@ -2433,6 +2448,7 @@ mod tests { | |
| EvalMode::Legacy, | ||
| "UTC", | ||
| false, | ||
| false, | ||
| ) | ||
| .unwrap(); | ||
| if let ColumnarValue::Array(cast_array) = cast_array { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 :)