From af4e1d10b44538dac917698fbfb77884cf530ef1 Mon Sep 17 00:00:00 2001 From: asier-isayas Date: Fri, 18 Apr 2025 14:39:31 -0400 Subject: [PATCH] GSI: Remove Unique Key Policy and Manual Throughput (#2114) * Remove Unique Key Policy and Manual Throughput * fix tests * remove manual throughput option from scale & settings * fix test * cleanup --------- Co-authored-by: Asier Isayas --- .../Controls/Settings/SettingsComponent.tsx | 1 + .../ScaleComponent.test.tsx | 1 + .../SettingsSubComponents/ScaleComponent.tsx | 2 + ...roughputInputAutoPilotV3Component.test.tsx | 1 + .../ThroughputInputAutoPilotV3Component.tsx | 35 +++++---- .../SettingsComponent.test.tsx.snap | 1 + .../ThroughputInput/ThroughputInput.tsx | 70 +++++++++-------- .../AddGlobalSecondaryIndexPanel.tsx | 45 +++-------- .../Components/ThroughputComponent.tsx | 7 +- .../Components/UniqueKeysComponent.tsx | 78 ------------------- ...AddGlobalSecondaryIndexPanel.test.tsx.snap | 5 -- 11 files changed, 74 insertions(+), 172 deletions(-) delete mode 100644 src/Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/UniqueKeysComponent.tsx diff --git a/src/Explorer/Controls/Settings/SettingsComponent.tsx b/src/Explorer/Controls/Settings/SettingsComponent.tsx index 2613fe65b..684858c56 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.tsx @@ -1149,6 +1149,7 @@ export class SettingsComponent extends React.Component { collection: collection, database: undefined, isFixedContainer: false, + isGlobalSecondaryIndex: false, onThroughputChange: () => { return; }, diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx index 251a3b841..1928a68e6 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ScaleComponent.tsx @@ -22,6 +22,7 @@ export interface ScaleComponentProps { collection: ViewModels.Collection; database: ViewModels.Database; isFixedContainer: boolean; + isGlobalSecondaryIndex: boolean; onThroughputChange: (newThroughput: number) => void; throughput: number; throughputBaseline: number; @@ -143,6 +144,7 @@ export class ScaleComponent extends React.Component { throughputError={this.props.throughputError} instantMaximumThroughput={this.offer?.instantMaximumThroughput} softAllowedMaximumThroughput={this.offer?.softAllowedMaximumThroughput} + isGlobalSecondaryIndex={this.props.isGlobalSecondaryIndex} /> ); diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.test.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.test.tsx index ff7b715b3..a02d907b3 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.test.tsx @@ -44,6 +44,7 @@ describe("ThroughputInputAutoPilotV3Component", () => { }, instantMaximumThroughput: 5000, softAllowedMaximumThroughput: 1000000, + isGlobalSecondaryIndex: false, }; it("throughput input visible", () => { diff --git a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx index 391789938..2ae5dcfc9 100644 --- a/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx +++ b/src/Explorer/Controls/Settings/SettingsSubComponents/ThroughputInputComponents/ThroughputInputAutoPilotV3Component.tsx @@ -80,6 +80,7 @@ export interface ThroughputInputAutoPilotV3Props { throughputError?: string; instantMaximumThroughput: number; softAllowedMaximumThroughput: number; + isGlobalSecondaryIndex: boolean; } interface ThroughputInputAutoPilotV3State { @@ -375,22 +376,26 @@ export class ThroughputInputAutoPilotV3Component extends React.Component< toolTipElement={getToolTipContainer(this.props.infoBubbleText)} /> - {this.overrideWithProvisionedThroughputSettings() && ( - - {manualToAutoscaleDisclaimerElement} - + {!this.props.isGlobalSecondaryIndex && ( + <> + {this.overrideWithProvisionedThroughputSettings() && ( + + {manualToAutoscaleDisclaimerElement} + + )} + + )} - ); }; diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index ac2aa4fa3..7a54134db 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -79,6 +79,7 @@ exports[`SettingsComponent renders 1`] = ` } isAutoPilotSelected={false} isFixedContainer={false} + isGlobalSecondaryIndex={true} onAutoPilotSelected={[Function]} onMaxAutoPilotThroughputChange={[Function]} onScaleDiscardableChange={[Function]} diff --git a/src/Explorer/Controls/ThroughputInput/ThroughputInput.tsx b/src/Explorer/Controls/ThroughputInput/ThroughputInput.tsx index 9fb5b28f9..af0219be1 100644 --- a/src/Explorer/Controls/ThroughputInput/ThroughputInput.tsx +++ b/src/Explorer/Controls/ThroughputInput/ThroughputInput.tsx @@ -18,6 +18,7 @@ export interface ThroughputInputProps { isFreeTier: boolean; showFreeTierExceedThroughputTooltip: boolean; isQuickstart?: boolean; + isGlobalSecondaryIndex?: boolean; setThroughputValue: (throughput: number) => void; setIsAutoscale: (isAutoscale: boolean) => void; setIsThroughputCapExceeded: (isThroughputCapExceeded: boolean) => void; @@ -30,6 +31,7 @@ export const ThroughputInput: FunctionComponent = ({ isFreeTier, showFreeTierExceedThroughputTooltip, isQuickstart, + isGlobalSecondaryIndex, setThroughputValue, setIsAutoscale, setIsThroughputCapExceeded, @@ -193,41 +195,41 @@ export const ThroughputInput: FunctionComponent = ({ {PricingUtils.getRuToolTipText()} + {!isGlobalSecondaryIndex && ( + +
+ handleOnChangeMode(e, "Autoscale")} + /> + - -
- handleOnChangeMode(e, "Autoscale")} - /> - - - handleOnChangeMode(e, "Manual")} - /> - -
-
- + handleOnChangeMode(e, "Manual")} + /> + +
+
+ )} {isAutoscaleSelected && ( diff --git a/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/AddGlobalSecondaryIndexPanel.tsx b/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/AddGlobalSecondaryIndexPanel.tsx index 313c72b4c..ba49299fb 100644 --- a/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/AddGlobalSecondaryIndexPanel.tsx +++ b/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/AddGlobalSecondaryIndexPanel.tsx @@ -22,7 +22,6 @@ import { FullTextPolicyDefault, getPartitionKey, isSynapseLinkEnabled, - parseUniqueKeys, scrollToSection, shouldShowAnalyticalStoreOptions, } from "Explorer/Panes/AddCollectionPanel/AddCollectionPanelUtility"; @@ -35,7 +34,6 @@ import { AnalyticalStoreComponent } from "Explorer/Panes/AddGlobalSecondaryIndex import { FullTextSearchComponent } from "Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/FullTextSearchComponent"; import { PartitionKeyComponent } from "Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/PartitionKeyComponent"; import { ThroughputComponent } from "Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/ThroughputComponent"; -import { UniqueKeysComponent } from "Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/UniqueKeysComponent"; import { VectorSearchComponent } from "Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/VectorSearchComponent"; import { PanelFooterComponent } from "Explorer/Panes/PanelFooterComponent"; import { PanelInfoErrorComponent } from "Explorer/Panes/PanelInfoErrorComponent"; @@ -66,14 +64,13 @@ export const AddGlobalSecondaryIndexPanel = (props: AddGlobalSecondaryIndexPanel const [useHashV1, setUseHashV1] = useState(); const [enableDedicatedThroughput, setEnabledDedicatedThroughput] = useState(); const [isThroughputCapExceeded, setIsThroughputCapExceeded] = useState(); - const [uniqueKeys, setUniqueKeys] = useState([]); const [enableAnalyticalStore, setEnableAnalyticalStore] = useState(); - const [vectorEmbeddingPolicy, setVectorEmbeddingPolicy] = useState(); - const [vectorIndexingPolicy, setVectorIndexingPolicy] = useState(); - const [vectorPolicyValidated, setVectorPolicyValidated] = useState(); + const [vectorEmbeddingPolicy, setVectorEmbeddingPolicy] = useState([]); + const [vectorIndexingPolicy, setVectorIndexingPolicy] = useState([]); + const [vectorPolicyValidated, setVectorPolicyValidated] = useState(true); const [fullTextPolicy, setFullTextPolicy] = useState(FullTextPolicyDefault); - const [fullTextIndexes, setFullTextIndexes] = useState(); - const [fullTextPolicyValidated, setFullTextPolicyValidated] = useState(); + const [fullTextIndexes, setFullTextIndexes] = useState([]); + const [fullTextPolicyValidated, setFullTextPolicyValidated] = useState(true); const [errorMessage, setErrorMessage] = useState(); const [showErrorDetails, setShowErrorDetails] = useState(); const [isExecuting, setIsExecuting] = useState(); @@ -109,17 +106,12 @@ export const AddGlobalSecondaryIndexPanel = (props: AddGlobalSecondaryIndexPanel }, [errorMessage]); let globalSecondaryIndexThroughput: number; - let isGlobalSecondaryIndexAutoscale: boolean; let isCostAcknowledged: boolean; const globalSecondaryIndexThroughputOnChange = (globalSecondaryIndexThroughputValue: number): void => { globalSecondaryIndexThroughput = globalSecondaryIndexThroughputValue; }; - const isGlobalSecondaryIndexAutoscaleOnChange = (isGlobalSecondaryIndexAutoscaleValue: boolean): void => { - isGlobalSecondaryIndexAutoscale = isGlobalSecondaryIndexAutoscaleValue; - }; - const isCostAknowledgedOnChange = (isCostAcknowledgedValue: boolean): void => { isCostAcknowledged = isCostAcknowledgedValue; }; @@ -178,9 +170,7 @@ export const AddGlobalSecondaryIndexPanel = (props: AddGlobalSecondaryIndexPanel } if (globalSecondaryIndexThroughput > CollectionCreation.DefaultCollectionRUs100K && !isCostAcknowledged) { - const errorMessage = isGlobalSecondaryIndexAutoscale - ? "Please acknowledge the estimated monthly spend." - : "Please acknowledge the estimated daily spend."; + const errorMessage: string = "Please acknowledge the estimated monthly spend."; setErrorMessage(errorMessage); return false; } @@ -221,7 +211,6 @@ export const AddGlobalSecondaryIndexPanel = (props: AddGlobalSecondaryIndexPanel const partitionKeyTrimmed: string = partitionKey.trim(); - const uniqueKeyPolicy: DataModels.UniqueKeyPolicy = parseUniqueKeys(uniqueKeys); const partitionKeyVersion = useHashV1 ? undefined : 2; const partitionKeyPaths: DataModels.PartitionKey = partitionKeyTrimmed ? { @@ -256,9 +245,8 @@ export const AddGlobalSecondaryIndexPanel = (props: AddGlobalSecondaryIndexPanel collection: { id: globalSecondaryIdTrimmed, throughput: globalSecondaryIndexThroughput, - isAutoscale: isGlobalSecondaryIndexAutoscale, + isAutoscale: true, partitionKeyPaths, - uniqueKeyPolicy, collectionWithDedicatedThroughput: enableDedicatedThroughput, }, subscriptionQuotaId: userContext.quotaId, @@ -268,28 +256,17 @@ export const AddGlobalSecondaryIndexPanel = (props: AddGlobalSecondaryIndexPanel const startKey: number = TelemetryProcessor.traceStart(Action.CreateCollection, telemetryData); const databaseLevelThroughput: boolean = isSelectedSourceContainerSharedThroughput() && !enableDedicatedThroughput; - let offerThroughput: number; - let autoPilotMaxThroughput: number; - - if (!databaseLevelThroughput) { - if (isGlobalSecondaryIndexAutoscale) { - autoPilotMaxThroughput = globalSecondaryIndexThroughput; - } else { - offerThroughput = globalSecondaryIndexThroughput; - } - } - const createGlobalSecondaryIndexParams: DataModels.CreateMaterializedViewsParams = { materializedViewId: globalSecondaryIdTrimmed, materializedViewDefinition: globalSecondaryIndexDefinition, databaseId: selectedSourceContainer.databaseId, databaseLevelThroughput: databaseLevelThroughput, - offerThroughput: offerThroughput, - autoPilotMaxThroughput: autoPilotMaxThroughput, + ...(!databaseLevelThroughput && { + autoPilotMaxThroughput: globalSecondaryIndexThroughput, + }), analyticalStorageTtl: getAnalyticalStorageTtl(), indexingPolicy: indexingPolicy, partitionKey: partitionKeyPaths, - uniqueKeyPolicy: uniqueKeyPolicy, vectorEmbeddingPolicy: vectorEmbeddingPolicyFinal, fullTextPolicy: fullTextPolicy, }; @@ -395,12 +372,10 @@ export const AddGlobalSecondaryIndexPanel = (props: AddGlobalSecondaryIndexPanel isSelectedSourceContainerSharedThroughput, showCollectionThroughputInput, globalSecondaryIndexThroughputOnChange, - isGlobalSecondaryIndexAutoscaleOnChange, setIsThroughputCapExceeded, isCostAknowledgedOnChange, }} /> - {shouldShowAnalyticalStoreOptions() && ( )} diff --git a/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/ThroughputComponent.tsx b/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/ThroughputComponent.tsx index 07669906f..0999acc5a 100644 --- a/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/ThroughputComponent.tsx +++ b/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/ThroughputComponent.tsx @@ -12,7 +12,6 @@ export interface ThroughputComponentProps { isSelectedSourceContainerSharedThroughput: () => boolean; showCollectionThroughputInput: () => boolean; globalSecondaryIndexThroughputOnChange: (globalSecondaryIndexThroughputValue: number) => void; - isGlobalSecondaryIndexAutoscaleOnChange: (isGlobalSecondaryIndexAutoscaleValue: boolean) => void; setIsThroughputCapExceeded: React.Dispatch>; isCostAknowledgedOnChange: (isCostAknowledgedValue: boolean) => void; } @@ -24,7 +23,6 @@ export const ThroughputComponent = (props: ThroughputComponentProps): JSX.Elemen isSelectedSourceContainerSharedThroughput, showCollectionThroughputInput, globalSecondaryIndexThroughputOnChange, - isGlobalSecondaryIndexAutoscaleOnChange, setIsThroughputCapExceeded, isCostAknowledgedOnChange, } = props; @@ -52,12 +50,11 @@ export const ThroughputComponent = (props: ThroughputComponentProps): JSX.Elemen isSharded={false} isFreeTier={isFreeTierAccount()} isQuickstart={false} + isGlobalSecondaryIndex={true} setThroughputValue={(throughput: number) => { globalSecondaryIndexThroughputOnChange(throughput); }} - setIsAutoscale={(isAutoscale: boolean) => { - isGlobalSecondaryIndexAutoscaleOnChange(isAutoscale); - }} + setIsAutoscale={() => {}} setIsThroughputCapExceeded={(isThroughputCapExceeded: boolean) => { setIsThroughputCapExceeded(isThroughputCapExceeded); }} diff --git a/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/UniqueKeysComponent.tsx b/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/UniqueKeysComponent.tsx deleted file mode 100644 index ab46c8d41..000000000 --- a/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/Components/UniqueKeysComponent.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import { ActionButton, IconButton, Stack } from "@fluentui/react"; -import { UniqueKeysHeader } from "Explorer/Panes/AddCollectionPanel/AddCollectionPanelUtility"; -import React from "react"; -import { userContext } from "UserContext"; - -export interface UniqueKeysComponentProps { - uniqueKeys: string[]; - setUniqueKeys: React.Dispatch>; -} - -export const UniqueKeysComponent = (props: UniqueKeysComponentProps): JSX.Element => { - const { uniqueKeys, setUniqueKeys } = props; - - const updateUniqueKeysOnChange = (value: string, uniqueKeyToReplaceIndex: number): void => { - const updatedUniqueKeys = uniqueKeys.map((uniqueKey: string, uniqueKeyIndex: number) => { - if (uniqueKeyToReplaceIndex === uniqueKeyIndex) { - return value; - } - return uniqueKey; - }); - setUniqueKeys(updatedUniqueKeys); - }; - - const deleteUniqueKeyOnClick = (uniqueKeyToDeleteIndex: number): void => { - const updatedUniqueKeys = uniqueKeys.filter((_, uniqueKeyIndex) => uniqueKeyToDeleteIndex !== uniqueKeyIndex); - setUniqueKeys(updatedUniqueKeys); - }; - - const addUniqueKeyOnClick = (): void => { - setUniqueKeys([...uniqueKeys, ""]); - }; - - return ( - - {UniqueKeysHeader()} - - {uniqueKeys.map((uniqueKey: string, uniqueKeyIndex: number): JSX.Element => { - return ( - - ) => { - updateUniqueKeysOnChange(event.target.value, uniqueKeyIndex); - }} - /> - - { - deleteUniqueKeyOnClick(uniqueKeyIndex); - }} - /> - - ); - })} - - { - addUniqueKeyOnClick(); - }} - > - Add unique key - - - ); -}; diff --git a/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/__snapshots__/AddGlobalSecondaryIndexPanel.test.tsx.snap b/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/__snapshots__/AddGlobalSecondaryIndexPanel.test.tsx.snap index 143c1f804..cef30c445 100644 --- a/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/__snapshots__/AddGlobalSecondaryIndexPanel.test.tsx.snap +++ b/src/Explorer/Panes/AddGlobalSecondaryIndexPanel/__snapshots__/AddGlobalSecondaryIndexPanel.test.tsx.snap @@ -137,16 +137,11 @@ exports[`AddGlobalSecondaryIndexPanel render default panel 1`] = ` -