matrixone icon indicating copy to clipboard operation
matrixone copied to clipboard

Add jq and try_jq function.

Open fengttt opened this issue 7 months ago • 2 comments

User description

What type of PR is this?

  • [ ] API-change
  • [ ] BUG
  • [ ] Improvement
  • [ ] Documentation
  • [x] Feature
  • [ ] Test and CI
  • [ ] Code Refactoring

Which issue(s) this PR fixes:

issue #17134

What this PR does / why we need it:

Added jq and try_jq function.


PR Type

Enhancement, Tests


Description

  • Added new jq and try_jq functions for JSON querying.
  • Implemented caching for jq queries and added an encoder for jq results.
  • Refactored Or method in Nulls to modify in place.
  • Added methods for handling null values in FunctionResult.
  • Updated null handling in opBinaryStrStrToFixedWithErrorCheck to use new FunctionResult methods.
  • Added null checks in FunctionSelectList methods.
  • Added JQ and TRY_JQ function IDs.
  • Added jq and try_jq to the list of supported functions.
  • Added gojq dependency and updated golang.org/x/sys dependency.
  • Added test cases and SQL test script for jq and try_jq functions.

Changes walkthrough 📝

Relevant files
Enhancement
7 files
nulls.go
Refactor `Or` method in `Nulls` to modify in place             

pkg/container/nulls/nulls.go

  • Refactored Or method to modify nsp in place instead of returning a new
    Nulls object.
  • +4/-11   
    functionTools.go
    Add null handling methods to `FunctionResult`                       

    pkg/container/vector/functionTools.go

    • Added methods for handling null values in FunctionResult.
    +17/-0   
    baseTemplate.go
    Update null handling in `opBinaryStrStrToFixedWithErrorCheck`

    pkg/sql/plan/function/baseTemplate.go

  • Updated null handling in opBinaryStrStrToFixedWithErrorCheck to use
    new FunctionResult methods.
  • +14/-15 
    func_builtin_jq.go
    Add `jq` and `try_jq` functions for JSON querying               

    pkg/sql/plan/function/func_builtin_jq.go

  • Added new jq and try_jq functions for JSON querying.
  • Implemented caching for jq queries.
  • Added an encoder for jq results.
  • +491/-0 
    function.go
    Add null checks in `FunctionSelectList` methods                   

    pkg/sql/plan/function/function.go

    • Added null checks in FunctionSelectList methods.
    +9/-0     
    function_id.go
    Add `JQ` and `TRY_JQ` function IDs                                             

    pkg/sql/plan/function/function_id.go

    • Added JQ and TRY_JQ function IDs.
    +4/-0     
    list_builtIn.go
    Add `jq` and `try_jq` to supported functions                         

    pkg/sql/plan/function/list_builtIn.go

    • Added jq and try_jq to the list of supported functions.
    +40/-0   
    Dependencies
    2 files
    go.mod
    Add `gojq` dependency and update `golang.org/x/sys`           

    go.mod

    • Added gojq dependency.
    • Updated golang.org/x/sys dependency.
    +4/-2     
    go.sum
    Update checksums for dependencies                                               

    go.sum

    • Updated checksums for new and updated dependencies.
    +10/-5   
    Tests
    2 files
    func_jq.result
    Add test cases for `jq` and `try_jq` functions                     

    test/distributed/cases/function/func_jq.result

    • Added test cases for jq and try_jq functions.
    +306/-0 
    func_jq.sql
    Add SQL test script for `jq` and `try_jq` functions           

    test/distributed/cases/function/func_jq.sql

    • Added SQL test script for jq and try_jq functions.
    +125/-0 

    💡 PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    fengttt avatar Jun 29 '24 06:06 fengttt