Skip to content

Conversation

@lichuang
Copy link

@lichuang lichuang commented Jan 2, 2026

fix #5601

@github-actions github-actions bot added enhancement New feature or request python java labels Jan 2, 2026
@wjones127 wjones127 self-assigned this Jan 2, 2026
Copy link
Contributor

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

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

Thanks for starting this. I have several suggestions.

Feel free to suggest that we add or change an error type. For example, maybe we want to make a more general NotFound error that's separate from FileNotFound error.

Comment on lines +168 to +173
pub fn not_found(message: impl Into<String>, location: Location) -> Self {
let message: String = message.into();
Self::NotFound {
uri: message,
location,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We could probably simplify this a lot by just using std::panic::Location::caller(). This can even be applied to existing variants.

Suggested change
pub fn not_found(message: impl Into<String>, location: Location) -> Self {
let message: String = message.into();
Self::NotFound {
uri: message,
location,
}
pub fn not_found(uri: impl Into<String>) -> Self {
Self::NotFound {
uri: uri.into(),
location: std::panic::Location::caller().to_snafu_location(),
}

// Regular data column - validate it exists in base schema
if base.schema().field(&field.name).is_none() {
return Err(Error::io(
return Err(Error::not_found(
Copy link
Contributor

Choose a reason for hiding this comment

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

The not_found error is really a FileNotFound error, so doesn't apply here.

Suggested change
return Err(Error::not_found(
return Err(Error::invalid_input(

batch.column_by_name(&field.name).ok_or_else(|| {
Error::io(
format!("FileWriter::write: Field '{}' not found", field.name),
Error::not_found(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Error::not_found(
Error::invalid_input(

})?;

let value_arr = dict_info.values.as_ref().ok_or_else(|| {
Error::io(
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed one here:

Suggested change
Error::io(
Error::invalid_input(

Error::io(
format!(
"Lance field {} is dictionary type, but misses the dictionary value array",
"Lance field {} is dictionary type, but misses the dictionary value array",
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably make it standard that we wrap the field names in quotes:

Suggested change
"Lance field {} is dictionary type, but misses the dictionary value array",
"Lance field '{}' is dictionary type, but misses the dictionary value array",

) -> Result<&'a PageInfo> {
page_table.get(field.id, batch_id).ok_or_else(|| {
Error::io(
Error::not_found(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Error::not_found(
Error::invalid_input(


if buf.len() < 16 {
return Err(Error::io(
return Err(Error::invalid_input(
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it might be corrupt file to me.

Suggested change
return Err(Error::invalid_input(
return Err(Error::corrupt_file(

}
if !buf.ends_with(MAGIC) {
return Err(Error::io(
return Err(Error::invalid_input(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here:

Suggested change
return Err(Error::invalid_input(
return Err(Error::corrupt_file(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request java python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review use of Error::io() to find cases where that error should be a different type

2 participants