You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "msyavuz (via GitHub)" <gi...@apache.org> on 2025/11/07 11:13:45 UTC

[PR] fix(date_parser): add check for time range timeshifts [superset]

msyavuz opened a new pull request, #36039:
URL: https://github.com/apache/superset/pull/36039

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   Check for timerange timeshifts when parsing the date to handle timeshift values like '2004-01-01 : 2005'.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   API call for adding a timeshift should work with a format like '2004-01-01 : 2005' when the   `DATE_RANGE_TIMESHIFTS_ENABLED` flag is enabled.
   
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(date_parser): add check for time range timeshifts [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #36039:
URL: https://github.com/apache/superset/pull/36039#discussion_r2509208838


##########
superset/utils/date_parser.py:
##########
@@ -477,10 +477,17 @@ def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-m
         )
 
     if time_shift:
-        time_delta_since = parse_past_timedelta(time_shift, _since)
-        time_delta_until = parse_past_timedelta(time_shift, _until)
-        _since = _since if _since is None else (_since - time_delta_since)
-        _until = _until if _until is None else (_until - time_delta_until)
+        if " : " in time_shift:
+            # Date range format: parse as a new time range
+            separator = " : "
+            since_part, until_part = time_shift.split(separator, 1)
+            _since = datetime_eval(f"DATETIME('{since_part.strip()}')")

Review Comment:
   Nice catch, fixed!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(date_parser): add check for time range timeshifts [superset]

Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #36039:
URL: https://github.com/apache/superset/pull/36039#discussion_r2502891739


##########
superset/utils/date_parser.py:
##########
@@ -477,10 +477,14 @@ def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-m
         )
 
     if time_shift:
-        time_delta_since = parse_past_timedelta(time_shift, _since)
-        time_delta_until = parse_past_timedelta(time_shift, _until)
-        _since = _since if _since is None else (_since - time_delta_since)
-        _until = _until if _until is None else (_until - time_delta_until)
+        if " : " in time_shift:
+            # Date range format: parse as a new time range
+            _since, _until = get_since_until(time_range=time_shift)

Review Comment:
   ### Recursive call loses function parameters <sub>![category Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The recursive call to get_since_until() when time_shift contains ' : ' passes only the time_range parameter but ignores all other parameters that were passed to the original function call.
   
   
   ###### Why this matters
   This could lead to inconsistent behavior where parameters like relative_start, relative_end, and instant_time_comparison_range are lost in the recursive call, potentially causing the time shift parsing to behave differently than expected.
   
   ###### Suggested change ∙ *Feature Preview*
   Pass the relevant parameters to the recursive call:
   ```python
   _since, _until = get_since_until(
       time_range=time_shift,
       relative_start=relative_start,
       relative_end=relative_end
   )
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e3cc2f23-6594-4199-8b22-faa5902189f8/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e3cc2f23-6594-4199-8b22-faa5902189f8?what_not_true=true)  [![Not in Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e3cc2f23-6594-4199-8b22-faa5902189f8?what_out_of_scope=true) [![Not in coding standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e3cc2f23-6594-4199-8b22-faa5902189f8?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e3cc2f23-6594-4199-8b22-faa5902189f8)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:2c7a4cf7-50f3-4e62-bda5-26eec2a6f861 -->
   
   
   [](2c7a4cf7-50f3-4e62-bda5-26eec2a6f861)



##########
superset/utils/date_parser.py:
##########
@@ -477,10 +477,14 @@ def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-m
         )
 
     if time_shift:
-        time_delta_since = parse_past_timedelta(time_shift, _since)
-        time_delta_until = parse_past_timedelta(time_shift, _until)
-        _since = _since if _since is None else (_since - time_delta_since)
-        _until = _until if _until is None else (_until - time_delta_until)
+        if " : " in time_shift:
+            # Date range format: parse as a new time range
+            _since, _until = get_since_until(time_range=time_shift)

Review Comment:
   ### Potential infinite recursion in time_shift processing <sub>![category Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   Recursive call to get_since_until() when time_shift contains " : " creates potential for infinite recursion and unnecessary function call overhead.
   
   
   ###### Why this matters
   If the time_shift parameter contains the same pattern that triggers this condition, it could lead to infinite recursion. Additionally, the recursive call adds function call overhead and stack frame allocation when a more direct parsing approach could be used.
   
   ###### Suggested change ∙ *Feature Preview*
   Add recursion depth tracking or parse the time_shift directly using the existing time range parsing logic without recursion. Consider extracting the time range parsing logic into a separate helper function that both code paths can use without recursive calls.
   
   ```python
   if " : " in time_shift:
       # Parse time_shift as time range directly to avoid recursion
       separator = " : "
       since_part, until_part = time_shift.split(separator, 1)
       # Use existing parsing logic without recursive call
       _since = datetime_eval(f"DATETIME('{since_part.strip()}')")
       _until = datetime_eval(f"DATETIME('{until_part.strip()}')")
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/7af7714f-a818-4fda-ace4-2d0b043ff611/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/7af7714f-a818-4fda-ace4-2d0b043ff611?what_not_true=true)  [![Not in Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/7af7714f-a818-4fda-ace4-2d0b043ff611?what_out_of_scope=true) [![Not in coding standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/7af7714f-a818-4fda-ace4-2d0b043ff611?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/7af7714f-a818-4fda-ace4-2d0b043ff611)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:661b11cf-08dc-49b2-be1b-92427bbc180f -->
   
   
   [](661b11cf-08dc-49b2-be1b-92427bbc180f)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(date_parser): add check for time range timeshifts [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #36039:
URL: https://github.com/apache/superset/pull/36039#discussion_r2502908266


##########
superset/utils/date_parser.py:
##########
@@ -477,10 +477,14 @@ def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-m
         )
 
     if time_shift:
-        time_delta_since = parse_past_timedelta(time_shift, _since)
-        time_delta_until = parse_past_timedelta(time_shift, _until)
-        _since = _since if _since is None else (_since - time_delta_since)
-        _until = _until if _until is None else (_until - time_delta_until)
+        if " : " in time_shift:
+            # Date range format: parse as a new time range
+            _since, _until = get_since_until(time_range=time_shift)

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Incorrect relative date handling in time_shift range parsing</b></div>
   <div id="fix">
   
   The recursive call to `get_since_until` when parsing `time_shift` as a date range fails to pass `relative_start` and `relative_end` parameters. This can lead to incorrect date calculations if the `time_shift` range uses relative dates, as the recursive call defaults to "today" instead of the original relative context. Pass these parameters to maintain consistency and prevent date parsing errors in production.
   </div>
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
           if " : " in time_shift:
               # Date range format: parse as a new time range
               _since, _until = get_since_until(
                   time_range=time_shift,
                   relative_start=relative_start,
                   relative_end=relative_end
               )
   ````
   
   </div>
   </details>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run <a href=https://github.com/apache/superset/pull/36039#issuecomment-3501939975>#e4353a</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(date_parser): add check for time range timeshifts [superset]

Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #36039:
URL: https://github.com/apache/superset/pull/36039#discussion_r2504739172


##########
superset/utils/date_parser.py:
##########
@@ -477,10 +477,17 @@ def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-m
         )
 
     if time_shift:
-        time_delta_since = parse_past_timedelta(time_shift, _since)
-        time_delta_until = parse_past_timedelta(time_shift, _until)
-        _since = _since if _since is None else (_since - time_delta_since)
-        _until = _until if _until is None else (_until - time_delta_until)
+        if " : " in time_shift:
+            # Date range format: parse as a new time range
+            separator = " : "
+            since_part, until_part = time_shift.split(separator, 1)
+            _since = datetime_eval(f"DATETIME('{since_part.strip()}')")
+            _until = datetime_eval(f"DATETIME('{until_part.strip()}')")

Review Comment:
   ### Time shift overrides instead of modifying existing time range <sub>![category Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The time_shift functionality completely overrides the existing _since and _until values when a date range format is detected, ignoring the original time range parameters.
   
   
   ###### Why this matters
   This breaks the expected behavior where time_shift should modify existing time ranges rather than replace them entirely. Users expecting time_shift to adjust their current time range will get unexpected results as their original range is completely discarded.
   
   ###### Suggested change ∙ *Feature Preview*
   The time_shift with date range format should either be treated as an error condition or should modify the existing _since and _until values rather than replacing them. Consider adding validation to prevent this conflicting usage:
   
   ```python
   if time_shift:
       if " : " in time_shift:
           # This conflicts with existing time range - should be an error
           raise ValueError("time_shift cannot contain date range format when time range is already specified")
       else:
           time_delta_since = parse_past_timedelta(time_shift, _since)
           time_delta_until = parse_past_timedelta(time_shift, _until)
           _since = _since if _since is None else (_since - time_delta_since)
           _until = _until if _until is None else (_until - time_delta_until)
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c73aa08d-7c32-4676-8a08-e39ec029d51c/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c73aa08d-7c32-4676-8a08-e39ec029d51c?what_not_true=true)  [![Not in Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c73aa08d-7c32-4676-8a08-e39ec029d51c?what_out_of_scope=true) [![Not in coding standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c73aa08d-7c32-4676-8a08-e39ec029d51c?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c73aa08d-7c32-4676-8a08-e39ec029d51c)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:2f601e74-161b-4aba-8f8c-a38131306124 -->
   
   
   [](2f601e74-161b-4aba-8f8c-a38131306124)



##########
superset/utils/date_parser.py:
##########
@@ -477,10 +477,17 @@ def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-m
         )
 
     if time_shift:
-        time_delta_since = parse_past_timedelta(time_shift, _since)
-        time_delta_until = parse_past_timedelta(time_shift, _until)
-        _since = _since if _since is None else (_since - time_delta_since)
-        _until = _until if _until is None else (_until - time_delta_until)
+        if " : " in time_shift:
+            # Date range format: parse as a new time range
+            separator = " : "
+            since_part, until_part = time_shift.split(separator, 1)

Review Comment:
   ### Redundant separator variable assignment <sub>![category Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The separator string " : " is defined as a local variable inside the conditional block, but the same separator is already defined earlier in the function scope.
   
   
   ###### Why this matters
   This creates unnecessary string object allocation and variable assignment when the same separator value is already available in the function scope, leading to minor memory overhead and redundant operations.
   
   ###### Suggested change ∙ *Feature Preview*
   Remove the local `separator = " : "` assignment and reuse the existing `separator` variable that was defined earlier in the function:
   
   ```python
   if separator in time_shift:
       # Date range format: parse as a new time range
       since_part, until_part = time_shift.split(separator, 1)
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/25f7b7be-b054-48ec-a394-6134258c3a28/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/25f7b7be-b054-48ec-a394-6134258c3a28?what_not_true=true)  [![Not in Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/25f7b7be-b054-48ec-a394-6134258c3a28?what_out_of_scope=true) [![Not in coding standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/25f7b7be-b054-48ec-a394-6134258c3a28?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/25f7b7be-b054-48ec-a394-6134258c3a28)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:6403e911-187f-4474-b475-53ee2c090bcc -->
   
   
   [](6403e911-187f-4474-b475-53ee2c090bcc)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(date_parser): add check for time range timeshifts [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #36039:
URL: https://github.com/apache/superset/pull/36039#issuecomment-3501939975

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(date_parser): add check for time range timeshifts [superset]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #36039:
URL: https://github.com/apache/superset/pull/36039#discussion_r2504926807


##########
superset/utils/date_parser.py:
##########
@@ -477,10 +477,17 @@ def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-m
         )
 
     if time_shift:
-        time_delta_since = parse_past_timedelta(time_shift, _since)
-        time_delta_until = parse_past_timedelta(time_shift, _until)
-        _since = _since if _since is None else (_since - time_delta_since)
-        _until = _until if _until is None else (_until - time_delta_until)
+        if " : " in time_shift:
+            # Date range format: parse as a new time range
+            separator = " : "
+            since_part, until_part = time_shift.split(separator, 1)
+            _since = datetime_eval(f"DATETIME('{since_part.strip()}')")
+            _until = datetime_eval(f"DATETIME('{until_part.strip()}')")

Review Comment:
   The time_shift date range parsing bypasses the sophisticated time_range_lookup logic (lines 419-465) that handles special patterns like 'start of next month', 'last 5 days', etc. This creates inconsistent behavior where 'today : tomorrow' works in time_range but patterns like 'last week : today' won't work in time_shift. Consider reusing the same parsing logic by extracting it into a reusable function.



##########
superset/utils/date_parser.py:
##########
@@ -477,10 +477,17 @@ def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-m
         )
 
     if time_shift:
-        time_delta_since = parse_past_timedelta(time_shift, _since)
-        time_delta_until = parse_past_timedelta(time_shift, _until)
-        _since = _since if _since is None else (_since - time_delta_since)
-        _until = _until if _until is None else (_until - time_delta_until)
+        if " : " in time_shift:
+            # Date range format: parse as a new time range
+            separator = " : "

Review Comment:
   The separator variable is redundant since it's already defined at line 347 with the same value. This line can be removed as the separator is already in scope.
   ```suggestion
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(date_parser): add check for time range timeshifts [superset]

Posted by "amaannawab923 (via GitHub)" <gi...@apache.org>.
amaannawab923 commented on code in PR #36039:
URL: https://github.com/apache/superset/pull/36039#discussion_r2505027806


##########
superset/utils/date_parser.py:
##########
@@ -477,10 +477,17 @@ def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-m
         )
 
     if time_shift:
-        time_delta_since = parse_past_timedelta(time_shift, _since)
-        time_delta_until = parse_past_timedelta(time_shift, _until)
-        _since = _since if _since is None else (_since - time_delta_since)
-        _until = _until if _until is None else (_until - time_delta_until)
+        if " : " in time_shift:
+            # Date range format: parse as a new time range
+            separator = " : "
+            since_part, until_part = time_shift.split(separator, 1)
+            _since = datetime_eval(f"DATETIME('{since_part.strip()}')")

Review Comment:
   Can we use parse_human_datetime() for _since , as it will work fine for this case without using f string 
    parts = time_shift.split(separator, 1)
             if len(parts) != 2:
                 raise ValueError(f"Invalid time_shift format: {time_shift}")
   
    since_part, until_part = (part.strip() for part in parts)
             _since = parse_human_datetime(since_part)
             _until = parse_human_datetime(until_part)
   
   Something like this i guess



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(date_parser): add check for time range timeshifts [superset]

Posted by "amaannawab923 (via GitHub)" <gi...@apache.org>.
amaannawab923 commented on code in PR #36039:
URL: https://github.com/apache/superset/pull/36039#discussion_r2505000990


##########
superset/utils/date_parser.py:
##########
@@ -477,10 +477,17 @@ def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-m
         )
 
     if time_shift:
-        time_delta_since = parse_past_timedelta(time_shift, _since)
-        time_delta_until = parse_past_timedelta(time_shift, _until)
-        _since = _since if _since is None else (_since - time_delta_since)
-        _until = _until if _until is None else (_until - time_delta_until)
+        if " : " in time_shift:
+            # Date range format: parse as a new time range

Review Comment:
   Should we just define the seperator variable at line 478 and then use it at line 480 and not redefine it at line 482



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(date_parser): add check for time range timeshifts [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #36039:
URL: https://github.com/apache/superset/pull/36039#discussion_r2509209756


##########
superset/utils/date_parser.py:
##########
@@ -477,10 +477,17 @@ def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-m
         )
 
     if time_shift:
-        time_delta_since = parse_past_timedelta(time_shift, _since)
-        time_delta_until = parse_past_timedelta(time_shift, _until)
-        _since = _since if _since is None else (_since - time_delta_since)
-        _until = _until if _until is None else (_until - time_delta_until)
+        if " : " in time_shift:
+            # Date range format: parse as a new time range

Review Comment:
   Good call, fixed this as well



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(date_parser): add check for time range timeshifts [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz merged PR #36039:
URL: https://github.com/apache/superset/pull/36039


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org