- 
                Notifications
    You must be signed in to change notification settings 
- Fork 25.6k
[ES|QL] Assign new id to alias created by ReplaceMissingFieldWithNull when there is lookup join #125462
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
          
     Closed
      
      
    
  
     Closed
                    [ES|QL] Assign new id to alias created by ReplaceMissingFieldWithNull when there is lookup join #125462
Changes from 4 commits
      Commits
    
    
            Show all changes
          
          
            11 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      13b35e6
              
                assign new id to aliases created by ReplaceMissingFieldWithNull
              
              
                fang-xing-esql 45553bb
              
                Update docs/changelog/125462.yaml
              
              
                fang-xing-esql 4f5fcc6
              
                Merge branch 'main' into layout-build-npe
              
              
                fang-xing-esql 95a461f
              
                fix test
              
              
                fang-xing-esql f705ed4
              
                more tests and comments
              
              
                fang-xing-esql 2a21697
              
                update tests
              
              
                fang-xing-esql e6a055b
              
                add EsqlCapabilities to skip tests on older versions that don't have …
              
              
                fang-xing-esql 3723510
              
                Merge branch 'main' into layout-build-npe
              
              
                fang-xing-esql 25dc590
              
                add tests for MvExpand and Aggregate with multiple batches
              
              
                fang-xing-esql 92985fa
              
                Merge branch 'main' into layout-build-npe
              
              
                fang-xing-esql a825a5b
              
                Merge branch 'main' into layout-build-npe
              
              
                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: 125462 | ||
| summary: Assign new id to alias created by `ReplaceMissingFieldWithNull` when there | ||
| is lookup join | ||
| area: ES|QL | ||
| type: bug | ||
| issues: [] | 
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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 | 
|---|---|---|
|  | @@ -81,7 +81,9 @@ else if (plan instanceof Project project) { | |
| Alias nullAlias = nullLiteral.get(f.dataType()); | ||
| // save the first field as null (per datatype) | ||
| if (nullAlias == null) { | ||
| Alias alias = new Alias(f.source(), f.name(), Literal.of(f, null), f.id()); | ||
| Alias alias = joinAttributes.isEmpty() | ||
| ? new Alias(f.source(), f.name(), Literal.of(f, null), f.id()) | ||
| : new Alias(f.source(), f.name(), Literal.of(f, null)); | ||
|          | ||
| nullLiteral.put(dt, alias); | ||
| projection = alias.toAttribute(); | ||
| } | ||
|  | ||
      
      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.
I tried the following, and it gives "no child with doc id found" in
InsertFieldExtraction:That's the diff from
ReplaceMissingFieldWithNull:Notice how
MvExpandnow references a missing attribute.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.
Thanks for reviewing @alex-spies!
Today,
ReplaceMissingFieldWithNullonly replace missing fields inProject,Eval,Filter,OrderBy,RegexExtractandTopN, it doesn't replace missing fields in the other commands likeMvExpand. One option I can think of is whether covering more commands in this rule can solve this problem, I'll give it a try, if birth_date can be identified as a missing field forMvExpand, and if replacing it with a null alias works.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.
Thank you for catching this issue with
MvExpand@alex-spies ! I addedMvExpandinReplaceMissingFieldWithNull, so that the missing field(target) referenced byMvExpandis replaced by null, expanded's id is kept unchanged, and also added some tests forMvExpandandAggregationafter lookup joins.ReplaceMissingFieldWithNulldoes not replace missing fields in aggregations, however I haven't seen queries failed because of it yet, perhaps the downstream processes aggregations in a smarter way.Another option to address #121754 is to remove duplicated entries(
ChannelSet) in the layout, in case duplicated entries are expected or not avoidable, so that theDefaultLayout.inverse()does not create a nullChannelSetin the list.