Skip to content

Commit

Permalink
Merge pull request #58 from dolthub/daylon/all-commands
Browse files Browse the repository at this point in the history
Parser Tests Tool
  • Loading branch information
Hydrocharged authored Nov 29, 2023
2 parents 5da75fd + 9e82020 commit 85686ac
Show file tree
Hide file tree
Showing 198 changed files with 3,853 additions and 23 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/dolthub/doltgresql
go 1.21

require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a
github.com/cockroachdb/errors v1.7.5
github.com/dolthub/dolt/go v0.40.5-0.20231114163244-0cc42b844045
Expand All @@ -19,6 +20,7 @@ require (
github.com/lib/pq v1.10.2
github.com/madflojo/testcerts v1.1.1
github.com/pierrre/geohash v1.0.0
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.8.2
github.com/tidwall/gjson v1.14.4
github.com/twpayne/go-geom v1.3.6
Expand All @@ -36,6 +38,7 @@ require (
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db // indirect
github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible // indirect
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 // indirect
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/apache/thrift v0.13.1-0.20201008052519-daf620915714 // indirect
github.com/aws/aws-sdk-go v1.34.0 // indirect
github.com/bcicen/jstream v1.0.0 // indirect
Expand Down Expand Up @@ -109,7 +112,6 @@ require (
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/silvasur/buzhash v0.0.0-20160816060738-9bdec3dec7c6 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/tealeg/xlsx v1.0.5 // indirect
github.com/tetratelabs/wazero v1.1.0 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jB
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc=
Expand All @@ -103,6 +105,8 @@ github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible h1:QoRMR0TCctLDqBCMyOu1e
github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apache/thrift v0.0.0-20181112125854-24918abba929/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
Expand Down Expand Up @@ -1044,11 +1048,13 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down
8 changes: 4 additions & 4 deletions server/ast/column_table_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func nodeColumnTableDef(node *tree.ColumnTableDef) (_ *vitess.ColumnDefinition,
return nil, fmt.Errorf("FAMILY is not yet supported")
}

typeParams, err := nodeResolvableTypeReference(node.Type)
convertType, err := nodeResolvableTypeReference(node.Type)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -104,13 +104,13 @@ func nodeColumnTableDef(node *tree.ColumnTableDef) (_ *vitess.ColumnDefinition,
return &vitess.ColumnDefinition{
Name: vitess.NewColIdent(string(node.Name)),
Type: vitess.ColumnType{
Type: typeParams.name,
Type: convertType.Type,
Null: isNull,
NotNull: isNotNull,
Autoincrement: vitess.BoolVal(node.IsSerial),
Default: defaultExpr,
Length: typeParams.length,
Scale: typeParams.scale,
Length: convertType.Length,
Scale: convertType.Scale,
KeyOpt: keyOpt,
ForeignKeyDef: fkDef,
GeneratedExpr: generated,
Expand Down
9 changes: 2 additions & 7 deletions server/ast/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,15 @@ func nodeExpr(node tree.Expr) (vitess.Expr, error) {
return nil, fmt.Errorf("unknown cast syntax")
}

params, err := nodeResolvableTypeReference(node.Type)
convertType, err := nodeResolvableTypeReference(node.Type)
if err != nil {
return nil, err
}

return &vitess.ConvertExpr{
Name: "CAST",
Expr: expr,
Type: &vitess.ConvertType{
Type: params.name,
Length: params.length,
Scale: params.scale,
Charset: "", // TODO
},
Type: convertType,
}, nil
case *tree.CoalesceExpr:
return nil, fmt.Errorf("COALESCE is not yet supported")
Expand Down
18 changes: 7 additions & 11 deletions server/ast/resolvable_type_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@ import (
"github.com/dolthub/doltgresql/postgres/parser/types"
)

type typeParams struct {
name string
length *vitess.SQLVal
scale *vitess.SQLVal
}

func nodeResolvableTypeReference(typ tree.ResolvableTypeReference) (*typeParams, error) {
// nodeResolvableTypeReference handles tree.ResolvableTypeReference nodes.
func nodeResolvableTypeReference(typ tree.ResolvableTypeReference) (*vitess.ConvertType, error) {
if typ == nil {
return nil, nil
}
Expand Down Expand Up @@ -62,9 +57,10 @@ func nodeResolvableTypeReference(typ tree.ResolvableTypeReference) (*typeParams,
}
}

return &typeParams{
name: columnTypeName,
length: columnTypeLength,
scale: columnTypeScale,
return &vitess.ConvertType{
Type: columnTypeName,
Length: columnTypeLength,
Scale: columnTypeScale,
Charset: "", // TODO
}, nil
}
Loading

0 comments on commit 85686ac

Please sign in to comment.