Skip to content

Commit 249a452

Browse files
static-analysis-v1
Summary: - Change interface to support AOT static analysis.
1 parent 6ba8688 commit 249a452

File tree

6 files changed

+75
-291
lines changed

6 files changed

+75
-291
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/spf13/cobra v1.4.0
2020
github.com/spf13/pflag v1.0.5
2121
github.com/spf13/viper v1.10.1
22-
github.com/stackql/any-sdk v0.1.4-beta03
22+
github.com/stackql/any-sdk v0.1.5-alpha03
2323
github.com/stackql/go-suffix-map v0.0.1-alpha01
2424
github.com/stackql/psql-wire v0.1.1-beta23
2525
github.com/stackql/stackql-parser v0.0.15-alpha06

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
484484
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
485485
github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk=
486486
github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU=
487-
github.com/stackql/any-sdk v0.1.4-beta03 h1:hEpVc04jQ2BgfiyIxBVB1K4cyzjlc2BL6dH/Of4jRMU=
488-
github.com/stackql/any-sdk v0.1.4-beta03/go.mod h1:AKS/g28y7m4SWL/YW8veE9MCNy8XJgaicVibemVE9e8=
487+
github.com/stackql/any-sdk v0.1.5-alpha03 h1:AVjRNU84M/ciSgsYgx13+pxIrCNdfs4QHCn20ZeT75o=
488+
github.com/stackql/any-sdk v0.1.5-alpha03/go.mod h1:AKS/g28y7m4SWL/YW8veE9MCNy8XJgaicVibemVE9e8=
489489
github.com/stackql/go-suffix-map v0.0.1-alpha01 h1:TDUDS8bySu41Oo9p0eniUeCm43mnRM6zFEd6j6VUaz8=
490490
github.com/stackql/go-suffix-map v0.0.1-alpha01/go.mod h1:QAi+SKukOyf4dBtWy8UMy+hsXXV+yyEE4vmBkji2V7g=
491491
github.com/stackql/psql-wire v0.1.1-beta23 h1:1ayYMjZArfDcIMyEOKnm+Bp1zRCISw8pguvTFuUhhVQ=

internal/stackql/discovery/discovery.go

Lines changed: 0 additions & 284 deletions
This file was deleted.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package persistence
2+
3+
import (
4+
"github.com/stackql/any-sdk/anysdk"
5+
"github.com/stackql/any-sdk/public/discovery"
6+
"github.com/stackql/stackql/internal/stackql/sql_system"
7+
"github.com/stackql/stackql/pkg/name_mangle"
8+
)
9+
10+
var (
11+
_ discovery.PersistenceSystem = &SQLPersistenceSystem{}
12+
)
13+
14+
type SQLPersistenceSystem struct {
15+
sqlSystem sql_system.SQLSystem
16+
viewNameMangler name_mangle.NameMangler
17+
}
18+
19+
func NewSQLPersistenceSystem(sqlSystem sql_system.SQLSystem) *SQLPersistenceSystem {
20+
return &SQLPersistenceSystem{
21+
sqlSystem: sqlSystem,
22+
viewNameMangler: name_mangle.NewViewNameMangler(),
23+
}
24+
}
25+
26+
func (s *SQLPersistenceSystem) GetSystemName() string {
27+
return s.sqlSystem.GetName()
28+
}
29+
30+
func (s *SQLPersistenceSystem) HandleExternalTables(providerName string, externalTables map[string]anysdk.SQLExternalTable) error {
31+
for _, tbl := range externalTables {
32+
err := s.sqlSystem.RegisterExternalTable(
33+
providerName,
34+
tbl,
35+
)
36+
if err != nil {
37+
return err
38+
}
39+
}
40+
return nil
41+
}
42+
43+
func (s *SQLPersistenceSystem) HandleViewCollection(viewCollection []anysdk.View) error {
44+
for i, view := range viewCollection {
45+
viewNameNaive := view.GetNameNaive()
46+
viewName := s.viewNameMangler.MangleName(viewNameNaive, i)
47+
_, viewExists := s.sqlSystem.GetViewByName(viewName)
48+
if !viewExists {
49+
// TODO: resolve any possible data race
50+
err := s.sqlSystem.CreateView(viewName, view.GetDDL(), true, view.GetRequiredParamNames())
51+
if err != nil {
52+
return err
53+
}
54+
}
55+
}
56+
return nil
57+
}
58+
59+
func (s *SQLPersistenceSystem) CacheStoreGet(key string) ([]byte, error) {
60+
return s.sqlSystem.GetSQLEngine().CacheStoreGet(key)
61+
}
62+
63+
func (s *SQLPersistenceSystem) CacheStorePut(key string, value []byte, expiration string, ttl int) error {
64+
return s.sqlSystem.GetSQLEngine().CacheStorePut(key, value, expiration, ttl)
65+
}

internal/stackql/provider/generic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/stackql/any-sdk/pkg/dto"
1111
"github.com/stackql/any-sdk/pkg/logging"
1212
"github.com/stackql/any-sdk/pkg/netutils"
13-
"github.com/stackql/stackql/internal/stackql/discovery"
13+
"github.com/stackql/any-sdk/public/discovery"
1414
"github.com/stackql/stackql/internal/stackql/docparser"
1515
"github.com/stackql/stackql/internal/stackql/internal_data_transfer/internaldto"
1616
"github.com/stackql/stackql/internal/stackql/methodselect"

0 commit comments

Comments
 (0)