-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Dictionary String (UTF8) type to String sqllogictests #12621
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
104a7c0
mapping DictionaryString to text
goldmedal 50543bb
disable and move out the fail case for dictionary string
goldmedal 5e0edc4
fix the schema for dictionary string
goldmedal a6e3bf6
rollback the unnecessary change
goldmedal 0f95dde
cargo fmt
goldmedal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use crate::engines::output::DFColumnType; | ||
use arrow::array::Array; | ||
use arrow::datatypes::Fields; | ||
use arrow::util::display::ArrayFormatter; | ||
use arrow::{array, array::ArrayRef, datatypes::DataType, record_batch::RecordBatch}; | ||
|
@@ -23,8 +25,6 @@ use datafusion_common::DataFusionError; | |
use std::path::PathBuf; | ||
use std::sync::OnceLock; | ||
|
||
use crate::engines::output::DFColumnType; | ||
|
||
use super::super::conversion::*; | ||
use super::error::{DFSqlLogicTestError, Result}; | ||
|
||
|
@@ -174,7 +174,7 @@ fn convert_batch(batch: RecordBatch) -> Result<Vec<Vec<String>>> { | |
batch | ||
.columns() | ||
.iter() | ||
.map(|col| cell_to_string(col, row)) | ||
.map(|col| cell_to_string(col, row, col.data_type())) | ||
.collect::<Result<Vec<String>>>() | ||
}) | ||
.collect() | ||
|
@@ -198,12 +198,16 @@ macro_rules! get_row_value { | |
/// | ||
/// Floating numbers are rounded to have a consistent representation with the Postgres runner. | ||
/// | ||
pub fn cell_to_string(col: &ArrayRef, row: usize) -> Result<String> { | ||
pub fn cell_to_string( | ||
col: &ArrayRef, | ||
row: usize, | ||
data_type: &DataType, | ||
) -> Result<String> { | ||
if !col.is_valid(row) { | ||
// represent any null value with the string "NULL" | ||
Ok(NULL_STR.to_string()) | ||
} else { | ||
match col.data_type() { | ||
match data_type { | ||
DataType::Null => Ok(NULL_STR.to_string()), | ||
DataType::Boolean => { | ||
Ok(bool_to_str(get_row_value!(array::BooleanArray, col, row))) | ||
|
@@ -275,6 +279,17 @@ pub(crate) fn convert_schema_to_types(columns: &Fields) -> Vec<DFColumnType> { | |
| DataType::Time32(_) | ||
| DataType::Time64(_) => DFColumnType::DateTime, | ||
DataType::Timestamp(_, _) => DFColumnType::Timestamp, | ||
DataType::Dictionary(key_type, value_type) => { | ||
if key_type.is_integer() { | ||
// mapping dictionary string types to Text | ||
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. 👍 |
||
match value_type.as_ref() { | ||
DataType::Utf8 | DataType::LargeUtf8 => DFColumnType::Text, | ||
_ => DFColumnType::Another, | ||
} | ||
} else { | ||
DFColumnType::Another | ||
} | ||
} | ||
_ => DFColumnType::Another, | ||
}) | ||
.collect() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Minor nit is that since this data type comes from
col
it seems like we could keep the signature of this function the same and calllet data_type = col.data_type()
in the functionThere 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.
oops... my bad. It's my other experimental change. I forgot to roll back it. I'll recover it. Thanks for mentioning it.