Skip to content
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

feat!: initial support for timestamp #12

Merged
merged 17 commits into from
Jun 19, 2024
Merged

feat!: initial support for timestamp #12

merged 17 commits into from
Jun 19, 2024

Conversation

Dustin-Ray
Copy link
Contributor

@Dustin-Ray Dustin-Ray commented Jun 13, 2024

Rationale for this change

Provides the initial typing support for a postgresql-like TimeStamp type. The proofs TimeStampTZ is typed over a custom TimeUnit and TimeZone type.

The choice is made to type out TimeStamp in this way because the arrow::datatypes::TimeStamp has a required TimeUnit field and an Option TimeZone field. Typing out our own TimeStamp with these fields gives us greater control over the arrow type if we want. We can also jut default to seconds and UTC if needed, which would simplify this design a bit.

Typing Rationale

The arrow::datatypes::timezone is typed over a TimeUnit and an optional timezone Option<Arc<str>>. Thus in our application it makes sense to have a mapping of this metadata:

example:

// arrow datatype mapping to our new timestamp type
DataType::Timestamp(time_unit, timezone_option) => Ok(ColumnType::TimestampTZ(
    PoSQLTimeUnit::from(time_unit),
    PoSQLTimeZone::try_from(timezone_option)?,
)),

If this becomes burdensome, we could just as easily remove the timezone type and simply default to UTC, and handle any timezone conversion in DML and DDL. We will align with postgresql and store all times as UTC by default.

Finally, the PoSQLTimeUnit type gives us the flexibility to store times in either seconds, milliseconds, nanoseconds, or microseconds for high precision. This type maps directly to TimeUnit which we alias as ArrowTimeUnit in this PR.

What changes are included in this PR?

Typing updates:

  • Column
  • OwnedColumn
  • CommittableColumn
  • ColumnBounds
  • Typed TimeZone
  • Typed TimeUnit
  • impl ArrayRefExt for ArrayRef -> to_curve_25519_scalar & to_column
  • LiteralValue
  • owned_and_arrow_conversions
  • impl<S: Scalar> FromIterator<i64> for OwnedColumn<S>
  • impl<CP: CommitmentEvaluationProof> DataAccessor<CP::Scalar> for OwnedTableTestAccessor<CP>
  • owned_table_utility
  • test accessor_utility
  • multi-linear-extension
  • Scalar trait bounds
  • compute_dory_commitment
  • filter_column_by_index
  • prover_evaluate
  • sum_aggregate_column_by_index_counts
  • compare_indexes_by_columns
  • impl ProvableQueryResult
  • to_owned_table
  • trait ProvableResultColumn
  • make_empty_query_result
  • record_batch_dataframe_conversion
  • impl ToArrow for RecordBatch

Are these changes tested?

Tests:

  • TimeUnit Conversions
  • ColumnBounds
  • ColumnCommitmentMetadata
  • arrow_array_to_column_conversion
  • column
  • owned_table

Split:

  • lalrpop grammar update and token parsing
  • timestamp.now()
  • timestamp.current_time()

@Dustin-Ray Dustin-Ray requested review from iajoiner and JayWhite2357 and removed request for iajoiner June 18, 2024 06:48
@Dustin-Ray Dustin-Ray marked this pull request as ready for review June 18, 2024 06:52
Copy link
Contributor

@JayWhite2357 JayWhite2357 left a comment

Choose a reason for hiding this comment

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

Looks mostly good to me.
This should be marked as a breaking change since it will require an update of upstream crates.

crates/proof-of-sql/src/base/database/column.rs Outdated Show resolved Hide resolved
@Dustin-Ray Dustin-Ray changed the title feat: initial support for timestamp feat!: initial support for timestamp Jun 18, 2024
@Dustin-Ray Dustin-Ray requested a review from iajoiner June 18, 2024 23:30
Copy link
Contributor

@iajoiner iajoiner left a comment

Choose a reason for hiding this comment

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

Can we add some tests in query_expr_tests.rs and integration_tests.rs as well?

@Dustin-Ray Dustin-Ray requested a review from iajoiner June 19, 2024 19:13
@Dustin-Ray Dustin-Ray merged commit 623df7d into main Jun 19, 2024
8 checks passed
@Dustin-Ray Dustin-Ray deleted the feat/timestamp branch June 19, 2024 19:13
Dustin-Ray added a commit that referenced this pull request Jun 19, 2024
# Rationale for this change

Incorporates a small amount of feedback from #12 

# What changes are included in this PR?

Corrects naming in tests and removes unsupported feature in
group_by_util

# Are these changes tested?

yes
Copy link

🎉 This PR is included in version 0.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

3 participants