Skip to content

Conversation

kgpai
Copy link
Contributor

@kgpai kgpai commented Sep 19, 2025

Description

This diff pushes session start time to VeloxQueryConfig.

Motivation and Context

This is required for queries like current_date, localtime, current_time etc which use the session start time instead of wall clock time.

Impact

N/A

Test Plan

Unite test.

If release note is NOT required, use:

== NO RELEASE NOTE ==

@kgpai kgpai requested review from a team as code owners September 19, 2025 21:35
@prestodb-ci prestodb-ci added the from:Meta PR from Meta label Sep 19, 2025
Copy link
Contributor

sourcery-ai bot commented Sep 19, 2025

Reviewer's Guide

This PR enables propagation of session start time into VeloxQueryConfig by extending the configuration update logic and adds comprehensive unit tests to verify correct handling of various start time values.

Sequence diagram for setting sessionStartTime in VeloxQueryConfig

sequenceDiagram
    participant S as Session
    participant P as PrestoToVeloxQueryConfig
    participant Q as QueryConfig
    S->>P: Provide startTime
    P->>Q: Set queryConfigs[kSessionStartTime] = to_string(startTime)
    P->>Q: Set other configs (e.g., source)
Loading

Class diagram for updated VeloxQueryConfig session start time support

classDiagram
    class Session {
        +startTime: optional<int64_t>
        +source: optional<string>
    }
    class PrestoToVeloxQueryConfig {
        +updateFromSessionConfigs(session: Session, queryConfigs: map<string, string>)
    }
    class QueryConfig {
        <<static>>
        +kSessionStartTime: string
        +kSource: string
    }
    Session --> PrestoToVeloxQueryConfig : used by
    PrestoToVeloxQueryConfig --> QueryConfig : uses constants
    PrestoToVeloxQueryConfig : +updateFromSessionConfigs()
    PrestoToVeloxQueryConfig : +queryConfigs[kSessionStartTime]
    PrestoToVeloxQueryConfig : +queryConfigs[kSource]
Loading

File-Level Changes

Change Details Files
Support sessionStartTime in VeloxQueryConfig
  • Add guard for session.startTime in updateFromSessionConfigs
  • Set queryConfigs[kSessionStartTime] to session.startTime
presto-native-execution/presto_cpp/main/PrestoToVeloxQueryConfig.cpp
Add unit tests for sessionStartTime propagation
  • Introduce TEST_F sessionStartTimeConfiguration
  • Verify propagation for default, overridden, zero, negative, and max values
presto-native-execution/presto_cpp/main/tests/PrestoToVeloxQueryConfigTest.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@kgpai
Copy link
Contributor Author

kgpai commented Sep 19, 2025

cc: @amitkdutta @kevinwilfong

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `presto-native-execution/presto_cpp/main/tests/PrestoToVeloxQueryConfigTest.cpp:487-499` </location>
<code_context>
+
+  EXPECT_EQ(0, veloxConfig3.sessionStartTimeMs());
+
+  // Test with negative start time (valid edge case)
+  session.startTime = -1000;
+  auto veloxConfig4 = toVeloxConfigs(session);
+
+  EXPECT_EQ(-1000, veloxConfig4.sessionStartTimeMs());
+
+  // Test with maximum value
</code_context>

<issue_to_address>
**suggestion (testing):** Consider adding a test for unset/absent sessionStartTime.

Testing the case where session.startTime is unset will confirm correct handling of missing values.

```suggestion
  // Test with zero start time (valid edge case)
  session.startTime = 0;
  auto veloxConfig3 = toVeloxConfigs(session);

  EXPECT_EQ(0, veloxConfig3.sessionStartTimeMs());

  // Test with unset/absent start time
  session.startTime = {};
  auto veloxConfigUnset = toVeloxConfigs(session);

  EXPECT_EQ(0, veloxConfigUnset.sessionStartTimeMs());

  // Test with negative start time (valid edge case)
  session.startTime = -1000;
  auto veloxConfig4 = toVeloxConfigs(session);

  EXPECT_EQ(-1000, veloxConfig4.sessionStartTimeMs());

  // Test with maximum value
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 487 to 565
// Test with zero start time (valid edge case)
session.startTime = 0;
auto veloxConfig3 = toVeloxConfigs(session);

EXPECT_EQ(0, veloxConfig3.sessionStartTimeMs());

// Test with negative start time (valid edge case)
session.startTime = -1000;
auto veloxConfig4 = toVeloxConfigs(session);

EXPECT_EQ(-1000, veloxConfig4.sessionStartTimeMs());

// Test with maximum value
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (testing): Consider adding a test for unset/absent sessionStartTime.

Testing the case where session.startTime is unset will confirm correct handling of missing values.

Suggested change
// Test with zero start time (valid edge case)
session.startTime = 0;
auto veloxConfig3 = toVeloxConfigs(session);
EXPECT_EQ(0, veloxConfig3.sessionStartTimeMs());
// Test with negative start time (valid edge case)
session.startTime = -1000;
auto veloxConfig4 = toVeloxConfigs(session);
EXPECT_EQ(-1000, veloxConfig4.sessionStartTimeMs());
// Test with maximum value
// Test with zero start time (valid edge case)
session.startTime = 0;
auto veloxConfig3 = toVeloxConfigs(session);
EXPECT_EQ(0, veloxConfig3.sessionStartTimeMs());
// Test with unset/absent start time
session.startTime = {};
auto veloxConfigUnset = toVeloxConfigs(session);
EXPECT_EQ(0, veloxConfigUnset.sessionStartTimeMs());
// Test with negative start time (valid edge case)
session.startTime = -1000;
auto veloxConfig4 = toVeloxConfigs(session);
EXPECT_EQ(-1000, veloxConfig4.sessionStartTimeMs());
// Test with maximum value

@kgpai kgpai force-pushed the add_session_start_time branch from 66748f3 to c39635d Compare September 19, 2025 22:03
@amitkdutta amitkdutta changed the title Add support for setting sessionStartTime in VeloxQueryConfig. [native] Add support for setting sessionStartTime in VeloxQueryConfig. Sep 19, 2025
Copy link
Contributor

@amitkdutta amitkdutta left a comment

Choose a reason for hiding this comment

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

Thanks @kgpai

@kgpai
Copy link
Contributor Author

kgpai commented Sep 20, 2025

@amitkdutta Time tests are failing :)

@amitkdutta
Copy link
Contributor

amitkdutta commented Sep 20, 2025

@kgpai We need to rebase. #26104 is merged now so tests will pass.

# Conflicts:
#	presto-native-execution/presto_cpp/main/tests/PrestoToVeloxQueryConfigTest.cpp
@kgpai kgpai force-pushed the add_session_start_time branch from c39635d to 8df23d6 Compare September 22, 2025 17:33
@kgpai
Copy link
Contributor Author

kgpai commented Sep 22, 2025

@amitkdutta I dont believe these failures are https://github.com/prestodb/presto/actions/runs/17923502131/job/50963889609?pr=26102 are related to this change ?

@kgpai kgpai merged commit 8c37a14 into prestodb:master Sep 23, 2025
78 of 79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from:Meta PR from Meta
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants