Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"strings"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
json2 "encoding/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package function
package json

import (
"gopkg.in/src-d/go-errors.v1"
Expand Down
59 changes: 30 additions & 29 deletions sql/expression/function/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/expression/function/aggregation"
"github.com/dolthub/go-mysql-server/sql/expression/function/aggregation/window"
"github.com/dolthub/go-mysql-server/sql/expression/function/json"
"github.com/dolthub/go-mysql-server/sql/expression/function/spatial"
)

Expand Down Expand Up @@ -106,37 +107,37 @@ var BuiltIns = []sql.Function{
sql.Function1{Name: "is_ipv6", Fn: NewIsIPv6},
sql.Function1{Name: "is_uuid", Fn: NewIsUUID},
sql.Function1{Name: "isnull", Fn: NewIsNull},
sql.FunctionN{Name: "json_array", Fn: NewJSONArray},
sql.FunctionN{Name: "json_array", Fn: json.NewJSONArray},
sql.Function1{Name: "json_arrayagg", Fn: func(e sql.Expression) sql.Expression { return aggregation.NewJsonArray(e) }},
sql.Function2{Name: "json_objectagg", Fn: aggregation.NewJSONObjectAgg},
sql.FunctionN{Name: "json_array_append", Fn: NewJSONArrayAppend},
sql.FunctionN{Name: "json_array_insert", Fn: NewJSONArrayInsert},
sql.FunctionN{Name: "json_contains", Fn: NewJSONContains},
sql.FunctionN{Name: "json_contains_path", Fn: NewJSONContainsPath},
sql.FunctionN{Name: "json_depth", Fn: NewJSONDepth},
sql.FunctionN{Name: "json_extract", Fn: NewJSONExtract},
sql.FunctionN{Name: "json_insert", Fn: NewJSONInsert},
sql.FunctionN{Name: "json_keys", Fn: NewJSONKeys},
sql.FunctionN{Name: "json_length", Fn: NewJSONLength},
sql.FunctionN{Name: "json_merge_patch", Fn: NewJSONMergePatch},
sql.FunctionN{Name: "json_merge_preserve", Fn: NewJSONMergePreserve},
sql.FunctionN{Name: "json_object", Fn: NewJSONObject},
sql.FunctionN{Name: "json_overlaps", Fn: NewJSONOverlaps},
sql.FunctionN{Name: "json_pretty", Fn: NewJSONPretty},
sql.FunctionN{Name: "json_quote", Fn: NewJSONQuote},
sql.FunctionN{Name: "json_remove", Fn: NewJSONRemove},
sql.FunctionN{Name: "json_replace", Fn: NewJSONReplace},
sql.FunctionN{Name: "json_schema_valid", Fn: NewJSONSchemaValid},
sql.FunctionN{Name: "json_schema_validation_report", Fn: NewJSONSchemaValidationReport},
sql.FunctionN{Name: "json_search", Fn: NewJSONSearch},
sql.FunctionN{Name: "json_set", Fn: NewJSONSet},
sql.FunctionN{Name: "json_storage_free", Fn: NewJSONStorageFree},
sql.FunctionN{Name: "json_storage_size", Fn: NewJSONStorageSize},
sql.FunctionN{Name: "json_table", Fn: NewJSONTable},
sql.FunctionN{Name: "json_type", Fn: NewJSONType},
sql.Function1{Name: "json_unquote", Fn: NewJSONUnquote},
sql.FunctionN{Name: "json_valid", Fn: NewJSONValid},
sql.FunctionN{Name: "json_value", Fn: NewJSONValue},
sql.FunctionN{Name: "json_array_append", Fn: json.NewJSONArrayAppend},
sql.FunctionN{Name: "json_array_insert", Fn: json.NewJSONArrayInsert},
sql.FunctionN{Name: "json_contains", Fn: json.NewJSONContains},
sql.FunctionN{Name: "json_contains_path", Fn: json.NewJSONContainsPath},
sql.FunctionN{Name: "json_depth", Fn: json.NewJSONDepth},
sql.FunctionN{Name: "json_extract", Fn: json.NewJSONExtract},
sql.FunctionN{Name: "json_insert", Fn: json.NewJSONInsert},
sql.FunctionN{Name: "json_keys", Fn: json.NewJSONKeys},
sql.FunctionN{Name: "json_length", Fn: json.NewJSONLength},
sql.FunctionN{Name: "json_merge_patch", Fn: json.NewJSONMergePatch},
sql.FunctionN{Name: "json_merge_preserve", Fn: json.NewJSONMergePreserve},
sql.FunctionN{Name: "json_object", Fn: json.NewJSONObject},
sql.FunctionN{Name: "json_overlaps", Fn: json.NewJSONOverlaps},
sql.FunctionN{Name: "json_pretty", Fn: json.NewJSONPretty},
sql.FunctionN{Name: "json_quote", Fn: json.NewJSONQuote},
sql.FunctionN{Name: "json_remove", Fn: json.NewJSONRemove},
sql.FunctionN{Name: "json_replace", Fn: json.NewJSONReplace},
sql.FunctionN{Name: "json_schema_valid", Fn: json.NewJSONSchemaValid},
sql.FunctionN{Name: "json_schema_validation_report", Fn: json.NewJSONSchemaValidationReport},
sql.FunctionN{Name: "json_search", Fn: json.NewJSONSearch},
sql.FunctionN{Name: "json_set", Fn: json.NewJSONSet},
sql.FunctionN{Name: "json_storage_free", Fn: json.NewJSONStorageFree},
sql.FunctionN{Name: "json_storage_size", Fn: json.NewJSONStorageSize},
sql.FunctionN{Name: "json_table", Fn: json.NewJSONTable},
sql.FunctionN{Name: "json_type", Fn: json.NewJSONType},
sql.Function1{Name: "json_unquote", Fn: json.NewJSONUnquote},
sql.FunctionN{Name: "json_valid", Fn: json.NewJSONValid},
sql.FunctionN{Name: "json_value", Fn: json.NewJSONValue},
sql.FunctionN{Name: "lag", Fn: func(e ...sql.Expression) (sql.Expression, error) { return window.NewLag(e...) }},
sql.Function1{Name: "last", Fn: func(e sql.Expression) sql.Expression { return aggregation.NewLast(e) }},
sql.FunctionN{Name: "last_insert_id", Fn: NewLastInsertId},
Expand Down
9 changes: 5 additions & 4 deletions sql/planbuilder/scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/dolthub/go-mysql-server/sql/encodings"
"github.com/dolthub/go-mysql-server/sql/expression"
"github.com/dolthub/go-mysql-server/sql/expression/function"
"github.com/dolthub/go-mysql-server/sql/expression/function/json"
"github.com/dolthub/go-mysql-server/sql/fulltext"
"github.com/dolthub/go-mysql-server/sql/plan"
"github.com/dolthub/go-mysql-server/sql/types"
Expand Down Expand Up @@ -428,13 +429,13 @@ func (b *Builder) buildBinaryScalar(inScope *scope, be *ast.BinaryExpr) sql.Expr
}

case ast.JSONExtractOp, ast.JSONUnquoteExtractOp:
jsonExtract, err := function.NewJSONExtract(l, r)
jsonExtract, err := json.NewJSONExtract(l, r)
if err != nil {
b.handleErr(err)
}

if operator == ast.JSONUnquoteExtractOp {
return function.NewJSONUnquote(jsonExtract)
return json.NewJSONUnquote(jsonExtract)
}
return jsonExtract

Expand Down Expand Up @@ -600,13 +601,13 @@ func (b *Builder) binaryExprToExpression(inScope *scope, be *ast.BinaryExpr) (sq
}

case ast.JSONExtractOp, ast.JSONUnquoteExtractOp:
jsonExtract, err := function.NewJSONExtract(l, r)
jsonExtract, err := json.NewJSONExtract(l, r)
if err != nil {
return nil, err
}

if operator == ast.JSONUnquoteExtractOp {
return function.NewJSONUnquote(jsonExtract), nil
return json.NewJSONUnquote(jsonExtract), nil
}
return jsonExtract, nil

Expand Down