这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@kou
Copy link
Member

@kou kou commented Jun 25, 2025

What's Changed

Remove needless as ArrowErrors because all errors must be ArrowError here.

Closes #52.

@kou kou force-pushed the error-as-arrow-error branch from 67943c0 to b2fa4b4 Compare June 25, 2025 01:43
@kou kou force-pushed the error-as-arrow-error branch from b2fa4b4 to c4944c7 Compare June 25, 2025 01:47
@kou kou requested a review from Copilot June 25, 2025 01:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Removes unnecessary as ArrowError casts by refactoring loadRecordBatch calls to return a Result instead of throwing, streamlining error handling. Key changes:

  • Replaced do-try-catch blocks for record batch loading with Result-based switch.
  • Eliminated generic unknownError fallback in favor of direct error propagation.
  • Moved offset and length updates to occur after successful batch processing.
Comments suppressed due to low confidence (2)

Arrow/Sources/Arrow/ArrowReader.swift:257

  • Add unit tests for the failure branch of loadRecordBatch in each context to verify error propagation and confirm offset updates only happen on success.
                switch recordBatchResult {

Arrow/Sources/Arrow/ArrowReader.swift:251

  • With the generic catch removed, ensure that loadRecordBatch can only fail with ArrowError; otherwise unhandled errors might escape and lead to crashes.
                let recordBatchResult = loadRecordBatch(

Comment on lines +257 to +260
switch recordBatchResult {
case .success(let recordBatch):
result.batches.append(recordBatch)
offset += Int(message.bodyLength + Int64(length))
length = getUInt32(input, offset: offset)
} catch let error as ArrowError {
case .failure(let error):
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

[nitpick] This switch recordBatchResult block is repeated multiple times; consider extracting a helper method to append batches and propagate errors to reduce duplication.

Copilot uses AI. Check for mistakes.
@kou
Copy link
Member Author

kou commented Jun 25, 2025

+1

@kou kou merged commit 4593bae into apache:main Jun 25, 2025
11 of 12 checks passed
@kou kou deleted the error-as-arrow-error branch June 25, 2025 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swift 6: error: 'as' test is always true

1 participant