@@ -38,6 +38,20 @@ pub struct ExportedData {
38
38
pub format : ExportFormat
39
39
}
40
40
41
+ /// Code snippet for the data view
42
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
43
+ pub struct ConvertedCode {
44
+ /// Lines of code that implement filters and sort keys
45
+ pub converted_code : Vec < String >
46
+ }
47
+
48
+ /// Syntax to use for code conversion
49
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
50
+ pub struct CodeSyntaxName {
51
+ /// The name of the code syntax, eg, pandas, polars, dplyr, etc.
52
+ pub code_syntax_name : String
53
+ }
54
+
41
55
/// The result of applying filters to a table
42
56
#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
43
57
pub struct FilterResult {
@@ -537,7 +551,10 @@ pub struct SupportedFeatures {
537
551
pub set_sort_columns : SetSortColumnsFeatures ,
538
552
539
553
/// Support for 'export_data_selection' RPC and its features
540
- pub export_data_selection : ExportDataSelectionFeatures
554
+ pub export_data_selection : ExportDataSelectionFeatures ,
555
+
556
+ /// Support for 'convert_to_code' RPC and its features
557
+ pub convert_to_code : ConvertToCodeFeatures
541
558
}
542
559
543
560
/// Feature flags for 'search_schema' RPC
@@ -600,6 +617,16 @@ pub struct SetSortColumnsFeatures {
600
617
pub support_status : SupportStatus
601
618
}
602
619
620
+ /// Feature flags for convert to code RPC
621
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
622
+ pub struct ConvertToCodeFeatures {
623
+ /// The support status for this RPC method
624
+ pub support_status : SupportStatus ,
625
+
626
+ /// The syntaxes for converted code
627
+ pub code_syntaxes : Option < Vec < CodeSyntaxName > >
628
+ }
629
+
603
630
/// A selection on the data grid, for copying to the clipboard or other
604
631
/// actions
605
632
#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
@@ -1073,6 +1100,22 @@ pub struct ExportDataSelectionParams {
1073
1100
pub format : ExportFormat ,
1074
1101
}
1075
1102
1103
+ /// Parameters for the ConvertToCode method.
1104
+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
1105
+ pub struct ConvertToCodeParams {
1106
+ /// Zero or more column filters to apply
1107
+ pub column_filters : Vec < ColumnFilter > ,
1108
+
1109
+ /// Zero or more row filters to apply
1110
+ pub row_filters : Vec < RowFilter > ,
1111
+
1112
+ /// Zero or more sort keys to apply
1113
+ pub sort_keys : Vec < ColumnSortKey > ,
1114
+
1115
+ /// The code syntax to use for conversion
1116
+ pub code_syntax_name : CodeSyntaxName ,
1117
+ }
1118
+
1076
1119
/// Parameters for the SetColumnFilters method.
1077
1120
#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
1078
1121
pub struct SetColumnFiltersParams {
@@ -1164,6 +1207,20 @@ pub enum DataExplorerBackendRequest {
1164
1207
#[ serde( rename = "export_data_selection" ) ]
1165
1208
ExportDataSelection ( ExportDataSelectionParams ) ,
1166
1209
1210
+ /// Converts the current data view into a code snippet.
1211
+ ///
1212
+ /// Converts filters and sort keys as code in different syntaxes like
1213
+ /// pandas, polars, data.table, dplyr
1214
+ #[ serde( rename = "convert_to_code" ) ]
1215
+ ConvertToCode ( ConvertToCodeParams ) ,
1216
+
1217
+ /// Suggest code syntax for code conversion
1218
+ ///
1219
+ /// Suggest code syntax for code conversion based on the current backend
1220
+ /// state
1221
+ #[ serde( rename = "suggest_code_syntax" ) ]
1222
+ SuggestCodeSyntax ,
1223
+
1167
1224
/// Set column filters to select subset of table columns
1168
1225
///
1169
1226
/// Set or clear column filters on table, replacing any previous filters
@@ -1220,6 +1277,12 @@ pub enum DataExplorerBackendReply {
1220
1277
/// Exported result
1221
1278
ExportDataSelectionReply ( ExportedData ) ,
1222
1279
1280
+ /// Code snippet for the data view
1281
+ ConvertToCodeReply ( ConvertedCode ) ,
1282
+
1283
+ /// Syntax to use for code conversion
1284
+ SuggestCodeSyntaxReply ( CodeSyntaxName ) ,
1285
+
1223
1286
/// Reply for the set_column_filters method (no result)
1224
1287
SetColumnFiltersReply ( ) ,
1225
1288
0 commit comments