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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 18 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
]
},
{
"name": "Debug exec \"show services from google where name = 'abusiveexperiencereport';\" -- prebuilt with cmake",
"name": "Debug exec \"show services from google where name = 'abusiveexperiencereport';\" ",
"type": "go",
"request": "launch",
"mode": "debug",
Expand Down Expand Up @@ -143,17 +143,18 @@
},
// ' registry pull okta
{
"name": "DEBUG pull okta ... ;",
"name": "DEBUG pull okta v2.0.1 ;",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/stackql",
"args": [
"registry",
"--registry={ \"useEmbedded\": false, \"url\": \"https://raw.githubusercontent.com/stackql/stackql-provider-registry/intial-devel/providers\" }",
"--registry={ \"useEmbedded\": false, \"url\": \"https://cdn.statically.io/gh/stackql/stackql-provider-registry/feature/provider-pointer-changes/providers\" }",
"--auth={ \"google\": { \"credentialsfilepath\": \"${workspaceFolder}/keys/sa-key.json\" }, \"okta\": { \"credentialsfilepath\": \"${workspaceFolder}/keys/okta-token.txt\", \"type\": \"api_key\" } }",
"pull",
"okta"
"okta",
"v2.0.1"
],
},
// { "url": "file://${workspaceFolder}/examples/registry'${PROVIDER_REGISTRY_ROOT_DIR}'", "localDocRoot": "'${PROVIDER_REGISTRY_ROOT_DIR}'", "useEmbedded": false, "verifyConfig": {"nopVerify": true } }
Expand Down Expand Up @@ -183,6 +184,19 @@
"select column_anon as f from publicapis.api.categories where column_anon like 'B%' limit 10;"
],
},
{
"name": "DEBUG join #1 ... ;",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/stackql",
"args": [
"exec",
"--registry={ \"useEmbedded\": false, \"url\": \"file://${workspaceFolder}/test/registry\", \"localDocRoot\": \"${workspaceFolder}/test/registry\", \"verifyConfig\": { \"nopVerify\": true } }",
"--auth={ \"publicapis\": { \"type\": \"null_auth\" }, \"google\": { \"credentialsfilepath\": \"${workspaceFolder}/keys/sa-key.json\" }, \"okta\": { \"credentialsfilepath\": \"${workspaceFolder}/keys/okta-token.txt\", \"type\": \"api_key\" } }",
"select d1.name, d1.id from google.compute.disks d1 inner join google.compute.disks d2 on d1.id = d2.id where d1.project = 'lab-kr-network-01' and d1.zone = 'australia-southeast1-a' and d2.project = 'lab-kr-network-01' and d2.zone = 'australia-southeast1-a';"
],
},
{
"name": "DEBUG BYO API ... ;",
"type": "go",
Expand Down
2 changes: 1 addition & 1 deletion docs/registry_contribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Example as per [examples/registry/src/publicapis/v1/services/api-v1.yaml](/examp

### 3. Run `stackql` with config to support local Provider development.

Configure `stackql` to use your docs, bia the `--registry` command line argument. The [example integration section](#Configuring-StackQL-to-consume-a-local-development-registry) expands upon this.
Configure `stackql` to use your docs, via the `--registry` command line argument. The [example integration section](#Configuring-StackQL-to-consume-a-local-development-registry) expands upon this.

### 4. Iterate and verify that `stackql` works as expected against your new provider.

Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,23 @@ require (
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.10.1
github.com/stackql/go-openapistackql v0.0.5-rc02
github.com/stackql/go-openapistackql v0.0.6-alpha12
github.com/stackql/go-sqlite3 v0.0.1-stackqlrc01
github.com/stackql/go-suffix-map v0.0.1-alpha01
go.uber.org/zap v1.21.0
golang.org/x/crypto v0.0.0-20220214200702-86341886e292
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
gonum.org/v1/gonum v0.9.3
gopkg.in/yaml.v2 v2.4.0
gotest.tools v2.2.0+incompatible
readline v0.0.0-00010101000000-000000000000
vitess.io/vitess v0.0.10-rc01
vitess.io/vitess v0.0.11-alpha04
)

replace readline => github.com/stackql/readline v0.0.1-rc01

replace github.com/fatih/color => github.com/stackql/color v0.0.1-rc01

replace vitess.io/vitess => github.com/stackql/vitess v0.0.10-rc01
replace vitess.io/vitess => github.com/stackql/vitess v0.0.11-alpha04

replace github.com/jeroenrinzema/psql-wire => github.com/stackql/psql-wire v0.0.1-stackqlrc01
32 changes: 32 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKz
github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Masterminds/glide v0.13.2/go.mod h1:STyF5vcenH/rUqTEv+/hBXlSTo7KYwg2oc2f4tzPWic=
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/Masterminds/vcs v1.13.0/go.mod h1:N09YCmOQr6RLxC6UNHzuVwAdodYbbnycGHSmwVJjcKA=
Expand Down Expand Up @@ -1471,12 +1472,34 @@ github.com/stackql/go-openapistackql v0.0.5-alpha06 h1:7tDAQcRbHq0XwusRdnTGCuo2A
github.com/stackql/go-openapistackql v0.0.5-alpha06/go.mod h1:DSVjQrASsDMSP+9r+iE3rKFWJ+4XDkIRF8pjUjsaNC4=
github.com/stackql/go-openapistackql v0.0.5-rc02 h1:bAW0imihqLgyZxphwvJKWr3WQQyqpwpzlvmGUcAmkfg=
github.com/stackql/go-openapistackql v0.0.5-rc02/go.mod h1:TM3KSDEosTCcFLLfMiKO3TGab8AyQpElbBTB+CRpBjw=
github.com/stackql/go-openapistackql v0.0.6-alpha01 h1:/b4Y+mgABl8REoBbia1Nr1iEjxWXYBkRKiZY3ew1sRE=
github.com/stackql/go-openapistackql v0.0.6-alpha01/go.mod h1:0auL0f59x1xRYhw2kmsXYijcbsJ0n0yLhukb6wF1VlY=
github.com/stackql/go-openapistackql v0.0.6-alpha02 h1:IOxcKvny9NPv1X/GD+NKSIkTTDCNryreE37SZpb4TyE=
github.com/stackql/go-openapistackql v0.0.6-alpha02/go.mod h1:0auL0f59x1xRYhw2kmsXYijcbsJ0n0yLhukb6wF1VlY=
github.com/stackql/go-openapistackql v0.0.6-alpha03 h1:APdQ/YsA03WOINcL4m/2+7vyAgtFSbyC2JRWNCQzO1s=
github.com/stackql/go-openapistackql v0.0.6-alpha03/go.mod h1:0auL0f59x1xRYhw2kmsXYijcbsJ0n0yLhukb6wF1VlY=
github.com/stackql/go-openapistackql v0.0.6-alpha05 h1:V1ZtD3G65LDt10vnjagfnvI7Eyq14+DdPcsATDbo7Yw=
github.com/stackql/go-openapistackql v0.0.6-alpha05/go.mod h1:0auL0f59x1xRYhw2kmsXYijcbsJ0n0yLhukb6wF1VlY=
github.com/stackql/go-openapistackql v0.0.6-alpha06 h1:o2xbh+S+eg+Okk0Z8HR2Co796RvjcAd2yeRYUcPiKfM=
github.com/stackql/go-openapistackql v0.0.6-alpha06/go.mod h1:0auL0f59x1xRYhw2kmsXYijcbsJ0n0yLhukb6wF1VlY=
github.com/stackql/go-openapistackql v0.0.6-alpha07 h1:jW+6CjfrEN1IwN8hBRwl73IecXeCIwiQ+Pm+AB50FvA=
github.com/stackql/go-openapistackql v0.0.6-alpha07/go.mod h1:0auL0f59x1xRYhw2kmsXYijcbsJ0n0yLhukb6wF1VlY=
github.com/stackql/go-openapistackql v0.0.6-alpha08 h1:rBa7uVoEThO1uRK1zaUIWvEwY1knvuRGUIA2p4mNAqQ=
github.com/stackql/go-openapistackql v0.0.6-alpha08/go.mod h1:0auL0f59x1xRYhw2kmsXYijcbsJ0n0yLhukb6wF1VlY=
github.com/stackql/go-openapistackql v0.0.6-alpha09 h1:5x1ybgUuQUCg4lmZJ9uiSvoVHVwoHNzjzawLLMCEleE=
github.com/stackql/go-openapistackql v0.0.6-alpha09/go.mod h1:0auL0f59x1xRYhw2kmsXYijcbsJ0n0yLhukb6wF1VlY=
github.com/stackql/go-openapistackql v0.0.6-alpha11 h1:U4umEM1cO+IeA+zDg5ZiDhAbaxcuSELRR4dC7wWCyA0=
github.com/stackql/go-openapistackql v0.0.6-alpha11/go.mod h1:/23TrApFtkASWok1HxXyfUGe/FBUar17JABiadn5ZX4=
github.com/stackql/go-openapistackql v0.0.6-alpha12 h1:HE7bNA4Cv+uF6iHdNLQKlW8+MQZFzNPHsO/XxOb5apE=
github.com/stackql/go-openapistackql v0.0.6-alpha12/go.mod h1:/23TrApFtkASWok1HxXyfUGe/FBUar17JABiadn5ZX4=
github.com/stackql/go-spew v1.1.3-alpha24 h1:yNmgWU+OKU8SvlQ0umiQWWgWS6C5U1GuRMlYfQgbmJA=
github.com/stackql/go-spew v1.1.3-alpha24/go.mod h1:o2MPqg2ee1PN4SxAh9zQSJJmKKFJjpro9pejdK7dXWk=
github.com/stackql/go-sqlite3 v0.0.1-stackqlalpha h1:Ze9rqvLF76IuI42KqffAmBBQcIgInQrGJQkmTcoVRTI=
github.com/stackql/go-sqlite3 v0.0.1-stackqlalpha/go.mod h1:JHMGM3Hu7TcW8NBiJMFSBCHaUkhm1VjGZD5/uDaUDf4=
github.com/stackql/go-sqlite3 v0.0.1-stackqlrc01 h1:q+LfCfPrIqqG5+v9T5xjyYzOEBB4i77Ek10Lzwyd0D4=
github.com/stackql/go-sqlite3 v0.0.1-stackqlrc01/go.mod h1:JHMGM3Hu7TcW8NBiJMFSBCHaUkhm1VjGZD5/uDaUDf4=
github.com/stackql/go-suffix-map v0.0.1-alpha01 h1:TDUDS8bySu41Oo9p0eniUeCm43mnRM6zFEd6j6VUaz8=
github.com/stackql/go-suffix-map v0.0.1-alpha01/go.mod h1:QAi+SKukOyf4dBtWy8UMy+hsXXV+yyEE4vmBkji2V7g=
github.com/stackql/psql-wire v0.0.1-stackqlalpha3 h1:Q6AMZNEi+n1z/pT2btghy7uzJRCL4r8Btz8cfLYTrpo=
github.com/stackql/psql-wire v0.0.1-stackqlalpha3/go.mod h1:p4SxaTS4m9mLiq08GSOaatXSiai8REL5XPMlcVJxSwE=
github.com/stackql/psql-wire v0.0.1-stackqlalpha6 h1:RsdZ114rLE5Au6OC6CUWtu4VBQVLsaLigUX4rBVb5/Y=
Expand Down Expand Up @@ -1506,6 +1529,14 @@ github.com/stackql/vitess v0.0.10-alpha5 h1:AEVzt8eCJY8rVqVruft2N/nXGw8EmE3AJ+cB
github.com/stackql/vitess v0.0.10-alpha5/go.mod h1:4M5NhkFYCF10+U3LS4owUYY2GsUt+7t1kN9Rv5UVc9A=
github.com/stackql/vitess v0.0.10-rc01 h1:n1yZax9aSqPAPQqHfRvifc65sMxx3qgPG1e0bTfSA30=
github.com/stackql/vitess v0.0.10-rc01/go.mod h1:4M5NhkFYCF10+U3LS4owUYY2GsUt+7t1kN9Rv5UVc9A=
github.com/stackql/vitess v0.0.11-alpha01 h1:aSyHguOfwYXk3ll2nRNKn9s6jaSqm+rxRkH0vSiwXzc=
github.com/stackql/vitess v0.0.11-alpha01/go.mod h1:4M5NhkFYCF10+U3LS4owUYY2GsUt+7t1kN9Rv5UVc9A=
github.com/stackql/vitess v0.0.11-alpha02 h1:XP5oUbNYfK56v5KOxhjZv8pPHtwihd+tDjWz82KNFmM=
github.com/stackql/vitess v0.0.11-alpha02/go.mod h1:4M5NhkFYCF10+U3LS4owUYY2GsUt+7t1kN9Rv5UVc9A=
github.com/stackql/vitess v0.0.11-alpha03 h1:yG7rmKJxyNcIMcGQbd+y+381Ax//8nFJkFqODm1LjDQ=
github.com/stackql/vitess v0.0.11-alpha03/go.mod h1:6aOZHbgHclTasEGZvrdoWfca6Y4XJfemKMqwnDL/klI=
github.com/stackql/vitess v0.0.11-alpha04 h1:XieZz9DM1bvhT1JUYHTV3/s8fuh7CaOlp6u2eixOSMk=
github.com/stackql/vitess v0.0.11-alpha04/go.mod h1:6aOZHbgHclTasEGZvrdoWfca6Y4XJfemKMqwnDL/klI=
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
Expand Down Expand Up @@ -1774,6 +1805,7 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.0 h1:UG21uOlmZabA4fW5i7ZX6bjw1xELEGg/ZLgZq9auk/Q=
golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down
33 changes: 33 additions & 0 deletions internal/stackql/astvisit/astvisit.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ type DRMAstVisitor struct {
rewrittenQuery string
gcQueries []string
tablesCited map[*sqlparser.AliasedTableExpr]sqlparser.TableName
params map[sqlparser.SQLNode]interface{}
shouldCollectTables bool
}

func NewDRMAstVisitor(iDColumnName string, shouldCollectTables bool) *DRMAstVisitor {
return &DRMAstVisitor{
iDColumnName: iDColumnName,
tablesCited: make(map[*sqlparser.AliasedTableExpr]sqlparser.TableName),
params: make(map[sqlparser.SQLNode]interface{}),
shouldCollectTables: shouldCollectTables,
}
}
Expand All @@ -49,6 +51,21 @@ func (v *DRMAstVisitor) GetGCQueries() []string {
return v.gcQueries
}

func (v *DRMAstVisitor) GetParameters() map[sqlparser.SQLNode]interface{} {
return v.params
}

func (v *DRMAstVisitor) GetStringifiedParameters() map[string]interface{} {
rv := make(map[string]interface{})
for k, v := range v.params {
switch k := k.(type) {
case *sqlparser.ColName:
rv[k.Name.GetRawVal()] = v
}
}
return rv
}

func (v *DRMAstVisitor) generateQIDComparison(ta sqlparser.TableIdent) *sqlparser.ComparisonExpr {
return &sqlparser.ComparisonExpr{
Left: &sqlparser.ColName{Qualifier: sqlparser.TableName{Name: ta}, Name: sqlparser.NewColIdent(v.iDColumnName)},
Expand Down Expand Up @@ -775,6 +792,8 @@ func (v *DRMAstVisitor) Visit(node sqlparser.SQLNode) error {
v.rewrittenQuery = buf.String()

case *sqlparser.JoinTableExpr:
node.LeftExpr.Accept(v)
node.LeftExpr.Accept(v)
buf.AstPrintf(node, "%v %s %v%v", node.LeftExpr, node.Join, node.RightExpr, node.Condition)
v.rewrittenQuery = buf.String()

Expand Down Expand Up @@ -824,6 +843,20 @@ func (v *DRMAstVisitor) Visit(node sqlparser.SQLNode) error {
v.rewrittenQuery = buf.String()

case *sqlparser.ComparisonExpr:
switch lt := node.Left.(type) {
case *sqlparser.ColName:
switch rt := node.Right.(type) {
case *sqlparser.SQLVal:
v.params[lt] = rt
default:
}
default:
switch rt := node.Right.(type) {
case *sqlparser.SQLVal:
default:
v.params[lt] = rt
}
}
buf.AstPrintf(node, "%v %s %v", node.Left, node.Operator, node.Right)
if node.Escape != nil {
buf.AstPrintf(node, " escape %v", node.Escape)
Expand Down
Loading