@@ -78,6 +78,12 @@ octosql "SELECT * FROM plugins.plugins"`,
78
78
defer profile .Start (profile .TraceProfile , profile .ProfilePath ("." )).Stop ()
79
79
}
80
80
ctx := cmd .Context ()
81
+ cfg , err := config .Read ()
82
+ if err != nil {
83
+ return fmt .Errorf ("couldn't read config: %w" , err )
84
+ }
85
+ ctx = config .ContextWithConfig (ctx , cfg )
86
+
81
87
debug .SetGCPercent (1000 )
82
88
83
89
logs .InitializeFileLogger ()
@@ -94,11 +100,6 @@ octosql "SELECT * FROM plugins.plugins"`,
94
100
}
95
101
}()
96
102
97
- cfg , err := config .Read ()
98
- if err != nil {
99
- return fmt .Errorf ("couldn't read config: %w" , err )
100
- }
101
-
102
103
installedPlugins , err := pluginManager .ListInstalledPlugins ()
103
104
if err != nil {
104
105
return fmt .Errorf ("couldn't list installed plugins: %w" , err )
@@ -188,15 +189,15 @@ octosql "SELECT * FROM plugins.plugins"`,
188
189
if err != nil {
189
190
return fmt .Errorf ("couldn't get file extension handlers: %w" , err )
190
191
}
191
- fileHandlers := map [string ]func (name string , options map [string ]string ) (physical.DatasourceImplementation , physical.Schema , error ){
192
+ fileHandlers := map [string ]func (ctx context. Context , name string , options map [string ]string ) (physical.DatasourceImplementation , physical.Schema , error ){
192
193
"csv" : csv .Creator (',' ),
193
194
"json" : json .Creator ,
194
195
"lines" : lines .Creator ,
195
196
"parquet" : parquet .Creator ,
196
197
"tsv" : csv .Creator ('\t' ),
197
198
}
198
199
for ext , pluginName := range fileExtensionHandlers {
199
- fileHandlers [ext ] = func (name string , options map [string ]string ) (physical.DatasourceImplementation , physical.Schema , error ) {
200
+ fileHandlers [ext ] = func (ctx context. Context , name string , options map [string ]string ) (physical.DatasourceImplementation , physical.Schema , error ) {
200
201
db , err := databases [pluginName ]()
201
202
if err != nil {
202
203
return nil , physical.Schema {}, fmt .Errorf ("couldn't get plugin %s database for plugin extensions %s: %w" , pluginName , ext , err )
@@ -513,13 +514,13 @@ func typecheckExpr(ctx context.Context, expr logical.Expression, env physical.En
513
514
}
514
515
515
516
type fileTypeDatabaseCreator struct {
516
- creator func (name string , options map [string ]string ) (physical.DatasourceImplementation , physical.Schema , error )
517
+ creator func (ctx context. Context , name string , options map [string ]string ) (physical.DatasourceImplementation , physical.Schema , error )
517
518
}
518
519
519
520
func (f * fileTypeDatabaseCreator ) ListTables (ctx context.Context ) ([]string , error ) {
520
521
return nil , nil
521
522
}
522
523
523
524
func (f * fileTypeDatabaseCreator ) GetTable (ctx context.Context , name string , options map [string ]string ) (physical.DatasourceImplementation , physical.Schema , error ) {
524
- return f .creator (name , options )
525
+ return f .creator (ctx , name , options )
525
526
}
0 commit comments