diff --git a/extensions/positron-python/pythonFiles/positron/positron_ipykernel/data_explorer.py b/extensions/positron-python/pythonFiles/positron/positron_ipykernel/data_explorer.py index 05eccba168b..29efcad3f68 100644 --- a/extensions/positron-python/pythonFiles/positron/positron_ipykernel/data_explorer.py +++ b/extensions/positron-python/pythonFiles/positron/positron_ipykernel/data_explorer.py @@ -28,7 +28,7 @@ ColumnHistogram, ColumnSummaryStats, CompareFilterParamsOp, - ColumnProfileRequestType, + ColumnProfileType, ColumnProfileResult, ColumnSchema, ColumnDisplayType, @@ -36,21 +36,26 @@ DataExplorerBackendMessageContent, DataExplorerFrontendEvent, FilterResult, + GetColumnProfilesFeatures, GetColumnProfilesRequest, GetDataValuesRequest, GetSchemaRequest, GetStateRequest, + GetSupportedFeaturesRequest, RowFilter, - RowFilterFilterType, + RowFilterType, SchemaUpdateParams, - SearchFilterParamsType, + SearchFilterType, + SearchSchemaFeatures, SearchSchemaRequest, SearchSchemaResult, + SetRowFiltersFeatures, SetRowFiltersRequest, SetSortColumnsRequest, SummaryStatsBoolean, SummaryStatsNumber, SummaryStatsString, + SupportedFeatures, TableData, TableSchema, TableShape, @@ -140,20 +145,20 @@ def get_column_profiles(self, request: GetColumnProfilesRequest): results = [] for req in request.params.profiles: - if req.type == ColumnProfileRequestType.NullCount: + if req.profile_type == ColumnProfileType.NullCount: count = self._prof_null_count(req.column_index) result = ColumnProfileResult(null_count=count) - elif req.type == ColumnProfileRequestType.SummaryStats: + elif req.profile_type == ColumnProfileType.SummaryStats: stats = self._prof_summary_stats(req.column_index) result = ColumnProfileResult(summary_stats=stats) - elif req.type == ColumnProfileRequestType.FrequencyTable: + elif req.profile_type == ColumnProfileType.FrequencyTable: freq_table = self._prof_freq_table(req.column_index) result = ColumnProfileResult(frequency_table=freq_table) - elif req.type == ColumnProfileRequestType.Histogram: + elif req.profile_type == ColumnProfileType.Histogram: histogram = self._prof_histogram(req.column_index) result = ColumnProfileResult(histogram=histogram) else: - raise NotImplementedError(req.type) + raise NotImplementedError(req.profile_type) results.append(result.dict()) return results @@ -161,6 +166,9 @@ def get_column_profiles(self, request: GetColumnProfilesRequest): def get_state(self, request: GetStateRequest): return self._get_state().dict() + def get_supported_features(self, request: GetSupportedFeaturesRequest): + return self._get_supported_features().dict() + @abc.abstractmethod def invalidate_computations(self): pass @@ -220,6 +228,10 @@ def _prof_histogram(self, column_index: int) -> ColumnHistogram: def _get_state(self) -> TableState: pass + @abc.abstractmethod + def _get_supported_features(self) -> SupportedFeatures: + pass + def _pandas_format_values(col): import pandas.io.formats.format as fmt @@ -498,19 +510,19 @@ def _eval_filter(self, filt: RowFilter): col = self.table.iloc[:, filt.column_index] mask = None if filt.filter_type in ( - RowFilterFilterType.Between, - RowFilterFilterType.NotBetween, + RowFilterType.Between, + RowFilterType.NotBetween, ): params = filt.between_params assert params is not None left_value = _coerce_value_param(params.left_value, col.dtype) right_value = _coerce_value_param(params.right_value, col.dtype) - if filt.filter_type == RowFilterFilterType.Between: + if filt.filter_type == RowFilterType.Between: mask = (col >= left_value) & (col <= right_value) else: # NotBetween mask = (col < left_value) | (col > right_value) - elif filt.filter_type == RowFilterFilterType.Compare: + elif filt.filter_type == RowFilterType.Compare: params = filt.compare_params assert params is not None @@ -519,11 +531,11 @@ def _eval_filter(self, filt: RowFilter): op = COMPARE_OPS[params.op] # pandas comparison filters return False for null values mask = op(col, _coerce_value_param(params.value, col.dtype)) - elif filt.filter_type == RowFilterFilterType.IsNull: + elif filt.filter_type == RowFilterType.IsNull: mask = col.isnull() - elif filt.filter_type == RowFilterFilterType.NotNull: + elif filt.filter_type == RowFilterType.NotNull: mask = col.notnull() - elif filt.filter_type == RowFilterFilterType.SetMembership: + elif filt.filter_type == RowFilterType.SetMembership: params = filt.set_membership_params assert params is not None boxed_values = pd_.Series(params.values).astype(col.dtype) @@ -532,7 +544,7 @@ def _eval_filter(self, filt: RowFilter): if not params.inclusive: # NOT-IN mask = ~mask - elif filt.filter_type == RowFilterFilterType.Search: + elif filt.filter_type == RowFilterType.Search: params = filt.search_params assert params is not None @@ -543,17 +555,17 @@ def _eval_filter(self, filt: RowFilter): term = params.term - if params.type == SearchFilterParamsType.RegexMatch: + if params.search_type == SearchFilterType.RegexMatch: mask = col.str.match(term, case=params.case_sensitive) else: if not params.case_sensitive: col = col.str.lower() term = term.lower() - if params.type == SearchFilterParamsType.Contains: + if params.search_type == SearchFilterType.Contains: mask = col.str.contains(term) - elif params.type == SearchFilterParamsType.StartsWith: + elif params.search_type == SearchFilterType.StartsWith: mask = col.str.startswith(term) - elif params.type == SearchFilterParamsType.EndsWith: + elif params.search_type == SearchFilterType.EndsWith: mask = col.str.endswith(term) assert mask is not None @@ -682,6 +694,35 @@ def _get_state(self) -> TableState: sort_keys=self.sort_keys, ) + def _get_supported_features(self) -> SupportedFeatures: + row_filter_features = SetRowFiltersFeatures( + supported=True, + supports_conditions=False, + supported_types=[ + RowFilterType.Between, + RowFilterType.Compare, + RowFilterType.IsNull, + RowFilterType.NotNull, + RowFilterType.NotBetween, + RowFilterType.Search, + RowFilterType.SetMembership, + ], + ) + + column_profile_features = GetColumnProfilesFeatures( + supported=True, + supported_types=[ + ColumnProfileType.NullCount, + ColumnProfileType.SummaryStats, + ], + ) + + return SupportedFeatures( + search_schema=SearchSchemaFeatures(supported=True), + set_row_filters=row_filter_features, + get_column_profiles=column_profile_features, + ) + COMPARE_OPS = { CompareFilterParamsOp.Gt: operator.gt, diff --git a/extensions/positron-python/pythonFiles/positron/positron_ipykernel/data_explorer_comm.py b/extensions/positron-python/pythonFiles/positron/positron_ipykernel/data_explorer_comm.py index de002df2025..07c143074fa 100644 --- a/extensions/positron-python/pythonFiles/positron/positron_ipykernel/data_explorer_comm.py +++ b/extensions/positron-python/pythonFiles/positron/positron_ipykernel/data_explorer_comm.py @@ -43,9 +43,9 @@ class ColumnDisplayType(str, enum.Enum): @enum.unique -class RowFilterFilterType(str, enum.Enum): +class RowFilterType(str, enum.Enum): """ - Possible values for FilterType in RowFilter + Possible values for RowFilterType """ Between = "between" @@ -83,9 +83,9 @@ class CompareFilterParamsOp(str, enum.Enum): @enum.unique -class SearchFilterParamsType(str, enum.Enum): +class SearchFilterType(str, enum.Enum): """ - Possible values for Type in SearchFilterParams + Possible values for SearchFilterType """ Contains = "contains" @@ -98,9 +98,9 @@ class SearchFilterParamsType(str, enum.Enum): @enum.unique -class ColumnProfileRequestType(str, enum.Enum): +class ColumnProfileType(str, enum.Enum): """ - Possible values for Type in ColumnProfileRequest + Possible values for ColumnProfileType """ NullCount = "null_count" @@ -161,8 +161,7 @@ class TableState(BaseModel): description="Provides number of rows and columns in table", ) - row_filters: Optional[List[RowFilter]] = Field( - default=None, + row_filters: List[RowFilter] = Field( description="The set of currently applied row filters", ) @@ -185,6 +184,24 @@ class TableShape(BaseModel): ) +class SupportedFeatures(BaseModel): + """ + For each field, returns flags indicating supported features + """ + + search_schema: SearchSchemaFeatures = Field( + description="Support for 'search_schema' RPC and its features", + ) + + set_row_filters: SetRowFiltersFeatures = Field( + description="Support for 'set_row_filters' RPC and its features", + ) + + get_column_profiles: GetColumnProfilesFeatures = Field( + description="Support for 'get_column_profiles' RPC and its features", + ) + + class ColumnSchema(BaseModel): """ Schema for a column in a table @@ -256,8 +273,8 @@ class RowFilter(BaseModel): description="Unique identifier for this filter", ) - filter_type: RowFilterFilterType = Field( - description="Type of filter to apply", + filter_type: RowFilterType = Field( + description="Type of row filter to apply", ) column_index: int = Field( @@ -332,7 +349,7 @@ class SearchFilterParams(BaseModel): Parameters for the 'search' filter type """ - type: SearchFilterParamsType = Field( + search_type: SearchFilterType = Field( description="Type of search to perform", ) @@ -354,7 +371,7 @@ class ColumnProfileRequest(BaseModel): description="The ordinal column index to profile", ) - type: ColumnProfileRequestType = Field( + profile_type: ColumnProfileType = Field( description="The type of analytical column profile", ) @@ -539,6 +556,48 @@ class ColumnSortKey(BaseModel): ) +class SearchSchemaFeatures(BaseModel): + """ + Feature flags for 'search_schema' RPC + """ + + supported: bool = Field( + description="Whether this RPC method is supported at all", + ) + + +class SetRowFiltersFeatures(BaseModel): + """ + Feature flags for 'set_row_filters' RPC + """ + + supported: bool = Field( + description="Whether this RPC method is supported at all", + ) + + supports_conditions: bool = Field( + description="Whether AND/OR filter conditions are supported", + ) + + supported_types: List[RowFilterType] = Field( + description="A list of supported types", + ) + + +class GetColumnProfilesFeatures(BaseModel): + """ + Feature flags for 'get_column_profiles' RPC + """ + + supported: bool = Field( + description="Whether this RPC method is supported at all", + ) + + supported_types: List[ColumnProfileType] = Field( + description="A list of supported types", + ) + + @enum.unique class DataExplorerBackendRequest(str, enum.Enum): """ @@ -566,6 +625,9 @@ class DataExplorerBackendRequest(str, enum.Enum): # Get the state GetState = "get_state" + # Query the backend to determine supported features + GetSupportedFeatures = "get_supported_features" + class GetSchemaParams(BaseModel): """ @@ -778,6 +840,22 @@ class GetStateRequest(BaseModel): ) +class GetSupportedFeaturesRequest(BaseModel): + """ + Query the backend to determine supported features, to enable feature + toggling + """ + + method: Literal[DataExplorerBackendRequest.GetSupportedFeatures] = Field( + description="The JSON-RPC method name (get_supported_features)", + ) + + jsonrpc: str = Field( + default="2.0", + description="The JSON-RPC version specifier", + ) + + class DataExplorerBackendMessageContent(BaseModel): comm_id: str data: Union[ @@ -788,6 +866,7 @@ class DataExplorerBackendMessageContent(BaseModel): SetSortColumnsRequest, GetColumnProfilesRequest, GetStateRequest, + GetSupportedFeaturesRequest, ] = Field(..., discriminator="method") @@ -824,6 +903,8 @@ class SchemaUpdateParams(BaseModel): TableShape.update_forward_refs() +SupportedFeatures.update_forward_refs() + ColumnSchema.update_forward_refs() TableSchema.update_forward_refs() @@ -860,6 +941,12 @@ class SchemaUpdateParams(BaseModel): ColumnSortKey.update_forward_refs() +SearchSchemaFeatures.update_forward_refs() + +SetRowFiltersFeatures.update_forward_refs() + +GetColumnProfilesFeatures.update_forward_refs() + GetSchemaParams.update_forward_refs() GetSchemaRequest.update_forward_refs() @@ -886,4 +973,6 @@ class SchemaUpdateParams(BaseModel): GetStateRequest.update_forward_refs() +GetSupportedFeaturesRequest.update_forward_refs() + SchemaUpdateParams.update_forward_refs() diff --git a/extensions/positron-python/pythonFiles/positron/positron_ipykernel/tests/test_data_explorer.py b/extensions/positron-python/pythonFiles/positron/positron_ipykernel/tests/test_data_explorer.py index 26c04fb157b..efff8e6e771 100644 --- a/extensions/positron-python/pythonFiles/positron/positron_ipykernel/tests/test_data_explorer.py +++ b/extensions/positron-python/pythonFiles/positron/positron_ipykernel/tests/test_data_explorer.py @@ -373,6 +373,9 @@ def search_schema(self, table_name, search_term, start_index, max_results): def get_state(self, table_name): return self.do_json_rpc(table_name, "get_state") + def get_supported_features(self, table_name): + return self.do_json_rpc(table_name, "get_supported_features") + def get_data_values(self, table_name, **params): return self.do_json_rpc(table_name, "get_data_values", **params) @@ -453,6 +456,35 @@ def test_pandas_get_state(dxf: DataExplorerFixture): assert result["row_filters"] == [RowFilter(**f) for f in filters] +def test_pandas_get_supported_features(dxf: DataExplorerFixture): + dxf.register_table("example", SIMPLE_PANDAS_DF) + features = dxf.get_supported_features("example") + + search_schema = features["search_schema"] + row_filters = features["set_row_filters"] + column_profiles = features["get_column_profiles"] + + assert search_schema["supported"] + + assert row_filters["supported"] + assert not row_filters["supports_conditions"] + assert set(row_filters["supported_types"]) == { + "is_null", + "not_null", + "between", + "compare", + "not_between", + "search", + "set_membership", + } + + assert column_profiles["supported"] + assert set(column_profiles["supported_types"]) == { + "null_count", + "summary_stats", + } + + def test_pandas_get_schema(dxf: DataExplorerFixture): result = dxf.get_schema("simple", 0, 100) @@ -668,7 +700,7 @@ def _search_filter(column_index, term, case_sensitive=False, search_type="contai "search", column_index, search_params={ - "type": search_type, + "search_type": search_type, "term": term, "case_sensitive": case_sensitive, }, @@ -935,7 +967,7 @@ def test_pandas_change_schema_after_sort( def _profile_request(column_index, profile_type): - return {"column_index": column_index, "type": profile_type} + return {"column_index": column_index, "profile_type": profile_type} def _get_null_count(column_index): diff --git a/positron/comms/data_explorer-backend-openrpc.json b/positron/comms/data_explorer-backend-openrpc.json index 91d033fb13b..f626b52c55f 100644 --- a/positron/comms/data_explorer-backend-openrpc.json +++ b/positron/comms/data_explorer-backend-openrpc.json @@ -244,7 +244,7 @@ "description": "The current backend table state", "required": [ "table_shape", - "filters", + "row_filters", "sort_keys" ], "properties": { @@ -284,6 +284,38 @@ } } } + }, + { + "name": "get_supported_features", + "summary": "Query the backend to determine supported features", + "description": "Query the backend to determine supported features, to enable feature toggling", + "params": [], + "result": { + "schema": { + "type": "object", + "name": "supported_features", + "description": "For each field, returns flags indicating supported features", + "required": [ + "search_schema", + "set_row_filters", + "get_column_profiles" + ], + "properties": { + "search_schema": { + "description": "Support for 'search_schema' RPC and its features", + "$ref": "#/components/schemas/search_schema_features" + }, + "set_row_filters": { + "description": "Support for 'set_row_filters' RPC and its features", + "$ref": "#/components/schemas/set_row_filters_features" + }, + "get_column_profiles": { + "description": "Support for 'get_column_profiles' RPC and its features", + "$ref": "#/components/schemas/get_column_profiles_features" + } + } + } + } } ], "components": { @@ -390,17 +422,8 @@ "description": "Unique identifier for this filter" }, "filter_type": { - "type": "string", - "description": "Type of filter to apply", - "enum": [ - "between", - "compare", - "is_null", - "not_between", - "not_null", - "search", - "set_membership" - ] + "description": "Type of row filter to apply", + "$ref": "#/components/schemas/row_filter_type" }, "column_index": { "type": "integer", @@ -424,6 +447,19 @@ } } }, + "row_filter_type": { + "type": "string", + "description": "Type of row filter", + "enum": [ + "between", + "compare", + "is_null", + "not_between", + "not_null", + "search", + "set_membership" + ] + }, "between_filter_params": { "type": "object", "description": "Parameters for the 'between' and 'not_between' filter types", @@ -493,20 +529,14 @@ "type": "object", "description": "Parameters for the 'search' filter type", "required": [ - "type", + "search_type", "term", "case_sensitive" ], "properties": { - "type": { - "type": "string", - "description": "Type of search to perform", - "enum": [ - "contains", - "starts_with", - "ends_with", - "regex_match" - ] + "search_type": { + "$ref": "#/components/schemas/search_filter_type", + "description": "Type of search to perform" }, "term": { "type": "string", @@ -518,30 +548,44 @@ } } }, + "search_filter_type": { + "type": "string", + "description": "Type of string search filter to perform", + "enum": [ + "contains", + "starts_with", + "ends_with", + "regex_match" + ] + }, "column_profile_request": { "type": "object", "description": "A single column profile request", "required": [ "column_index", - "type" + "profile_type" ], "properties": { "column_index": { "type": "integer", "description": "The ordinal column index to profile" }, - "type": { - "type": "string", + "profile_type": { "description": "The type of analytical column profile", - "enum": [ - "null_count", - "summary_stats", - "frequency_table", - "histogram" - ] + "$ref": "#/components/schemas/column_profile_type" } } }, + "column_profile_type": { + "type": "string", + "description": "Type of analytical column profile", + "enum": [ + "null_count", + "summary_stats", + "frequency_table", + "histogram" + ] + }, "column_profile_result": { "type": "object", "description": "Result of computing column profile", @@ -755,6 +799,66 @@ "description": "Sort order, ascending (true) or descending (false)" } } + }, + "search_schema_features": { + "type": "object", + "description": "Feature flags for 'search_schema' RPC", + "required": [ + "supported" + ], + "properties": { + "supported": { + "type": "boolean", + "description": "Whether this RPC method is supported at all" + } + } + }, + "set_row_filters_features": { + "type": "object", + "description": "Feature flags for 'set_row_filters' RPC", + "required": [ + "supported", + "supports_conditions", + "supported_types" + ], + "properties": { + "supported": { + "type": "boolean", + "description": "Whether this RPC method is supported at all" + }, + "supports_conditions": { + "type": "boolean", + "description": "Whether AND/OR filter conditions are supported" + }, + "supported_types": { + "type": "array", + "description": "A list of supported types", + "items": { + "$ref": "#/components/schemas/row_filter_type" + } + } + } + }, + "get_column_profiles_features": { + "type": "object", + "description": "Feature flags for 'get_column_profiles' RPC", + "required": [ + "supported", + "supported_types" + ], + "properties": { + "supported": { + "type": "boolean", + "description": "Whether this RPC method is supported at all" + }, + "supported_types": { + "type": "array", + "description": "A list of supported types", + "items": { + "$ref": "#/components/schemas/column_profile_type" + } + } + } } } } diff --git a/src/vs/workbench/services/languageRuntime/common/positronDataExplorerComm.ts b/src/vs/workbench/services/languageRuntime/common/positronDataExplorerComm.ts index ae4f15dc01d..7253d51e01c 100644 --- a/src/vs/workbench/services/languageRuntime/common/positronDataExplorerComm.ts +++ b/src/vs/workbench/services/languageRuntime/common/positronDataExplorerComm.ts @@ -65,7 +65,7 @@ export interface TableState { /** * The set of currently applied row filters */ - row_filters?: Array; + row_filters: Array; /** * The set of currently applied sorts @@ -90,6 +90,27 @@ export interface TableShape { } +/** + * For each field, returns flags indicating supported features + */ +export interface SupportedFeatures { + /** + * Support for 'search_schema' RPC and its features + */ + search_schema: SearchSchemaFeatures; + + /** + * Support for 'set_row_filters' RPC and its features + */ + set_row_filters: SetRowFiltersFeatures; + + /** + * Support for 'get_column_profiles' RPC and its features + */ + get_column_profiles: GetColumnProfilesFeatures; + +} + /** * Schema for a column in a table */ @@ -167,9 +188,9 @@ export interface RowFilter { filter_id: string; /** - * Type of filter to apply + * Type of row filter to apply */ - filter_type: RowFilterFilterType; + filter_type: RowFilterType; /** * Column index to apply filter to @@ -253,7 +274,7 @@ export interface SearchFilterParams { /** * Type of search to perform */ - type: SearchFilterParamsType; + search_type: SearchFilterType; /** * String value/regex to search for in stringified data @@ -279,7 +300,7 @@ export interface ColumnProfileRequest { /** * The type of analytical column profile */ - type: ColumnProfileRequestType; + profile_type: ColumnProfileType; } @@ -485,6 +506,54 @@ export interface ColumnSortKey { } +/** + * Feature flags for 'search_schema' RPC + */ +export interface SearchSchemaFeatures { + /** + * Whether this RPC method is supported at all + */ + supported: boolean; + +} + +/** + * Feature flags for 'set_row_filters' RPC + */ +export interface SetRowFiltersFeatures { + /** + * Whether this RPC method is supported at all + */ + supported: boolean; + + /** + * Whether AND/OR filter conditions are supported + */ + supports_conditions: boolean; + + /** + * A list of supported types + */ + supported_types: Array; + +} + +/** + * Feature flags for 'get_column_profiles' RPC + */ +export interface GetColumnProfilesFeatures { + /** + * Whether this RPC method is supported at all + */ + supported: boolean; + + /** + * A list of supported types + */ + supported_types: Array; + +} + /** * Possible values for ColumnDisplayType */ @@ -501,9 +570,9 @@ export enum ColumnDisplayType { } /** - * Possible values for FilterType in RowFilter + * Possible values for RowFilterType */ -export enum RowFilterFilterType { +export enum RowFilterType { Between = 'between', Compare = 'compare', IsNull = 'is_null', @@ -526,9 +595,9 @@ export enum CompareFilterParamsOp { } /** - * Possible values for Type in SearchFilterParams + * Possible values for SearchFilterType */ -export enum SearchFilterParamsType { +export enum SearchFilterType { Contains = 'contains', StartsWith = 'starts_with', EndsWith = 'ends_with', @@ -536,9 +605,9 @@ export enum SearchFilterParamsType { } /** - * Possible values for Type in ColumnProfileRequest + * Possible values for ColumnProfileType */ -export enum ColumnProfileRequestType { +export enum ColumnProfileType { NullCount = 'null_count', SummaryStats = 'summary_stats', FrequencyTable = 'frequency_table', @@ -674,6 +743,19 @@ export class PositronDataExplorerComm extends PositronBaseComm { return super.performRpc('get_state', [], []); } + /** + * Query the backend to determine supported features + * + * Query the backend to determine supported features, to enable feature + * toggling + * + * + * @returns For each field, returns flags indicating supported features + */ + getSupportedFeatures(): Promise { + return super.performRpc('get_supported_features', [], []); + } + /** * Reset after a schema change diff --git a/src/vs/workbench/services/positronDataExplorer/common/dataExplorerCache.ts b/src/vs/workbench/services/positronDataExplorer/common/dataExplorerCache.ts index 1696850f065..2db4a89faa1 100644 --- a/src/vs/workbench/services/positronDataExplorer/common/dataExplorerCache.ts +++ b/src/vs/workbench/services/positronDataExplorer/common/dataExplorerCache.ts @@ -4,7 +4,7 @@ import { Emitter } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; -import { ColumnProfileRequestType, ColumnSchema, ColumnSummaryStats, TableData } from 'vs/workbench/services/languageRuntime/common/positronDataExplorerComm'; +import { ColumnProfileType, ColumnSchema, ColumnSummaryStats, TableData } from 'vs/workbench/services/languageRuntime/common/positronDataExplorerComm'; import { DataExplorerClientInstance } from 'vs/workbench/services/languageRuntime/common/languageRuntimeDataExplorerClient'; /** @@ -213,7 +213,7 @@ export class DataExplorerCache extends Disposable { columnIndices.map(column_index => { return { column_index, - type: ColumnProfileRequestType.SummaryStats + profile_type: ColumnProfileType.SummaryStats }; }) ); @@ -330,7 +330,7 @@ export class DataExplorerCache extends Disposable { columnNullCountIndices.map(column_index => { return { column_index, - type: ColumnProfileRequestType.NullCount + profile_type: ColumnProfileType.NullCount }; }) ); diff --git a/src/vs/workbench/services/positronDataExplorer/common/positronDataExplorerMocks.ts b/src/vs/workbench/services/positronDataExplorer/common/positronDataExplorerMocks.ts index c8e8cb50259..91b03069d14 100644 --- a/src/vs/workbench/services/positronDataExplorer/common/positronDataExplorerMocks.ts +++ b/src/vs/workbench/services/positronDataExplorer/common/positronDataExplorerMocks.ts @@ -5,11 +5,11 @@ import { generateUuid } from 'vs/base/common/uuid'; import { CompareFilterParamsOp, - SearchFilterParamsType, + SearchFilterType, ColumnSchema, ColumnProfileResult, RowFilter, - RowFilterFilterType, + RowFilterType, TableData, TableSchema } from 'vs/workbench/services/languageRuntime/common/positronDataExplorerComm'; @@ -119,7 +119,7 @@ export function getExampleFreqtable(): ColumnProfileResult { // For filtering -function _getFilterWithProps(columnIndex: number, filterType: RowFilterFilterType, +function _getFilterWithProps(columnIndex: number, filterType: RowFilterType, props: Partial = {}): RowFilter { return { filter_id: generateUuid(), @@ -131,27 +131,27 @@ function _getFilterWithProps(columnIndex: number, filterType: RowFilterFilterTyp export function getCompareFilter(columnIndex: number, op: CompareFilterParamsOp, value: string) { - return _getFilterWithProps(columnIndex, RowFilterFilterType.Compare, + return _getFilterWithProps(columnIndex, RowFilterType.Compare, { compare_params: { op, value } }); } export function getIsNullFilter(columnIndex: number) { - return _getFilterWithProps(columnIndex, RowFilterFilterType.IsNull); + return _getFilterWithProps(columnIndex, RowFilterType.IsNull); } export function getNotNullFilter(columnIndex: number) { - return _getFilterWithProps(columnIndex, RowFilterFilterType.NotNull); + return _getFilterWithProps(columnIndex, RowFilterType.NotNull); } export function getSetMemberFilter(columnIndex: number, values: string[], inclusive: boolean) { - return _getFilterWithProps(columnIndex, RowFilterFilterType.SetMembership, { + return _getFilterWithProps(columnIndex, RowFilterType.SetMembership, { set_membership_params: { values, inclusive } }); } export function getTextSearchFilter(columnIndex: number, searchTerm: string, - searchType: SearchFilterParamsType, caseSensitive: boolean) { - return _getFilterWithProps(columnIndex, RowFilterFilterType.Search, { - search_params: { term: searchTerm, type: searchType, case_sensitive: caseSensitive } + searchType: SearchFilterType, caseSensitive: boolean) { + return _getFilterWithProps(columnIndex, RowFilterType.Search, { + search_params: { term: searchTerm, search_type: searchType, case_sensitive: caseSensitive } }); } diff --git a/src/vs/workbench/services/positronDataExplorer/test/common/positronDataExplorerMocks.test.ts b/src/vs/workbench/services/positronDataExplorer/test/common/positronDataExplorerMocks.test.ts index 7fcead87985..83f530f36c8 100644 --- a/src/vs/workbench/services/positronDataExplorer/test/common/positronDataExplorerMocks.test.ts +++ b/src/vs/workbench/services/positronDataExplorer/test/common/positronDataExplorerMocks.test.ts @@ -6,8 +6,8 @@ import * as assert from 'assert'; import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils'; import { CompareFilterParamsOp, - RowFilterFilterType, - SearchFilterParamsType + RowFilterType, + SearchFilterType } from 'vs/workbench/services/languageRuntime/common/positronDataExplorerComm'; import * as mocks from "vs/workbench/services/positronDataExplorer/common/positronDataExplorerMocks"; @@ -40,7 +40,7 @@ suite('DataExplorerMocks', () => { test('Test getCompareFilter', () => { const filter = mocks.getCompareFilter(2, CompareFilterParamsOp.Gt, '1234'); - assert.equal(filter.filter_type, RowFilterFilterType.Compare); + assert.equal(filter.filter_type, RowFilterType.Compare); assert.equal(filter.column_index, 2); const params = filter.compare_params!; @@ -52,22 +52,22 @@ suite('DataExplorerMocks', () => { test('Test getIsNullFilter', () => { let filter = mocks.getIsNullFilter(3); assert.equal(filter.column_index, 3); - assert.equal(filter.filter_type, RowFilterFilterType.IsNull); + assert.equal(filter.filter_type, RowFilterType.IsNull); filter = mocks.getNotNullFilter(3); - assert.equal(filter.filter_type, RowFilterFilterType.NotNull); + assert.equal(filter.filter_type, RowFilterType.NotNull); }); test('Test getTextSearchFilter', () => { const filter = mocks.getTextSearchFilter(5, 'needle', - SearchFilterParamsType.Contains, false); + SearchFilterType.Contains, false); assert.equal(filter.column_index, 5); - assert.equal(filter.filter_type, RowFilterFilterType.Search); + assert.equal(filter.filter_type, RowFilterType.Search); const params = filter.search_params!; assert.equal(params.term, 'needle'); - assert.equal(params.type, SearchFilterParamsType.Contains); + assert.equal(params.search_type, SearchFilterType.Contains); assert.equal(params.case_sensitive, false); }); @@ -75,7 +75,7 @@ suite('DataExplorerMocks', () => { const set_values = ['need1', 'need2']; const filter = mocks.getSetMemberFilter(6, set_values, true); assert.equal(filter.column_index, 6); - assert.equal(filter.filter_type, RowFilterFilterType.SetMembership); + assert.equal(filter.filter_type, RowFilterType.SetMembership); const params = filter.set_membership_params!;