- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.7k
Remove null / nan related operations #15441
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
      
      
    
      
        
          +54
        
        
          −140
        
        
          
        
      
    
  
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            71 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      f1b5b5d
              
                [realppl 3] Arithmetic and comparison expressions
              
              
                wu-hui 6294868
              
                [realppl 4] Array, debug, field and logical expressions
              
              
                wu-hui 6c0a698
              
                [realppl 5] map,string,timestamp and mirroring semantics
              
              
                wu-hui 8efed9e
              
                [realppl 6] offline ppl evaluation and tests
              
              
                wu-hui 0a8821c
              
                [realppl 7] realppl integration with remote/local and unit tests
              
              
                wu-hui f79f655
              
                Remove Fuzzer
              
              
                wu-hui 8b8d4a2
              
                [realppl 8] realppl spec tests
              
              
                wu-hui 0d65b86
              
                [realppl 9] realppl public api and integration tests
              
              
                wu-hui a1ad8f9
              
                [realppl 10] Add server timestamp support
              
              
                wu-hui 3a10495
              
                [realppl 11] Add query to pipeline support
              
              
                wu-hui 5a50bd6
              
                Hide realtime pipelines
              
              
                wu-hui a54bd45
              
                address API feedbacks
              
              
                cherylEnkidu e76d2a2
              
                add documentation
              
              
                cherylEnkidu fac2f83
              
                rename Firestore/Swift/Source/ExprImpl.swift
              
              
                cherylEnkidu 2951a6c
              
                expand expr to expression
              
              
                cherylEnkidu afa920e
              
                move files
              
              
                cherylEnkidu d77d6d5
              
                move files
              
              
                cherylEnkidu 18fbbae
              
                move file
              
              
                cherylEnkidu 7c7eb75
              
                Separate PipelineSource and RealtimePipelineSource
              
              
                cherylEnkidu caf8158
              
                add abs()
              
              
                cherylEnkidu fb482c7
              
                add arrayReverse
              
              
                cherylEnkidu 62434c1
              
                add ceil()
              
              
                cherylEnkidu d5d5c9d
              
                add collectionId()
              
              
                cherylEnkidu 11bf771
              
                add countDistinct()
              
              
                cherylEnkidu 0e39951
              
                [realppl 8] realppl spec tests
              
              
                wu-hui 016dac0
              
                [realppl 9] realppl public api and integration tests
              
              
                wu-hui 00c6256
              
                add exp()
              
              
                cherylEnkidu 854b6bb
              
                [realppl 10] Add query to pipeline support
              
              
                wu-hui 814074f
              
                make all bit operations internal
              
              
                cherylEnkidu 54461f1
              
                add floor()
              
              
                cherylEnkidu 8e8557f
              
                add length()
              
              
                cherylEnkidu ead6684
              
                hide manhattanDistance()
              
              
                cherylEnkidu c720527
              
                add ln()
              
              
                cherylEnkidu b51b545
              
                Hide realtime pipelines
              
              
                wu-hui 69ced35
              
                add pow()
              
              
                cherylEnkidu 3d0a3d3
              
                hide replace expression
              
              
                cherylEnkidu 617feb4
              
                rename substring
              
              
                cherylEnkidu 5bc46e3
              
                add more expressions
              
              
                cherylEnkidu 452875f
              
                make internal impl of Order public
              
              
                cherylEnkidu 3a258b2
              
                rename timestampSubtract
              
              
                cherylEnkidu 1c00eea
              
                refactor snapshot
              
              
                cherylEnkidu aaa7855
              
                move file
              
              
                cherylEnkidu d02c044
              
                remove backpointer to parent
              
              
                cherylEnkidu fd8ed65
              
                equivalent()
              
              
                cherylEnkidu 418e3a6
              
                merge in base branch
              
              
                cherylEnkidu e42cce2
              
                merge in base 2
              
              
                cherylEnkidu 2fb7a14
              
                add concat()
              
              
                cherylEnkidu 8422b15
              
                add currentTimestamp()
              
              
                cherylEnkidu 45797e1
              
                hide equivalent
              
              
                cherylEnkidu b377edb
              
                add ifAbsent and error
              
              
                cherylEnkidu 903425b
              
                add join()
              
              
                cherylEnkidu 50b673e
              
                rename logical
              
              
                cherylEnkidu 41fcae2
              
                add name tag for FunctionExpression
              
              
                cherylEnkidu a4d33e4
              
                add missing tags
              
              
                cherylEnkidu 91b0dec
              
                add documentations
              
              
                cherylEnkidu d8c5c81
              
                add documentations 2
              
              
                cherylEnkidu 88586a1
              
                rebase to feature branch
              
              
                cherylEnkidu 43fb9ef
              
                fix rebase error 1
              
              
                cherylEnkidu 77e4556
              
                resolve rebase error
              
              
                cherylEnkidu dfce952
              
                fix broken tests
              
              
                cherylEnkidu 8005a23
              
                format code
              
              
                cherylEnkidu 7a357c2
              
                add map_set
              
              
                cherylEnkidu bc1a2b7
              
                add equivalent
              
              
                cherylEnkidu 72b89fd
              
                add TimestampTrunc
              
              
                cherylEnkidu 2e18c4a
              
                Revert "add equivalent"
              
              
                cherylEnkidu 3475b66
              
                solve rebase error
              
              
                cherylEnkidu 7aed083
              
                remove null / nan related operations
              
              
                cherylEnkidu 78c00d8
              
                change logic to remove null handling
              
              
                cherylEnkidu 1c9df2a
              
                address feedbacks
              
              
                cherylEnkidu af33109
              
                merge in main branch
              
              
                cherylEnkidu 219add6
              
                solve merge error
              
              
                cherylEnkidu 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
    
  
  
    
              
              
  
    
      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 | 
|---|---|---|
|  | @@ -554,87 +554,58 @@ std::shared_ptr<api::Expr> ToPipelineBooleanExpr(const Filter& filter) { | |
| const google_firestore_v1_Value& value = field_filter.value(); | ||
| FieldFilter::Operator op = field_filter.op(); | ||
|  | ||
| if (model::IsNaNValue(value)) { | ||
| auto is_nan_expr = std::make_shared<api::FunctionExpr>( | ||
| "is_nan", std::vector<std::shared_ptr<api::Expr>>{api_field}); | ||
| if (op == FieldFilter::Operator::Equal) { | ||
| return std::make_shared<api::FunctionExpr>( | ||
| "and", | ||
| std::vector<std::shared_ptr<api::Expr>>{exists_expr, is_nan_expr}); | ||
| } else { // Assuming NotEqual for IsNotNan | ||
| auto is_not_nan_expr = std::make_shared<api::FunctionExpr>( | ||
| "not", std::vector<std::shared_ptr<api::Expr>>{is_nan_expr}); | ||
| return std::make_shared<api::FunctionExpr>( | ||
| "and", std::vector<std::shared_ptr<api::Expr>>{exists_expr, | ||
| is_not_nan_expr}); | ||
| auto api_constant = | ||
| std::make_shared<api::Constant>(model::DeepClone(value)); | ||
| std::shared_ptr<api::Expr> comparison_expr; | ||
| std::string func_name; | ||
|  | ||
| switch (op) { | ||
| case FieldFilter::Operator::LessThan: | ||
| func_name = "lt"; | ||
| 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. Should these functions be renamed? 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. yes, this part would be address when fixing realtime ppl implementation. So it is not included in this PR. | ||
| break; | ||
| case FieldFilter::Operator::LessThanOrEqual: | ||
| func_name = "lte"; | ||
| break; | ||
| case FieldFilter::Operator::GreaterThan: | ||
| func_name = "gt"; | ||
| break; | ||
| case FieldFilter::Operator::GreaterThanOrEqual: | ||
| func_name = "gte"; | ||
| break; | ||
| case FieldFilter::Operator::Equal: | ||
| func_name = "eq"; | ||
| break; | ||
| case FieldFilter::Operator::NotEqual: | ||
| func_name = "neq"; | ||
| break; | ||
| case FieldFilter::Operator::ArrayContains: | ||
| func_name = "array_contains"; | ||
| break; | ||
| case FieldFilter::Operator::In: | ||
| case FieldFilter::Operator::NotIn: | ||
| case FieldFilter::Operator::ArrayContainsAny: { | ||
| HARD_ASSERT( | ||
| model::IsArray(value), | ||
| "Value for IN, NOT_IN, ARRAY_CONTAINS_ANY must be an array."); | ||
|  | ||
| if (op == FieldFilter::Operator::In) | ||
| func_name = "eq_any"; | ||
| else if (op == FieldFilter::Operator::NotIn) | ||
| func_name = "not_eq_any"; | ||
| else if (op == FieldFilter::Operator::ArrayContainsAny) | ||
| func_name = "array_contains_any"; | ||
| break; | ||
| } | ||
| } else if (model::IsNullValue(value)) { | ||
| auto is_null_expr = std::make_shared<api::FunctionExpr>( | ||
| "is_null", std::vector<std::shared_ptr<api::Expr>>{api_field}); | ||
| if (op == FieldFilter::Operator::Equal) { | ||
| return std::make_shared<api::FunctionExpr>( | ||
| "and", | ||
| std::vector<std::shared_ptr<api::Expr>>{exists_expr, is_null_expr}); | ||
| } else { // Assuming NotEqual for IsNotNull | ||
| auto is_not_null_expr = std::make_shared<api::FunctionExpr>( | ||
| "not", std::vector<std::shared_ptr<api::Expr>>{is_null_expr}); | ||
| return std::make_shared<api::FunctionExpr>( | ||
| "and", std::vector<std::shared_ptr<api::Expr>>{exists_expr, | ||
| is_not_null_expr}); | ||
| } | ||
| } else { | ||
| auto api_constant = | ||
| std::make_shared<api::Constant>(model::DeepClone(value)); | ||
| std::shared_ptr<api::Expr> comparison_expr; | ||
| std::string func_name; | ||
|  | ||
| switch (op) { | ||
| case FieldFilter::Operator::LessThan: | ||
| func_name = "lt"; | ||
| break; | ||
| case FieldFilter::Operator::LessThanOrEqual: | ||
| func_name = "lte"; | ||
| break; | ||
| case FieldFilter::Operator::GreaterThan: | ||
| func_name = "gt"; | ||
| break; | ||
| case FieldFilter::Operator::GreaterThanOrEqual: | ||
| func_name = "gte"; | ||
| break; | ||
| case FieldFilter::Operator::Equal: | ||
| func_name = "eq"; | ||
| break; | ||
| case FieldFilter::Operator::NotEqual: | ||
| func_name = "neq"; | ||
| break; | ||
| case FieldFilter::Operator::ArrayContains: | ||
| func_name = "array_contains"; | ||
| break; | ||
| case FieldFilter::Operator::In: | ||
| case FieldFilter::Operator::NotIn: | ||
| case FieldFilter::Operator::ArrayContainsAny: { | ||
| HARD_ASSERT( | ||
| model::IsArray(value), | ||
| "Value for IN, NOT_IN, ARRAY_CONTAINS_ANY must be an array."); | ||
|  | ||
| if (op == FieldFilter::Operator::In) | ||
| func_name = "eq_any"; | ||
| else if (op == FieldFilter::Operator::NotIn) | ||
| func_name = "not_eq_any"; | ||
| else if (op == FieldFilter::Operator::ArrayContainsAny) | ||
| func_name = "array_contains_any"; | ||
| break; | ||
| } | ||
| default: | ||
| HARD_FAIL("Unexpected FieldFilter operator."); | ||
| } | ||
| comparison_expr = std::make_shared<api::FunctionExpr>( | ||
| func_name, | ||
| std::vector<std::shared_ptr<api::Expr>>{api_field, api_constant}); | ||
| return std::make_shared<api::FunctionExpr>( | ||
| "and", std::vector<std::shared_ptr<api::Expr>>{exists_expr, | ||
| comparison_expr}); | ||
| default: | ||
| HARD_FAIL("Unexpected FieldFilter operator."); | ||
| } | ||
| comparison_expr = std::make_shared<api::FunctionExpr>( | ||
| func_name, | ||
| std::vector<std::shared_ptr<api::Expr>>{api_field, api_constant}); | ||
| return std::make_shared<api::FunctionExpr>( | ||
| "and", | ||
| std::vector<std::shared_ptr<api::Expr>>{exists_expr, comparison_expr}); | ||
|  | ||
| } else if (filter.type() == FieldFilter::Type::kCompositeFilter) { | ||
| const auto& composite_filter = static_cast<const CompositeFilter&>(filter); | ||
| std::vector<std::shared_ptr<api::Expr>> sub_exprs; | ||
|  | ||
      
      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.
Instead of deleting them, you can add Field(rating) == nil instead.
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 will add back this test. But the iOS SDK only implemented operator overload for ^, !, and ||. So it is still Field(rating).equals(nil)