codeant-ai-for-open-source[bot] commented on code in PR #43891: URL: https://github.com/apache/superset/pull/43891#discussion_r3939217512
########## superset-frontend/src/components/Datasource/components/DatasourceEditor/components/PartitionFilterMapping/PartitionMappingSection.tsx: ########## @@ -0,0 +1,280 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { t } from '@apache-superset/core/translation'; +import { css, useTheme } from '@apache-superset/core/theme'; +import { Alert } from '@apache-superset/core/components'; +import { + Button, + Checkbox, + Flex, + Icons, + InfoTooltip, + Input, + Loading, + Typography, +} from '@superset-ui/core/components'; +import { usePartitionMappingPreview } from './usePartitionMappingPreview'; +import { + partitionRowState, + previewOperatorFor, + sampleValuesFor, +} from './utils'; +import type { PartitionMappingColumn, PartitionMappingDatasource } from './types'; + +interface PartitionMappingSectionProps { + /** Injected by Field when `passItemToControl` is set. */ + item?: PartitionMappingColumn; + /** The column's `partition_value_transform`, injected by Field. */ + value?: string | null; + onChange?: (newValue: string | null) => void; + datasource: PartitionMappingDatasource; + /** Move the mapping onto this column, pre-filling a transform if we have one. */ + onMoveMappingHere: (columnName: string) => void; + onRemoveMapping: () => void; + onMonotonicChange: (columnName: string, isMonotonic: boolean) => void; +} + +/** + * The "Partition filter mapping" subsection of a column's row expand + * (wireframes 1c, 1h). + * + * Three states, because the model is one partition column and one mapped + * column: the mapped column carries the transform, every other column offers to + * take the mapping over, and the partition column itself shows nothing -- it is + * the target, not a source. + */ +export default function PartitionMappingSection({ + item, + value, + onChange, + datasource, + onMoveMappingHere, + onRemoveMapping, + onMonotonicChange, +}: PartitionMappingSectionProps) { + const theme = useTheme(); + const columnName = item?.column_name ?? ''; + const state = partitionRowState(datasource, columnName); + const isMonotonic = Boolean(item?.partition_transform_is_monotonic); + const transform = value ?? ''; + const isTemporal = Boolean(item?.is_dttm); + + const { preview, loading } = usePartitionMappingPreview({ + datasetId: datasource.id, + mappedColumn: columnName, + partitionColumn: datasource.partition_column ?? '', + valueTransform: transform, + sampleValues: sampleValuesFor(item), + operator: previewOperatorFor(item), + isMonotonic, + enabled: state === 'mapped', Review Comment: **Suggestion:** Every mapped row sends previews after debounce, including invalid transforms; the backend consumes its rate-limit budget before validation, so repeated typing can block later valid previews. [performance] **Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` [](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6188cf3d4d7e48c2abc7a4a864fd097f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6188cf3d4d7e48c2abc7a4a864fd097f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) <details> <summary><b>Prompt for AI Agent ๐ค </b></summary> ```mdx This is a comment left during a code review. **Path:** superset-frontend/src/components/Datasource/components/DatasourceEditor/components/PartitionFilterMapping/PartitionMappingSection.tsx **Line:** 86:86 **Comment:** *Performance: Every mapped row sends previews after debounce, including invalid transforms; the backend consumes its rate-limit budget before validation, so repeated typing can block later valid previews. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43891&comment_hash=e0d2e18e503e955a5b2cf1f09a3968dffe625126f754c4242cfa9b14f735d762&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43891&comment_hash=e0d2e18e503e955a5b2cf1f09a3968dffe625126f754c4242cfa9b14f735d762&reaction=dislike'>๐</a> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
