Skip to content

Conversation

@leekeiabstraction
Copy link
Contributor

Purpose

Linked issue: close #209

Brief change log

  • Added PartitionGetter
  • Added Partition utils
  • PartitionNameConverter logics are rolled into Partition utils as they are not used by any other component
  • Added validation functions in TablePath

Tests

  • Added test cases that mirror Java side

@leekeiabstraction
Copy link
Contributor Author

@luoyuxia @fresh-borzoni Appreciate your reviews here

Copy link

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

This PR introduces partition-related utilities for the Fluss Rust client, mirroring functionality from the Java implementation. It adds partition validation, auto-partition generation, and partition value conversion capabilities.

Changes:

  • Added PartitionGetter for extracting partition names/specs from rows
  • Added partition utilities including validation and auto-partition time generation
  • Added validation functions to TablePath for name and prefix checking
  • Added new InvalidPartition error variant

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/fluss/src/util/partition.rs New file containing partition validation, auto-partition generation, and datum-to-string conversion utilities
crates/fluss/src/util/mod.rs Exports the new partition module
crates/fluss/src/metadata/table.rs Adds validation methods for table/partition names and prefixes
crates/fluss/src/error.rs Adds InvalidPartition error variant for partition-related errors
crates/fluss/src/client/table/partition_getter.rs Implements PartitionGetter to extract partition information from rows, with comprehensive test coverage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@leekeiabstraction
Copy link
Contributor Author

Copilot comments have been addressed

Copy link
Contributor

@fresh-borzoni fresh-borzoni left a comment

Choose a reason for hiding this comment

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

@leekeiabstraction Thank you for the PR.
Left comments. PTAL

}

fn format_date_time(total_nanos: i64, dt: DateTime) -> String {
if total_nanos > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens in Java and Rust when nanos are 0?
I see Java uses optional blocks, so wouldn't it return trailing _ if no nanos?

let millis = ts.get_millisecond();
let nano_of_milli = ts.get_nano_of_millisecond();

let total_nanos = (millis % MILLIS_PER_SECOND) * NANOS_PER_MILLIS + (nano_of_milli as i64);
Copy link
Contributor

Choose a reason for hiding this comment

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

what would happen with negative timestamp?

let millis = ts.get_epoch_millisecond();
let nano_of_milli = ts.get_nano_of_millisecond();

let total_nanos = (millis % MILLIS_PER_SECOND) * NANOS_PER_MILLIS + (nano_of_milli as i64);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

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.

Introduce PartitionUtils, PartitionNameConverters and PartitionGetter

2 participants