createTableAsSelect is a test utility for creating a table directly in an OLAP connector. It invokes a model executor directly without actually creating a model resource. This is useful for testing resources against pre-existing/external tables.
(t *testing.T, rt *runtime.Runtime, instanceID, connector, name, sql string)
| 279 | // It invokes a model executor directly without actually creating a model resource. |
| 280 | // This is useful for testing resources against pre-existing/external tables. |
| 281 | func createTableAsSelect(t *testing.T, rt *runtime.Runtime, instanceID, connector, name, sql string) { |
| 282 | h, release, err := rt.AcquireHandle(context.Background(), instanceID, connector) |
| 283 | require.NoError(t, err) |
| 284 | defer release() |
| 285 | opts := &drivers.ModelExecutorOptions{ |
| 286 | Env: &drivers.ModelEnv{}, |
| 287 | ModelName: name, |
| 288 | InputHandle: h, |
| 289 | InputConnector: connector, |
| 290 | PreliminaryInputProperties: map[string]any{"sql": sql}, |
| 291 | OutputHandle: h, |
| 292 | OutputConnector: connector, |
| 293 | PreliminaryOutputProperties: map[string]any{"table": name}, |
| 294 | } |
| 295 | me, err := h.AsModelExecutor(instanceID, opts) |
| 296 | require.NoError(t, err) |
| 297 | _, err = me.Execute(context.Background(), &drivers.ModelExecuteOptions{ |
| 298 | ModelExecutorOptions: opts, |
| 299 | InputProperties: opts.PreliminaryInputProperties, |
| 300 | OutputProperties: opts.PreliminaryOutputProperties, |
| 301 | }) |
| 302 | require.NoError(t, err) |
| 303 | } |
no test coverage detected