-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathfeature-engineering.go
More file actions
executable file
·1145 lines (900 loc) · 35 KB
/
feature-engineering.go
File metadata and controls
executable file
·1145 lines (900 loc) · 35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
package feature_engineering
import (
"fmt"
"strings"
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/cmdctx"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/flags"
"github.com/databricks/databricks-sdk-go/common/types/fieldmask"
"github.com/databricks/databricks-sdk-go/service/ml"
"github.com/spf13/cobra"
)
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var cmdOverrides []func(*cobra.Command)
func New() *cobra.Command {
cmd := &cobra.Command{
Use: "feature-engineering",
Short: `[description].`,
Long: `[description]`,
GroupID: "ml",
// This service is being previewed; hide from help output.
Hidden: true,
RunE: root.ReportUnknownSubcommand,
}
// Add methods
cmd.AddCommand(newCreateFeature())
cmd.AddCommand(newCreateKafkaConfig())
cmd.AddCommand(newCreateMaterializedFeature())
cmd.AddCommand(newDeleteFeature())
cmd.AddCommand(newDeleteKafkaConfig())
cmd.AddCommand(newDeleteMaterializedFeature())
cmd.AddCommand(newGetFeature())
cmd.AddCommand(newGetKafkaConfig())
cmd.AddCommand(newGetMaterializedFeature())
cmd.AddCommand(newListFeatures())
cmd.AddCommand(newListKafkaConfigs())
cmd.AddCommand(newListMaterializedFeatures())
cmd.AddCommand(newUpdateFeature())
cmd.AddCommand(newUpdateKafkaConfig())
cmd.AddCommand(newUpdateMaterializedFeature())
// Apply optional overrides to this command.
for _, fn := range cmdOverrides {
fn(cmd)
}
return cmd
}
// start create-feature command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var createFeatureOverrides []func(
*cobra.Command,
*ml.CreateFeatureRequest,
)
func newCreateFeature() *cobra.Command {
cmd := &cobra.Command{}
var createFeatureReq ml.CreateFeatureRequest
createFeatureReq.Feature = ml.Feature{}
var createFeatureJson flags.JsonFlag
cmd.Flags().Var(&createFeatureJson, "json", `either inline JSON string or @path/to/file.json with request body`)
cmd.Flags().StringVar(&createFeatureReq.Feature.Description, "description", createFeatureReq.Feature.Description, `The description of the feature.`)
cmd.Flags().StringVar(&createFeatureReq.Feature.FilterCondition, "filter-condition", createFeatureReq.Feature.FilterCondition, `The filter condition applied to the source data before aggregation.`)
// TODO: complex arg: lineage_context
// TODO: complex arg: time_window
cmd.Use = "create-feature FULL_NAME SOURCE INPUTS FUNCTION"
cmd.Short = `Create a feature.`
cmd.Long = `Create a feature.
Create a Feature.
Arguments:
FULL_NAME: The full three-part name (catalog, schema, name) of the feature.
SOURCE: The data source of the feature.
INPUTS: The input columns from which the feature is computed.
FUNCTION: The function by which the feature is computed.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("json") {
err := root.ExactArgs(0)(cmd, args)
if err != nil {
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'full_name', 'source', 'inputs', 'function' in your JSON input")
}
return nil
}
check := root.ExactArgs(4)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
diags := createFeatureJson.Unmarshal(&createFeatureReq.Feature)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
createFeatureReq.Feature.FullName = args[0]
}
if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[1], &createFeatureReq.Feature.Source)
if err != nil {
return fmt.Errorf("invalid SOURCE: %s", args[1])
}
}
if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[2], &createFeatureReq.Feature.Inputs)
if err != nil {
return fmt.Errorf("invalid INPUTS: %s", args[2])
}
}
if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[3], &createFeatureReq.Feature.Function)
if err != nil {
return fmt.Errorf("invalid FUNCTION: %s", args[3])
}
}
response, err := w.FeatureEngineering.CreateFeature(ctx, createFeatureReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range createFeatureOverrides {
fn(cmd, &createFeatureReq)
}
return cmd
}
// start create-kafka-config command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var createKafkaConfigOverrides []func(
*cobra.Command,
*ml.CreateKafkaConfigRequest,
)
func newCreateKafkaConfig() *cobra.Command {
cmd := &cobra.Command{}
var createKafkaConfigReq ml.CreateKafkaConfigRequest
createKafkaConfigReq.KafkaConfig = ml.KafkaConfig{}
var createKafkaConfigJson flags.JsonFlag
cmd.Flags().Var(&createKafkaConfigJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: map via StringToStringVar: extra_options
// TODO: complex arg: key_schema
// TODO: complex arg: value_schema
cmd.Use = "create-kafka-config NAME BOOTSTRAP_SERVERS SUBSCRIPTION_MODE AUTH_CONFIG"
cmd.Short = `Create a Kafka config.`
cmd.Long = `Create a Kafka config.
Arguments:
NAME: Name that uniquely identifies this Kafka config within the metastore. This
will be the identifier used from the Feature object to reference these
configs for a feature. Can be distinct from topic name.
BOOTSTRAP_SERVERS: A comma-separated list of host/port pairs pointing to Kafka cluster.
SUBSCRIPTION_MODE: Options to configure which Kafka topics to pull data from.
AUTH_CONFIG: Authentication configuration for connection to topics.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("json") {
err := root.ExactArgs(0)(cmd, args)
if err != nil {
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'name', 'bootstrap_servers', 'subscription_mode', 'auth_config' in your JSON input")
}
return nil
}
check := root.ExactArgs(4)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
diags := createKafkaConfigJson.Unmarshal(&createKafkaConfigReq.KafkaConfig)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
createKafkaConfigReq.KafkaConfig.Name = args[0]
}
if !cmd.Flags().Changed("json") {
createKafkaConfigReq.KafkaConfig.BootstrapServers = args[1]
}
if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[2], &createKafkaConfigReq.KafkaConfig.SubscriptionMode)
if err != nil {
return fmt.Errorf("invalid SUBSCRIPTION_MODE: %s", args[2])
}
}
if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[3], &createKafkaConfigReq.KafkaConfig.AuthConfig)
if err != nil {
return fmt.Errorf("invalid AUTH_CONFIG: %s", args[3])
}
}
response, err := w.FeatureEngineering.CreateKafkaConfig(ctx, createKafkaConfigReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range createKafkaConfigOverrides {
fn(cmd, &createKafkaConfigReq)
}
return cmd
}
// start create-materialized-feature command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var createMaterializedFeatureOverrides []func(
*cobra.Command,
*ml.CreateMaterializedFeatureRequest,
)
func newCreateMaterializedFeature() *cobra.Command {
cmd := &cobra.Command{}
var createMaterializedFeatureReq ml.CreateMaterializedFeatureRequest
createMaterializedFeatureReq.MaterializedFeature = ml.MaterializedFeature{}
var createMaterializedFeatureJson flags.JsonFlag
cmd.Flags().Var(&createMaterializedFeatureJson, "json", `either inline JSON string or @path/to/file.json with request body`)
cmd.Flags().StringVar(&createMaterializedFeatureReq.MaterializedFeature.CronSchedule, "cron-schedule", createMaterializedFeatureReq.MaterializedFeature.CronSchedule, `The quartz cron expression that defines the schedule of the materialization pipeline.`)
// TODO: complex arg: offline_store_config
// TODO: complex arg: online_store_config
cmd.Flags().Var(&createMaterializedFeatureReq.MaterializedFeature.PipelineScheduleState, "pipeline-schedule-state", `The schedule state of the materialization pipeline. Supported values: [ACTIVE, PAUSED, SNAPSHOT]`)
cmd.Use = "create-materialized-feature FEATURE_NAME"
cmd.Short = `Create a materialized feature.`
cmd.Long = `Create a materialized feature.
Arguments:
FEATURE_NAME: The full name of the feature in Unity Catalog.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("json") {
err := root.ExactArgs(0)(cmd, args)
if err != nil {
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'feature_name' in your JSON input")
}
return nil
}
check := root.ExactArgs(1)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
diags := createMaterializedFeatureJson.Unmarshal(&createMaterializedFeatureReq.MaterializedFeature)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
createMaterializedFeatureReq.MaterializedFeature.FeatureName = args[0]
}
response, err := w.FeatureEngineering.CreateMaterializedFeature(ctx, createMaterializedFeatureReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range createMaterializedFeatureOverrides {
fn(cmd, &createMaterializedFeatureReq)
}
return cmd
}
// start delete-feature command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var deleteFeatureOverrides []func(
*cobra.Command,
*ml.DeleteFeatureRequest,
)
func newDeleteFeature() *cobra.Command {
cmd := &cobra.Command{}
var deleteFeatureReq ml.DeleteFeatureRequest
cmd.Use = "delete-feature FULL_NAME"
cmd.Short = `Delete a feature.`
cmd.Long = `Delete a feature.
Delete a Feature.
Arguments:
FULL_NAME: Name of the feature to delete.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(1)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
deleteFeatureReq.FullName = args[0]
err = w.FeatureEngineering.DeleteFeature(ctx, deleteFeatureReq)
if err != nil {
return err
}
return nil
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range deleteFeatureOverrides {
fn(cmd, &deleteFeatureReq)
}
return cmd
}
// start delete-kafka-config command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var deleteKafkaConfigOverrides []func(
*cobra.Command,
*ml.DeleteKafkaConfigRequest,
)
func newDeleteKafkaConfig() *cobra.Command {
cmd := &cobra.Command{}
var deleteKafkaConfigReq ml.DeleteKafkaConfigRequest
cmd.Use = "delete-kafka-config NAME"
cmd.Short = `Delete a Kafka config.`
cmd.Long = `Delete a Kafka config.
Arguments:
NAME: Name of the Kafka config to delete.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(1)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
deleteKafkaConfigReq.Name = args[0]
err = w.FeatureEngineering.DeleteKafkaConfig(ctx, deleteKafkaConfigReq)
if err != nil {
return err
}
return nil
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range deleteKafkaConfigOverrides {
fn(cmd, &deleteKafkaConfigReq)
}
return cmd
}
// start delete-materialized-feature command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var deleteMaterializedFeatureOverrides []func(
*cobra.Command,
*ml.DeleteMaterializedFeatureRequest,
)
func newDeleteMaterializedFeature() *cobra.Command {
cmd := &cobra.Command{}
var deleteMaterializedFeatureReq ml.DeleteMaterializedFeatureRequest
cmd.Use = "delete-materialized-feature MATERIALIZED_FEATURE_ID"
cmd.Short = `Delete a materialized feature.`
cmd.Long = `Delete a materialized feature.
Arguments:
MATERIALIZED_FEATURE_ID: The ID of the materialized feature to delete.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(1)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
deleteMaterializedFeatureReq.MaterializedFeatureId = args[0]
err = w.FeatureEngineering.DeleteMaterializedFeature(ctx, deleteMaterializedFeatureReq)
if err != nil {
return err
}
return nil
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range deleteMaterializedFeatureOverrides {
fn(cmd, &deleteMaterializedFeatureReq)
}
return cmd
}
// start get-feature command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var getFeatureOverrides []func(
*cobra.Command,
*ml.GetFeatureRequest,
)
func newGetFeature() *cobra.Command {
cmd := &cobra.Command{}
var getFeatureReq ml.GetFeatureRequest
cmd.Use = "get-feature FULL_NAME"
cmd.Short = `Get a feature.`
cmd.Long = `Get a feature.
Get a Feature.
Arguments:
FULL_NAME: Name of the feature to get.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(1)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
getFeatureReq.FullName = args[0]
response, err := w.FeatureEngineering.GetFeature(ctx, getFeatureReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range getFeatureOverrides {
fn(cmd, &getFeatureReq)
}
return cmd
}
// start get-kafka-config command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var getKafkaConfigOverrides []func(
*cobra.Command,
*ml.GetKafkaConfigRequest,
)
func newGetKafkaConfig() *cobra.Command {
cmd := &cobra.Command{}
var getKafkaConfigReq ml.GetKafkaConfigRequest
cmd.Use = "get-kafka-config NAME"
cmd.Short = `Get a Kafka config.`
cmd.Long = `Get a Kafka config.
Arguments:
NAME: Name of the Kafka config to get.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(1)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
getKafkaConfigReq.Name = args[0]
response, err := w.FeatureEngineering.GetKafkaConfig(ctx, getKafkaConfigReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range getKafkaConfigOverrides {
fn(cmd, &getKafkaConfigReq)
}
return cmd
}
// start get-materialized-feature command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var getMaterializedFeatureOverrides []func(
*cobra.Command,
*ml.GetMaterializedFeatureRequest,
)
func newGetMaterializedFeature() *cobra.Command {
cmd := &cobra.Command{}
var getMaterializedFeatureReq ml.GetMaterializedFeatureRequest
cmd.Use = "get-materialized-feature MATERIALIZED_FEATURE_ID"
cmd.Short = `Get a materialized feature.`
cmd.Long = `Get a materialized feature.
Arguments:
MATERIALIZED_FEATURE_ID: The ID of the materialized feature.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(1)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
getMaterializedFeatureReq.MaterializedFeatureId = args[0]
response, err := w.FeatureEngineering.GetMaterializedFeature(ctx, getMaterializedFeatureReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range getMaterializedFeatureOverrides {
fn(cmd, &getMaterializedFeatureReq)
}
return cmd
}
// start list-features command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var listFeaturesOverrides []func(
*cobra.Command,
*ml.ListFeaturesRequest,
)
func newListFeatures() *cobra.Command {
cmd := &cobra.Command{}
var listFeaturesReq ml.ListFeaturesRequest
cmd.Flags().IntVar(&listFeaturesReq.PageSize, "page-size", listFeaturesReq.PageSize, `The maximum number of results to return.`)
cmd.Flags().StringVar(&listFeaturesReq.PageToken, "page-token", listFeaturesReq.PageToken, `Pagination token to go to the next page based on a previous query.`)
cmd.Use = "list-features"
cmd.Short = `List features.`
cmd.Long = `List features.
List Features.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(0)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
response := w.FeatureEngineering.ListFeatures(ctx, listFeaturesReq)
return cmdio.RenderIterator(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range listFeaturesOverrides {
fn(cmd, &listFeaturesReq)
}
return cmd
}
// start list-kafka-configs command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var listKafkaConfigsOverrides []func(
*cobra.Command,
*ml.ListKafkaConfigsRequest,
)
func newListKafkaConfigs() *cobra.Command {
cmd := &cobra.Command{}
var listKafkaConfigsReq ml.ListKafkaConfigsRequest
cmd.Flags().IntVar(&listKafkaConfigsReq.PageSize, "page-size", listKafkaConfigsReq.PageSize, `The maximum number of results to return.`)
cmd.Flags().StringVar(&listKafkaConfigsReq.PageToken, "page-token", listKafkaConfigsReq.PageToken, `Pagination token to go to the next page based on a previous query.`)
cmd.Use = "list-kafka-configs"
cmd.Short = `List Kafka configs.`
cmd.Long = `List Kafka configs.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(0)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
response := w.FeatureEngineering.ListKafkaConfigs(ctx, listKafkaConfigsReq)
return cmdio.RenderIterator(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range listKafkaConfigsOverrides {
fn(cmd, &listKafkaConfigsReq)
}
return cmd
}
// start list-materialized-features command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var listMaterializedFeaturesOverrides []func(
*cobra.Command,
*ml.ListMaterializedFeaturesRequest,
)
func newListMaterializedFeatures() *cobra.Command {
cmd := &cobra.Command{}
var listMaterializedFeaturesReq ml.ListMaterializedFeaturesRequest
cmd.Flags().StringVar(&listMaterializedFeaturesReq.FeatureName, "feature-name", listMaterializedFeaturesReq.FeatureName, `Filter by feature name.`)
cmd.Flags().IntVar(&listMaterializedFeaturesReq.PageSize, "page-size", listMaterializedFeaturesReq.PageSize, `The maximum number of results to return.`)
cmd.Flags().StringVar(&listMaterializedFeaturesReq.PageToken, "page-token", listMaterializedFeaturesReq.PageToken, `Pagination token to go to the next page based on a previous query.`)
cmd.Use = "list-materialized-features"
cmd.Short = `List materialized features.`
cmd.Long = `List materialized features.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(0)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
response := w.FeatureEngineering.ListMaterializedFeatures(ctx, listMaterializedFeaturesReq)
return cmdio.RenderIterator(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range listMaterializedFeaturesOverrides {
fn(cmd, &listMaterializedFeaturesReq)
}
return cmd
}
// start update-feature command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var updateFeatureOverrides []func(
*cobra.Command,
*ml.UpdateFeatureRequest,
)
func newUpdateFeature() *cobra.Command {
cmd := &cobra.Command{}
var updateFeatureReq ml.UpdateFeatureRequest
updateFeatureReq.Feature = ml.Feature{}
var updateFeatureJson flags.JsonFlag
cmd.Flags().Var(&updateFeatureJson, "json", `either inline JSON string or @path/to/file.json with request body`)
cmd.Flags().StringVar(&updateFeatureReq.Feature.Description, "description", updateFeatureReq.Feature.Description, `The description of the feature.`)
cmd.Flags().StringVar(&updateFeatureReq.Feature.FilterCondition, "filter-condition", updateFeatureReq.Feature.FilterCondition, `The filter condition applied to the source data before aggregation.`)
// TODO: complex arg: lineage_context
// TODO: complex arg: time_window
cmd.Use = "update-feature FULL_NAME UPDATE_MASK SOURCE INPUTS FUNCTION"
cmd.Short = `Update a feature's description (all other fields are immutable).`
cmd.Long = `Update a feature's description (all other fields are immutable).
Update a Feature.
Arguments:
FULL_NAME: The full three-part name (catalog, schema, name) of the feature.
UPDATE_MASK: The list of fields to update.
SOURCE: The data source of the feature.
INPUTS: The input columns from which the feature is computed.
FUNCTION: The function by which the feature is computed.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("json") {
err := root.ExactArgs(2)(cmd, args)
if err != nil {
return fmt.Errorf("when --json flag is specified, provide only FULL_NAME, UPDATE_MASK as positional arguments. Provide 'full_name', 'source', 'inputs', 'function' in your JSON input")
}
return nil
}
check := root.ExactArgs(5)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
diags := updateFeatureJson.Unmarshal(&updateFeatureReq.Feature)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
updateFeatureReq.FullName = args[0]
updateFeatureReq.UpdateMask = args[1]
if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[2], &updateFeatureReq.Feature.Source)
if err != nil {
return fmt.Errorf("invalid SOURCE: %s", args[2])
}
}
if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[3], &updateFeatureReq.Feature.Inputs)
if err != nil {
return fmt.Errorf("invalid INPUTS: %s", args[3])
}
}
if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[4], &updateFeatureReq.Feature.Function)
if err != nil {
return fmt.Errorf("invalid FUNCTION: %s", args[4])
}
}
response, err := w.FeatureEngineering.UpdateFeature(ctx, updateFeatureReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range updateFeatureOverrides {
fn(cmd, &updateFeatureReq)
}
return cmd
}
// start update-kafka-config command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var updateKafkaConfigOverrides []func(
*cobra.Command,
*ml.UpdateKafkaConfigRequest,
)
func newUpdateKafkaConfig() *cobra.Command {
cmd := &cobra.Command{}
var updateKafkaConfigReq ml.UpdateKafkaConfigRequest
updateKafkaConfigReq.KafkaConfig = ml.KafkaConfig{}
var updateKafkaConfigJson flags.JsonFlag
cmd.Flags().Var(&updateKafkaConfigJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: map via StringToStringVar: extra_options
// TODO: complex arg: key_schema
// TODO: complex arg: value_schema
cmd.Use = "update-kafka-config NAME UPDATE_MASK BOOTSTRAP_SERVERS SUBSCRIPTION_MODE AUTH_CONFIG"
cmd.Short = `Update a Kafka config.`
cmd.Long = `Update a Kafka config.
Arguments:
NAME: Name that uniquely identifies this Kafka config within the metastore. This
will be the identifier used from the Feature object to reference these
configs for a feature. Can be distinct from topic name.
UPDATE_MASK: The list of fields to update.
BOOTSTRAP_SERVERS: A comma-separated list of host/port pairs pointing to Kafka cluster.
SUBSCRIPTION_MODE: Options to configure which Kafka topics to pull data from.
AUTH_CONFIG: Authentication configuration for connection to topics.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("json") {
err := root.ExactArgs(2)(cmd, args)
if err != nil {
return fmt.Errorf("when --json flag is specified, provide only NAME, UPDATE_MASK as positional arguments. Provide 'name', 'bootstrap_servers', 'subscription_mode', 'auth_config' in your JSON input")
}
return nil
}
check := root.ExactArgs(5)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := cmdctx.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {