- 
                Notifications
    
You must be signed in to change notification settings  - Fork 25.6k
 
[ESQL] Ensure date/date_nanos implicit casting rule behind snapshot #130026
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
          
     Merged
      
      
            fang-xing-esql
  merged 17 commits into
  elastic:main
from
fang-xing-esql:date-nanos-implicit-casting-behind-snapshot
  
      
      
   
  Jul 2, 2025 
      
    
  
     Merged
                    Changes from 4 commits
      Commits
    
    
            Show all changes
          
          
            17 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      f865774
              
                put date date_nanos implicit casting rule behind snapshot
              
              
                fang-xing-esql 033bf4a
              
                Update docs/changelog/130026.yaml
              
              
                fang-xing-esql 5c33194
              
                Merge branch 'main' into date-nanos-implicit-casting-behind-snapshot
              
              
                fang-xing-esql dbfea50
              
                Merge branch 'main' into date-nanos-implicit-casting-behind-snapshot
              
              
                fang-xing-esql 623c4cc
              
                Merge branch 'main' into date-nanos-implicit-casting-behind-snapshot
              
              
                fang-xing-esql cc4dac3
              
                update according to review comments
              
              
                fang-xing-esql d99300c
              
                Merge branch 'main' into date-nanos-implicit-casting-behind-snapshot
              
              
                fang-xing-esql 19a29cd
              
                Merge branch 'main' into date-nanos-implicit-casting-behind-snapshot
              
              
                fang-xing-esql 3ac7e58
              
                Merge branch 'main' into date-nanos-implicit-casting-behind-snapshot
              
              
                fang-xing-esql 12c2693
              
                Merge branch 'main' into date-nanos-implicit-casting-behind-snapshot
              
              
                fang-xing-esql 921eb11
              
                Merge branch 'main' into date-nanos-implicit-casting-behind-snapshot
              
              
                fang-xing-esql 2489f5d
              
                Merge branch 'main' into date-nanos-implicit-casting-behind-snapshot
              
              
                fang-xing-esql 3549595
              
                Merge branch 'main' into date-nanos-implicit-casting-behind-snapshot
              
              
                fang-xing-esql b33b12a
              
                Update docs/changelog/130026.yaml
              
              
                fang-xing-esql ad4f789
              
                clean up
              
              
                fang-xing-esql 945efd5
              
                Update docs/changelog/130026.yaml
              
              
                fang-xing-esql 76b3548
              
                remove/undo changelog
              
              
                fang-xing-esql File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| pr: 130026 | ||
| summary: Ensure date/date_nanos implicit casting rule behind snapshot | ||
| area: ES|QL | ||
| type: bug | ||
| issues: | ||
| - 130003 | ||
                
      
                  alex-spies marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -134,6 +134,7 @@ | |
| import static java.util.Collections.emptyList; | ||
| import static java.util.Collections.singletonList; | ||
| import static org.elasticsearch.xpack.core.enrich.EnrichPolicy.GEO_MATCH_TYPE; | ||
| import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.IMPLICIT_CASTING_DATE_AND_DATE_NANOS; | ||
| import static org.elasticsearch.xpack.esql.core.type.DataType.BOOLEAN; | ||
| import static org.elasticsearch.xpack.esql.core.type.DataType.DATETIME; | ||
| import static org.elasticsearch.xpack.esql.core.type.DataType.DATE_NANOS; | ||
| 
          
            
          
           | 
    @@ -1819,10 +1820,6 @@ private static boolean canConvertOriginalTypes(MultiTypeEsField multiTypeEsField | |
| 
     | 
||
| private static Expression typeSpecificConvert(ConvertFunction convert, Source source, DataType type, InvalidMappedField mtf) { | ||
| EsField field = new EsField(mtf.getName(), type, mtf.getProperties(), mtf.isAggregatable()); | ||
| return typeSpecificConvert(convert, source, field); | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a small refactor.  | 
||
| } | ||
| 
     | 
||
| private static Expression typeSpecificConvert(ConvertFunction convert, Source source, EsField field) { | ||
| FieldAttribute originalFieldAttr = (FieldAttribute) convert.field(); | ||
| FieldAttribute resolvedAttr = new FieldAttribute( | ||
| source, | ||
| 
          
            
          
           | 
    @@ -1904,6 +1901,9 @@ private static LogicalPlan planWithoutSyntheticAttributes(LogicalPlan plan) { | |
| private static class DateMillisToNanosInEsRelation extends Rule<LogicalPlan, LogicalPlan> { | ||
| @Override | ||
| public LogicalPlan apply(LogicalPlan plan) { | ||
| if (IMPLICIT_CASTING_DATE_AND_DATE_NANOS.isEnabled() == false) { | ||
| return plan; | ||
| } | ||
                
      
                  alex-spies marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| return plan.transformUp(EsRelation.class, relation -> { | ||
| if (relation.indexMode() == IndexMode.LOOKUP) { | ||
| return relation; | ||
| 
          
            
          
           | 
    ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This re-appeared - I think you'll have to mark this PR as
>non-issue, otherwise the bot will probably insist on the changelog entry.